Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ab2d-6288/springboot upgrade #105

Merged
merged 13 commits into from
Feb 26, 2025
55 changes: 27 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
plugins {
id 'java'
id 'org.springframework.boot' version "2.7.6"
id 'com.jfrog.artifactory' version '4.33.1' apply false
id "org.sonarqube" version "4.1.0.3113"
id "gov.cms.ab2d.plugin" version "1.0.2"
id 'maven-publish'
id 'org.cyclonedx.bom' version '1.7.4' apply true
}

version="1.0.1"
version="2.0.0"
group = "gov.cms.ab2d"

ext {
springCloudAwsVersion = '2.4.4'
lombokVersion = '1.18.34'
springCloudAwsVersion = '3.1.1'
springBootVersion='3.2.8'
testContainerVersion='1.20.1'
}

allprojects {
apply plugin: "org.cyclonedx.bom"
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-quartz:2.7.6'
implementation 'gov.cms.ab2d:ab2d-events-client:3.1.0'
implementation 'gov.cms.ab2d:ab2d-contracts-client:2.0.0'
implementation 'gov.cms.ab2d:ab2d-properties-client:2.0.0'
implementation "io.awspring.cloud:spring-cloud-aws:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-aws-dependencies:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-aws-starter:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-aws-starter-sqs:${springCloudAwsVersion}"
implementation 'net.logstash.logback:logstash-logback-encoder:7.3'
implementation 'org.springframework.boot:spring-boot-starter-webflux:2.7.6'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.6'
testImplementation 'org.mockito:mockito-inline:5.2.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.6'
implementation 'org.springframework.boot:spring-boot-starter-validation:2.7.6'
implementation 'org.springframework.boot:spring-boot-starter-web:2.7.6'
implementation 'org.liquibase:liquibase-core:4.23.0'
implementation 'org.postgresql:postgresql:42.7.3'
implementation 'org.liquibase:liquibase-core:4.22.0'
implementation 'gov.cms.ab2d:ab2d-events-client:1.12.9'
implementation 'gov.cms.ab2d:ab2d-contracts-client:1.2.4'
implementation 'gov.cms.ab2d:ab2d-properties-client:1.2.5'
implementation "io.awspring.cloud:spring-cloud-aws-dependencies:$springCloudAwsVersion"
implementation "io.awspring.cloud:spring-cloud-aws-core:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-aws-autoconfigure:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-starter-aws:${springCloudAwsVersion}"
implementation "io.awspring.cloud:spring-cloud-aws-messaging:${springCloudAwsVersion}"
implementation 'org.springdoc:springdoc-openapi-ui:1.7.0'
testImplementation 'org.testcontainers:testcontainers:1.18.1'
testImplementation 'org.testcontainers:postgresql:1.18.1'
testImplementation 'org.testcontainers:junit-jupiter:1.18.1'
testImplementation 'org.testcontainers:localstack:1.18.1'
testImplementation 'org.projectlombok:lombok:1.18.28'
compileOnly 'org.projectlombok:lombok:1.18.26'
implementation(platform(annotationProcessor("org.projectlombok:lombok:1.18.26")))
annotationProcessor("org.projectlombok:lombok:1.18.26")
implementation "org.springframework.boot:spring-boot-starter-quartz:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-validation:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation 'org.springframework:spring-context:6.1.13'
implementation 'org.springdoc:springdoc-openapi-ui:1.8.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
testImplementation "org.testcontainers:localstack:${testContainerVersion}"
testImplementation "org.projectlombok:lombok:${lombokVersion}"
compileOnly "org.projectlombok:lombok:${lombokVersion}"
implementation(platform(annotationProcessor("org.projectlombok:lombok:${lombokVersion}")))
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
}

cyclonedxBom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import gov.cms.ab2d.eventclient.events.ApiResponseEvent;
import gov.cms.ab2d.eventclient.events.ErrorEvent;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.cms.ab2d.contracts.controller;

