From 2ee8e26e0af96ad37d38f03f5e81f7b0afc43543 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Mon, 25 Nov 2024 11:32:21 -0800 Subject: [PATCH] added @Profile for ContractService --- .../java/gov/cms/ab2d/common/feign/ContractFeignClient.java | 2 ++ .../gov/cms/ab2d/common/service/ContractServiceImpl.java | 3 +++ .../ab2d/common/service/ContractServiceFeignImplTest.java | 2 +- .../gov/cms/ab2d/common/service/ContractServiceImplTest.java | 2 +- .../gov/cms/ab2d/common/service/ContractServiceStub.java | 5 +++++ e2e-bfd-test/src/test/java/gov/cms/ab2d/SpringBootApp.java | 2 +- .../test/java/gov/cms/ab2d/testjobs/EndToEndBfdTests.java | 5 ++--- e2e-bfd-test/src/test/resources/application.properties | 3 ++- 8 files changed, 17 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/gov/cms/ab2d/common/feign/ContractFeignClient.java b/common/src/main/java/gov/cms/ab2d/common/feign/ContractFeignClient.java index d64e0498c0..a284882364 100644 --- a/common/src/main/java/gov/cms/ab2d/common/feign/ContractFeignClient.java +++ b/common/src/main/java/gov/cms/ab2d/common/feign/ContractFeignClient.java @@ -2,7 +2,9 @@ import gov.cms.ab2d.contracts.model.ContractAPI; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.context.annotation.Profile; @FeignClient(name = "contract", url = "${contract.base.url}") +@Profile("prod") public interface ContractFeignClient extends ContractAPI { } diff --git a/common/src/main/java/gov/cms/ab2d/common/service/ContractServiceImpl.java b/common/src/main/java/gov/cms/ab2d/common/service/ContractServiceImpl.java index 076f227805..bed61c46e1 100644 --- a/common/src/main/java/gov/cms/ab2d/common/service/ContractServiceImpl.java +++ b/common/src/main/java/gov/cms/ab2d/common/service/ContractServiceImpl.java @@ -5,11 +5,14 @@ import gov.cms.ab2d.contracts.model.ContractDTO; import java.util.List; import java.util.Optional; + +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@Profile("prod") public class ContractServiceImpl implements ContractService { private final ContractFeignClient contractFeignClient; diff --git a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceFeignImplTest.java b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceFeignImplTest.java index 62f5343fd7..5b9f6bfe54 100644 --- a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceFeignImplTest.java +++ b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceFeignImplTest.java @@ -24,7 +24,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -@SpringBootTest +@SpringBootTest(properties = "spring.profiles.active=prod") @Testcontainers @TestPropertySource(locations = "/application.common.properties") class ContractServiceFeignImplTest { diff --git a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceImplTest.java b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceImplTest.java index 936af7fba3..8c6236cf16 100644 --- a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceImplTest.java +++ b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceImplTest.java @@ -27,7 +27,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -@SpringBootTest +@SpringBootTest(properties = "spring.profiles.active=prod") @Testcontainers @TestPropertySource(locations = "/application.common.properties") class ContractServiceImplTest { diff --git a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceStub.java b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceStub.java index b5583c92e8..62b8304959 100644 --- a/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceStub.java +++ b/common/src/test/java/gov/cms/ab2d/common/service/ContractServiceStub.java @@ -3,12 +3,17 @@ import gov.cms.ab2d.common.model.PdpClient; import gov.cms.ab2d.common.repository.PdpClientRepository; import gov.cms.ab2d.contracts.model.Contract; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Profile; + import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; +@TestConfiguration +@Profile("test") public class ContractServiceStub implements ContractService { PdpClientRepository pdpClientRepository; private ArrayList contractMap; diff --git a/e2e-bfd-test/src/test/java/gov/cms/ab2d/SpringBootApp.java b/e2e-bfd-test/src/test/java/gov/cms/ab2d/SpringBootApp.java index 73029b44ce..8a6c5a8860 100644 --- a/e2e-bfd-test/src/test/java/gov/cms/ab2d/SpringBootApp.java +++ b/e2e-bfd-test/src/test/java/gov/cms/ab2d/SpringBootApp.java @@ -14,11 +14,11 @@ "gov.cms.ab2d.eventclient.clients", "gov.cms.ab2d.snsclient.clients", "gov.cms.ab2d.common.config", - "gov.cms.ab2d.common.feign", "gov.cms.ab2d.common.model", "gov.cms.ab2d.common.properties", "gov.cms.ab2d.common.repository", "gov.cms.ab2d.common.service", + "gov.cms.ab2d.common.util", "gov.cms.ab2d.coverage.repository", "gov.cms.ab2d.coverage.service", "gov.cms.ab2d.job.service", diff --git a/e2e-bfd-test/src/test/java/gov/cms/ab2d/testjobs/EndToEndBfdTests.java b/e2e-bfd-test/src/test/java/gov/cms/ab2d/testjobs/EndToEndBfdTests.java index 3c97e15b1f..f9d380b03e 100644 --- a/e2e-bfd-test/src/test/java/gov/cms/ab2d/testjobs/EndToEndBfdTests.java +++ b/e2e-bfd-test/src/test/java/gov/cms/ab2d/testjobs/EndToEndBfdTests.java @@ -16,7 +16,6 @@ import gov.cms.ab2d.coverage.repository.CoverageSearchRepository; import gov.cms.ab2d.coverage.service.CoverageService; import gov.cms.ab2d.eventclient.clients.SQSEventClient; -import gov.cms.ab2d.eventclient.config.Ab2dEnvironment; import gov.cms.ab2d.fhir.BundleUtils; import gov.cms.ab2d.fhir.FhirVersion; import gov.cms.ab2d.fhir.IdentifierUtils; @@ -93,16 +92,16 @@ * In the db container, it generates coverage data for the contract, pre-processes, then processes each job * (except the last one). All the data pulls from BFDs sandbox Synthea data. */ -@SpringBootTest +@SpringBootTest(properties = "spring.profiles.active=test") @ComponentScan(basePackages = {"gov.cms.ab2d.bfd.client", "gov.cms.ab2d.eventclient.clients", "gov.cms.ab2d.snsclient.clients", "gov.cms.ab2d.common.config", - "gov.cms.ab2d.common.feign", "gov.cms.ab2d.common.model", "gov.cms.ab2d.common.properties", "gov.cms.ab2d.common.repository", "gov.cms.ab2d.common.service", + "gov.cms.ab2d.common.util", "gov.cms.ab2d.coverage.repository", "gov.cms.ab2d.coverage.service", "gov.cms.ab2d.job.service", diff --git a/e2e-bfd-test/src/test/resources/application.properties b/e2e-bfd-test/src/test/resources/application.properties index 1e52d23f52..cdc1cf4ceb 100644 --- a/e2e-bfd-test/src/test/resources/application.properties +++ b/e2e-bfd-test/src/test/resources/application.properties @@ -25,6 +25,7 @@ spring.liquibase.contexts=test spring.main.allow-bean-definition-overriding=true + # Set max number of patients to be put into patient search queue eob.job.patient.queue.max.size=10000 @@ -117,4 +118,4 @@ pcp.scaleToMax.time=10 contract.base.url=${PROPERTIES_SERVICE_URL:#{'localhost:8070'}} -spring.profiles.active: test \ No newline at end of file +spring.profiles.active=test \ No newline at end of file