public class RemoteTimeoutException extends RuntimeException {
public RemoteTimeoutException(String msg) {
super(msg);
}
}
14 changes: 7 additions & 7 deletions src/main/java/gov/cms/ab2d/contracts/model/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;

@Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gov.cms.ab2d.contracts.service;

import gov.cms.ab2d.contracts.controller.RemoteTimeoutException;
import gov.cms.ab2d.eventclient.clients.EventClient;
import gov.cms.ab2d.eventclient.clients.SQSEventClient;
import gov.cms.ab2d.eventclient.events.ErrorEvent;
Expand All @@ -9,13 +10,12 @@
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseCookie;
import org.springframework.remoting.RemoteTimeoutException;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.reactive.function.client.WebClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gov.cms.ab2d.contracts.service;

import gov.cms.ab2d.contracts.SpringBootApp;
import gov.cms.ab2d.contracts.controller.RemoteTimeoutException;
import gov.cms.ab2d.contracts.util.AB2DPostgresqlContainer;
import gov.cms.ab2d.eventclient.clients.SQSEventClient;
import gov.cms.ab2d.contracts.hmsapi.HPMSAuthResponse;
Expand All @@ -13,7 +13,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.remoting.RemoteTimeoutException;

import org.springframework.test.context.TestPropertySource;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientResponseException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Slf4j
public class AB2DLocalstackContainer extends LocalStackContainer {

private static final DockerImageName IMAGE_VERSION = DockerImageName.parse("localstack/localstack:1.0.2");
private static final DockerImageName IMAGE_VERSION = DockerImageName.parse("localstack/localstack:3.5.0");

public AB2DLocalstackContainer() {
super(IMAGE_VERSION);
Expand All @@ -22,6 +22,6 @@ public void start() {
super.withServices(Service.SQS);
super.start();
System.setProperty("AWS_SQS_URL",
"localhost:" + this.getMappedPort(EnabledService.named("SQS").getPort()));
"http://localhost:" + this.getMappedPort(EnabledService.named("SQS").getPort()));
}
}
24 changes: 4 additions & 20 deletions src/test/java/gov/cms/ab2d/contracts/util/AB2DSQSMockConfig.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package gov.cms.ab2d.contracts.util;

import com.amazonaws.services.sqs.AmazonSQSAsync;
import gov.cms.ab2d.eventclient.clients.SQSEventClient;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import io.awspring.cloud.messaging.config.SimpleMessageListenerContainerFactory;
import io.awspring.cloud.messaging.listener.QueueMessageHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import software.amazon.awssdk.services.sqs.SqsAsyncClient;


import static org.mockito.Mockito.mock;
Expand All @@ -22,26 +19,13 @@ public class AB2DSQSMockConfig {
}

@MockBean
AmazonSQSAsync amazonSQSAsync;
SqsAsyncClient amazonSQSAsync;

@MockBean
SQSEventClient sQSEventClient;

@Bean
@Primary
public SimpleMessageListenerContainerFactory simpleMessageListenerContainerFactory() {
SimpleMessageListenerContainerFactory factory = new SimpleMessageListenerContainerFactory();
factory.setAutoStartup(false);
return factory;
}

@Bean
public QueueMessageHandler messageHandler() {
return mock(QueueMessageHandler.class);
}

@Bean("mockAmazonSQS")
public AmazonSQSAsync amazonSQSAsync() {
return mock(AmazonSQSAsync.class);
public SqsAsyncClient amazonSQSAsync() {
return mock(SqsAsyncClient.class);
}
}
3 changes: 2 additions & 1 deletion src/test/resources/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ ALTER TABLE ONLY contract.contract
ALTER TABLE ONLY contract.contract
ADD CONSTRAINT contract_pkey PRIMARY KEY (id);

CREATE SEQUENCE hibernate_sequence START 1;
CREATE SEQUENCE hibernate_sequence START 1;
CREATE SEQUENCE IF NOT EXISTS contract_seq START 1;