From b3ffd70ce21e0449bc0be3ccbb1acb090bb543de Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 17 Jan 2024 12:17:43 -0500 Subject: [PATCH 01/15] add logs to contractserviceimpl --- .../common/service/ContractServiceImpl.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 076f22780..c25dfb476 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 @@ -7,7 +7,10 @@ import java.util.Optional; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import lombok.extern.slf4j.Slf4j; + +@Slf4j @Service @Transactional public class ContractServiceImpl implements ContractService { @@ -42,12 +45,29 @@ public Contract getContractByContractId(Long contractId) { //TODO replace Contract with ContractDTO private Contract dtoToContract(ContractDTO contractDTO) { + log.info("ContractServiceImpl-dtoToContract: Retrieving contract information..."); + log.info("ContractServiceImpl-dtoToContract: contractDTO = " + contractDTO.toString()); + + Contract contract = new Contract(contractDTO.getContractNumber(), contractDTO.getContractName(), null, null, null, contractDTO.getTotalEnrollment(), contractDTO.getMedicareEligible()); + + log.info("ContractServiceImpl-dtoToContract: Contract created from DTO."); + log.info("ContractServiceImpl-dtoToContract: Setting attestation date..."); + log.info("ContractServiceImpl-dtoToContract: attestedOn = "+ contractDTO.getAttestedOn().toString()); contract.setAttestedOn(contractDTO.getAttestedOn()); + + log.info("ContractServiceImpl-dtoToContract: Setting contract type..."); + log.info("ContractServiceImpl-dtoToContract: contractType = " + contractDTO.getContractType().toString()); contract.setContractType(contractDTO.getContractType()); + + log.info("ContractServiceImpl-dtoToContract: Setting ID..."); + log.info("ContractServiceImpl-dtoToContract: ID = " + Long.toString(contractDTO.getId())); contract.setId(contractDTO.getId()); + + log.info("ContractServiceImpl-dtoToContract: contract = " + contract.toString()); + log.info("ContractServiceImpl-dtoToContract: Returning contract..."); return contract; } } From 640a13a04f647e2dcceb7b97fa5a80904cc3ba13 Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 17 Jan 2024 14:57:14 -0500 Subject: [PATCH 02/15] fixed whitespace issues --- .../java/gov/cms/ab2d/common/service/ContractServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 c25dfb476..8b4e11615 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 @@ -47,15 +47,13 @@ public Contract getContractByContractId(Long contractId) { private Contract dtoToContract(ContractDTO contractDTO) { log.info("ContractServiceImpl-dtoToContract: Retrieving contract information..."); log.info("ContractServiceImpl-dtoToContract: contractDTO = " + contractDTO.toString()); - Contract contract = new Contract(contractDTO.getContractNumber(), contractDTO.getContractName(), null, null, null, contractDTO.getTotalEnrollment(), contractDTO.getMedicareEligible()); - log.info("ContractServiceImpl-dtoToContract: Contract created from DTO."); log.info("ContractServiceImpl-dtoToContract: Setting attestation date..."); - log.info("ContractServiceImpl-dtoToContract: attestedOn = "+ contractDTO.getAttestedOn().toString()); + log.info("ContractServiceImpl-dtoToContract: attestedOn = " + contractDTO.getAttestedOn().toString()); contract.setAttestedOn(contractDTO.getAttestedOn()); log.info("ContractServiceImpl-dtoToContract: Setting contract type..."); From 4d51e11681184a03fc24c71bac6e57f5338f4ceb Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 17 Jan 2024 16:58:00 -0500 Subject: [PATCH 03/15] remove log for attestationDate --- .../gov/cms/ab2d/common/service/ContractServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 8b4e11615..b84ee2606 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 @@ -51,18 +51,18 @@ private Contract dtoToContract(ContractDTO contractDTO) { Contract contract = new Contract(contractDTO.getContractNumber(), contractDTO.getContractName(), null, null, null, contractDTO.getTotalEnrollment(), contractDTO.getMedicareEligible()); + log.info("ContractServiceImpl-dtoToContract: Contract created from DTO."); log.info("ContractServiceImpl-dtoToContract: Setting attestation date..."); - log.info("ContractServiceImpl-dtoToContract: attestedOn = " + contractDTO.getAttestedOn().toString()); contract.setAttestedOn(contractDTO.getAttestedOn()); log.info("ContractServiceImpl-dtoToContract: Setting contract type..."); - log.info("ContractServiceImpl-dtoToContract: contractType = " + contractDTO.getContractType().toString()); contract.setContractType(contractDTO.getContractType()); + log.info("ContractServiceImpl-dtoToContract: contractType = " + contractDTO.getContractType().toString()); log.info("ContractServiceImpl-dtoToContract: Setting ID..."); - log.info("ContractServiceImpl-dtoToContract: ID = " + Long.toString(contractDTO.getId())); contract.setId(contractDTO.getId()); + log.info("ContractServiceImpl-dtoToContract: ID = " + Long.toString(contractDTO.getId())); log.info("ContractServiceImpl-dtoToContract: contract = " + contract.toString()); log.info("ContractServiceImpl-dtoToContract: Returning contract..."); From 70880c100e216f40fa0d7104199fb5ad2bc9656f Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 17 Jan 2024 18:10:08 -0500 Subject: [PATCH 04/15] add null check for attestedOn --- .../worker/processor/JobPreProcessorImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java index b0b26abf4..c51414e03 100644 --- a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java +++ b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java @@ -26,6 +26,7 @@ import static gov.cms.ab2d.eventclient.config.Ab2dEnvironment.PUBLIC_LIST; import static gov.cms.ab2d.eventclient.events.SlackEvents.EOB_JOB_COVERAGE_ISSUE; import static gov.cms.ab2d.eventclient.events.SlackEvents.EOB_JOB_STARTED; +import static gov.cms.ab2d.eventclient.events.SlackEvents.EOB_JOB_FAILURE; import static gov.cms.ab2d.job.model.JobStatus.FAILED; import static gov.cms.ab2d.job.model.JobStatus.IN_PROGRESS; import static gov.cms.ab2d.job.model.JobStatus.SUBMITTED; @@ -72,6 +73,20 @@ public Job preprocess(String jobUuid) { if (contract == null) { throw new IllegalArgumentException("A job must always have a contract."); } + + if (contract.getAttestedOn() == null) { + log.warn("JobPreProcessorImpl > preprocess: job FAILED because the contract attestation date is null."); + + eventLogger.logAndAlert(job.buildJobStatusChangeEvent(FAILED, EOB_JOB_FAILURE + " Job for " + + contract.getContractNumber() + " in progress"), PUBLIC_LIST); + + job.setStatus(FAILED); + job.setStatusMessage("failed because contract attestation date is null."); + + job = jobRepository.save(job); + return job; + } + Optional sinceValue = Optional.ofNullable(job.getSince()); if (sinceValue.isPresent()) { // If the user provided a 'since' value From 1924a05340df133c4c1a9d281e1e819c291a0e89 Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 17 Jan 2024 18:12:18 -0500 Subject: [PATCH 05/15] revert logs in ContractServiceImpl --- .../common/service/ContractServiceImpl.java | 18 ------------------ 1 file changed, 18 deletions(-) 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 b84ee2606..076f22780 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 @@ -7,10 +7,7 @@ import java.util.Optional; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import lombok.extern.slf4j.Slf4j; - -@Slf4j @Service @Transactional public class ContractServiceImpl implements ContractService { @@ -45,27 +42,12 @@ public Contract getContractByContractId(Long contractId) { //TODO replace Contract with ContractDTO private Contract dtoToContract(ContractDTO contractDTO) { - log.info("ContractServiceImpl-dtoToContract: Retrieving contract information..."); - log.info("ContractServiceImpl-dtoToContract: contractDTO = " + contractDTO.toString()); - Contract contract = new Contract(contractDTO.getContractNumber(), contractDTO.getContractName(), null, null, null, contractDTO.getTotalEnrollment(), contractDTO.getMedicareEligible()); - - log.info("ContractServiceImpl-dtoToContract: Contract created from DTO."); - log.info("ContractServiceImpl-dtoToContract: Setting attestation date..."); contract.setAttestedOn(contractDTO.getAttestedOn()); - - log.info("ContractServiceImpl-dtoToContract: Setting contract type..."); contract.setContractType(contractDTO.getContractType()); - log.info("ContractServiceImpl-dtoToContract: contractType = " + contractDTO.getContractType().toString()); - - log.info("ContractServiceImpl-dtoToContract: Setting ID..."); contract.setId(contractDTO.getId()); - log.info("ContractServiceImpl-dtoToContract: ID = " + Long.toString(contractDTO.getId())); - - log.info("ContractServiceImpl-dtoToContract: contract = " + contract.toString()); - log.info("ContractServiceImpl-dtoToContract: Returning contract..."); return contract; } } From 9c4005b1e406e505022dcca62d9158dd56f9dddf Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Thu, 18 Jan 2024 09:34:24 -0500 Subject: [PATCH 06/15] indent line for eventlogger to match others --- .../java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java index c51414e03..1cef5fbbf 100644 --- a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java +++ b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java @@ -78,7 +78,7 @@ public Job preprocess(String jobUuid) { log.warn("JobPreProcessorImpl > preprocess: job FAILED because the contract attestation date is null."); eventLogger.logAndAlert(job.buildJobStatusChangeEvent(FAILED, EOB_JOB_FAILURE + " Job for " - + contract.getContractNumber() + " in progress"), PUBLIC_LIST); + + contract.getContractNumber() + " in progress"), PUBLIC_LIST); job.setStatus(FAILED); job.setStatusMessage("failed because contract attestation date is null."); From e6566c34a3b5cc6e2d777b5b5282900358e3397a Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Thu, 18 Jan 2024 10:40:26 -0500 Subject: [PATCH 07/15] update event_logger status message for null attestation --- .../gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java index 1cef5fbbf..f414df2c1 100644 --- a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java +++ b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java @@ -77,8 +77,8 @@ public Job preprocess(String jobUuid) { if (contract.getAttestedOn() == null) { log.warn("JobPreProcessorImpl > preprocess: job FAILED because the contract attestation date is null."); - eventLogger.logAndAlert(job.buildJobStatusChangeEvent(FAILED, EOB_JOB_FAILURE + " Job for " - + contract.getContractNumber() + " in progress"), PUBLIC_LIST); + eventLogger.logAndAlert(job.buildJobStatusChangeEvent(FAILED, EOB_JOB_FAILURE + " Job " + jobUuid + + "failed for contract: " + contract.getContractNumber() + " because contract attestation date is null"), PUBLIC_LIST); job.setStatus(FAILED); job.setStatusMessage("failed because contract attestation date is null."); From 356ef455616214040099caa929ecce7fcd75a73f Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 14:20:13 -0500 Subject: [PATCH 08/15] update unit test to handle new logic --- .../worker/processor/JobPreProcessorImpl.java | 2 +- .../processor/JobPreProcessorUnitTest.java | 44 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java index f414df2c1..a19f6674b 100644 --- a/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java +++ b/worker/src/main/java/gov/cms/ab2d/worker/processor/JobPreProcessorImpl.java @@ -83,7 +83,7 @@ public Job preprocess(String jobUuid) { job.setStatus(FAILED); job.setStatusMessage("failed because contract attestation date is null."); - job = jobRepository.save(job); + jobRepository.save(job); return job; } diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java index 1bf5b3942..bd2b6b8af 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java @@ -10,7 +10,7 @@ import gov.cms.ab2d.job.model.JobStatus; import gov.cms.ab2d.job.repository.JobRepository; import gov.cms.ab2d.worker.processor.coverage.CoverageDriver; -import gov.cms.ab2d.worker.util.ContractWorkerClientMock; +import gov.cms.ab2d.worker.service.ContractWorkerClient; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; @@ -39,6 +39,8 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.never; @@ -53,8 +55,10 @@ class JobPreProcessorUnitTest { private static final String JOB_UUID = "6d08bf08-f926-4e19-8d89-ad67ef89f17e"; - private final ContractWorkerClientMock contractWorkerClient = new ContractWorkerClientMock(); + // private final ContractWorkerClientMock contractWorkerClient = new ContractWorkerClientMock(); + @Mock + private ContractWorkerClient contractWorkerClient; @Mock private JobRepository jobRepository; @Mock @@ -67,7 +71,7 @@ class JobPreProcessorUnitTest { @BeforeEach void setUp() { - contract = new ContractDTO(null, "JPP5678", "JPP5678", null, null, 0, 0); + contract = new ContractDTO(null, "JPP5678", "JPP5678", OffsetDateTime.now(), Contract.ContractType.NORMAL, 0, 0); cut = new JobPreProcessorImpl(contractWorkerClient, jobRepository, eventLogger, coverageDriver); job = createJob(); } @@ -123,6 +127,7 @@ void whenJobIsInSubmittedStatus_ThenJobShouldBePutInProgress() throws Interrupte when(jobRepository.save(Mockito.any())).thenReturn(job); when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); when(coverageDriver.isCoverageAvailable(any(Job.class), any(ContractDTO.class))).thenReturn(true); var processedJob = cut.preprocess(job.getJobUuid()); @@ -131,12 +136,30 @@ void whenJobIsInSubmittedStatus_ThenJobShouldBePutInProgress() throws Interrupte verify(jobRepository).save(Mockito.any()); } + @DisplayName("Job is FAILED if contract is not attested") + @Test + void jobFailedIfContractNotAttested() { + + contract.setAttestedOn(null); + + job.setContractNumber(contract.getContractNumber()); + job.setStatus(JobStatus.SUBMITTED); + + when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); + + job = cut.preprocess(job.getJobUuid()); + + assertEquals(JobStatus.FAILED, job.getStatus()); + } + @DisplayName("Job is not started if coverage is not available") @Test void proccessingNotTriggeredIfCoverageNotAvailable() throws InterruptedException { job.setStatus(JobStatus.SUBMITTED); when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); when(coverageDriver.isCoverageAvailable(any(Job.class), any(ContractDTO.class))).thenReturn(false); Job result = cut.preprocess(job.getJobUuid()); @@ -149,6 +172,7 @@ void proccessingNotTriggeredIfCoverageCheckInterrupted() throws InterruptedExcep job.setStatus(JobStatus.SUBMITTED); when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); when(coverageDriver.isCoverageAvailable(any(Job.class), any(ContractDTO.class))).thenThrow(InterruptedException.class); var exceptionThrown = assertThrows(RuntimeException.class, @@ -165,6 +189,7 @@ void testDefaultSinceSTU3() { job.setStatus(JobStatus.SUBMITTED); job.setContractNumber(contract.getContractNumber()); when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); cut.preprocess(job.getJobUuid()); assertNull(job.getSince()); verify(jobRepository, never()).findByContractNumberEqualsAndStatusInAndStartedByOrderByCompletedAtDesc(anyString(), any(), any()); @@ -178,8 +203,10 @@ void testDefaultSinceR4FirstRun() { job.setFhirVersion(R4); job.setStatus(JobStatus.SUBMITTED); when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); when(jobRepository.findByContractNumberEqualsAndStatusInAndStartedByOrderByCompletedAtDesc(anyString(), any(), any())).thenReturn(Collections.emptyList()); cut.preprocess(job.getJobUuid()); + assertNull(job.getSince()); assertEquals(SinceSource.FIRST_RUN, job.getSinceSource()); } @@ -200,6 +227,7 @@ void testDefaultSinceR4FirstRunByPdp() { oldJob.setCreatedAt(oldJobTime); when(jobRepository.findByJobUuid(newJob.getJobUuid())).thenReturn(newJob); + when(contractWorkerClient.getContractByContractNumber(newJob.getContractNumber())).thenReturn(contract); when(jobRepository.findByContractNumberEqualsAndStatusInAndStartedByOrderByCompletedAtDesc(anyString(), any(), any())).thenReturn(List.of(oldJob)); cut.preprocess(newJob.getJobUuid()); @@ -225,6 +253,7 @@ void testDefaultSinceR4SuppliedSince() { oldJob.setJobUuid(oldJob.getJobUuid() + "-2"); when(jobRepository.findByJobUuid(newJob.getJobUuid())).thenReturn(newJob); + when(contractWorkerClient.getContractByContractNumber(newJob.getContractNumber())).thenReturn(contract); cut.preprocess(newJob.getJobUuid()); @@ -240,9 +269,6 @@ void testDifferentSinceConditions() { newJob.setStatus(JobStatus.SUBMITTED); newJob.setCreatedAt(OffsetDateTime.now()); - ContractDTO contract = new ContractDTO(null, "contractNum", null, null, Contract.ContractType.CLASSIC_TEST, 0, 0); - newJob.setContractNumber(contract.getContractNumber()); - Job oldJob = createJob(); oldJob.setStatus(SUCCESSFUL); oldJob.setJobUuid(oldJob.getJobUuid() + "-2"); @@ -250,14 +276,15 @@ void testDifferentSinceConditions() { oldJob.setCreatedAt(oldJobTime); when(jobRepository.findByJobUuid(newJob.getJobUuid())).thenReturn(newJob); + when(contractWorkerClient.getContractByContractNumber(newJob.getContractNumber())).thenReturn(contract); - cut.preprocess(newJob.getJobUuid()); + newJob = cut.preprocess(newJob.getJobUuid()); assertNull(newJob.getSince()); // No longer allow null contracts so things get flagged as first run now. assertEquals(SinceSource.FIRST_RUN, newJob.getSinceSource()); - contract = new ContractDTO(null, "contractNum", null, null, Contract.ContractType.SYNTHEA, 0, 0); + contract = new ContractDTO(null, "contractNum", null, OffsetDateTime.now(), Contract.ContractType.SYNTHEA, 0, 0); when(jobRepository.findByContractNumberEqualsAndStatusInAndStartedByOrderByCompletedAtDesc(anyString(), any(), any())).thenReturn(List.of(oldJob)); @@ -303,6 +330,7 @@ void testGetLatestFullySuccessfulJob() { assertTrue(impl.getLastSuccessfulJobWithDownloads(List.of(job3)).isEmpty()); when(jobRepository.findByJobUuid(newJob.getJobUuid())).thenReturn(newJob); + when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); when(jobRepository.findByContractNumberEqualsAndStatusInAndStartedByOrderByCompletedAtDesc(anyString(), any(), any())).thenReturn(List.of(job1, job2, job3, job4)); cut.preprocess(newJob.getJobUuid()); assertEquals(newJob.getSince().getNano(), job4.getCreatedAt().getNano()); From fc51ba9bae4a906c95b1520e359e01490705bbdb Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 14:37:31 -0500 Subject: [PATCH 09/15] some cleanup --- .../ab2d/worker/processor/JobPreProcessorUnitTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java index bd2b6b8af..cae7f97d2 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/JobPreProcessorUnitTest.java @@ -39,8 +39,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.never; @@ -55,8 +53,6 @@ class JobPreProcessorUnitTest { private static final String JOB_UUID = "6d08bf08-f926-4e19-8d89-ad67ef89f17e"; - // private final ContractWorkerClientMock contractWorkerClient = new ContractWorkerClientMock(); - @Mock private ContractWorkerClient contractWorkerClient; @Mock @@ -139,12 +135,12 @@ void whenJobIsInSubmittedStatus_ThenJobShouldBePutInProgress() throws Interrupte @DisplayName("Job is FAILED if contract is not attested") @Test void jobFailedIfContractNotAttested() { - + contract.setAttestedOn(null); job.setContractNumber(contract.getContractNumber()); job.setStatus(JobStatus.SUBMITTED); - + when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job); when(contractWorkerClient.getContractByContractNumber(job.getContractNumber())).thenReturn(contract); From 74167218bb07b7904c58bef56e9c63fdf9ac56ec Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 16:55:14 -0500 Subject: [PATCH 10/15] temporary sonarqube workaround --- Jenkinsfile | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fe9f382c0..60b868df7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -116,32 +116,32 @@ pipeline { } } } - stage('SonarQube Analysis') { - steps { - withCredentials([usernamePassword(credentialsId: 'artifactoryuserpass', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { - git branch: 'master', credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL - git branch: env.BRANCH_NAME, credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL - // Automatically saves the an id for the SonarQube build - withSonarQubeEnv('CMSSonar') { - sh ''' - mvn -s settings.xml sonar:sonar -Dsonar.projectKey=ab2d-project -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} - ''' - } - } - } - } - - // New Way in declarative pipeline - stage("Quality Gate") { - options { - timeout(time: 10, unit: 'MINUTES') - } - steps { - // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails - // true = set pipeline to UNSTABLE, false = don't - waitForQualityGate abortPipeline: true - } - } + // stage('SonarQube Analysis') { + // steps { + // withCredentials([usernamePassword(credentialsId: 'artifactoryuserpass', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + // git branch: 'master', credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL + // git branch: env.BRANCH_NAME, credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL + // // Automatically saves the an id for the SonarQube build + // withSonarQubeEnv('CMSSonar') { + // sh ''' + // mvn -s settings.xml sonar:sonar -Dsonar.projectKey=ab2d-project -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} + // ''' + // } + // } + // } + // } + + // // New Way in declarative pipeline + // stage("Quality Gate") { + // options { + // timeout(time: 10, unit: 'MINUTES') + // } + // steps { + // // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails + // // true = set pipeline to UNSTABLE, false = don't + // waitForQualityGate abortPipeline: true + // } + // } stage('Run e2e-test') { From 74c19135be2a7d951b1d3249d751507a74cdba9c Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 17:06:48 -0500 Subject: [PATCH 11/15] temporary - comment out failing integreation tests --- .../CoverageCheckIntegrationTest.java | 56 ++++----- .../coverage/CoverageDriverTest.java | 56 ++++----- ...overageCheckPredicatesIntegrationTest.java | 112 +++++++++--------- 3 files changed, 112 insertions(+), 112 deletions(-) diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java index 69ce449b9..7cf4f235d 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java @@ -235,34 +235,34 @@ void verifyCoverage_whenSomeCoverageMissing_fail() { assertFalse(exception.getAlertMessage().contains("old coverage search")); } - @DisplayName("Verify coverage stops if some coverage periods change drastically") - @Test - void verifyCoverage_whenCoverageUnstable_fail() { - createCoveragePeriods(); - - Set tenK = new LinkedHashSet<>(); - for (long idx = 0; idx < 10000; idx++) { - tenK.add(createIdentifier(idx)); - } - - Set twelveK = new LinkedHashSet<>(); - for (long idx = 0; idx < 12000; idx++) { - twelveK.add(createIdentifier(idx)); - } - - insertAndRunSearch(attestationMonth, tenK); - insertAndRunSearch(attestationMonthPlus1, twelveK); - insertAndRunSearch(attestationMonthPlus2, tenK); - - CoverageVerificationException exception = - assertThrows(CoverageVerificationException.class, () ->coverageDriver.verifyCoverage()); - assertFalse(exception.getAlertMessage().contains("coverage period missing")); - assertFalse(exception.getAlertMessage().contains("has no enrollment")); - assertFalse(exception.getAlertMessage().contains("no enrollment found")); - assertTrue(exception.getAlertMessage().contains("enrollment changed")); - assertFalse(exception.getAlertMessage().contains("sets of enrollment")); - assertFalse(exception.getAlertMessage().contains("old coverage search")); - } + // @DisplayName("Verify coverage stops if some coverage periods change drastically") + // @Test + // void verifyCoverage_whenCoverageUnstable_fail() { + // createCoveragePeriods(); + + // Set tenK = new LinkedHashSet<>(); + // for (long idx = 0; idx < 10000; idx++) { + // tenK.add(createIdentifier(idx)); + // } + + // Set twelveK = new LinkedHashSet<>(); + // for (long idx = 0; idx < 12000; idx++) { + // twelveK.add(createIdentifier(idx)); + // } + + // insertAndRunSearch(attestationMonth, tenK); + // insertAndRunSearch(attestationMonthPlus1, twelveK); + // insertAndRunSearch(attestationMonthPlus2, tenK); + + // CoverageVerificationException exception = + // assertThrows(CoverageVerificationException.class, () ->coverageDriver.verifyCoverage()); + // assertFalse(exception.getAlertMessage().contains("coverage period missing")); + // assertFalse(exception.getAlertMessage().contains("has no enrollment")); + // assertFalse(exception.getAlertMessage().contains("no enrollment found")); + // assertTrue(exception.getAlertMessage().contains("enrollment changed")); + // assertFalse(exception.getAlertMessage().contains("sets of enrollment")); + // assertFalse(exception.getAlertMessage().contains("old coverage search")); + // } @DisplayName("Verify coverage stops if some coverage periods have multiple copies of coverage") @Test diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java index f6fa7b390..4d628de35 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java @@ -743,34 +743,34 @@ void availableCoverageWhenSinceContainsOnlySuccessful() { } - @DisplayName("Number of beneficiaries to process calculation works") - @Test - void numberOfBeneficiariesToProcess() { - - // Override BeforeEach method settings to make this test work for a smaller period of time - contract.setAttestedOn(OffsetDateTime.now().minus(1, ChronoUnit.SECONDS)); - contractServiceStub.updateContract(contract); - - CoveragePeriod period = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), contract.getESTAttestationTime().getMonthValue(), contract.getESTAttestationTime().getYear()); - - int total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); - assertEquals(0, total); - - CoverageSearchEvent event = new CoverageSearchEvent(); - event.setOldStatus(CoverageJobStatus.SUBMITTED); - event.setNewStatus(CoverageJobStatus.IN_PROGRESS); - event.setDescription("test"); - event.setCoveragePeriod(period); - event = coverageSearchEventRepo.saveAndFlush(event); - dataSetup.queueForCleanup(event); - - Set members = new HashSet<>(); - members.add(new Identifiers(1, "1234", new LinkedHashSet<>())); - coverageService.insertCoverage(event.getId(), members); - - total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); - assertEquals(1, total); - } + // @DisplayName("Number of beneficiaries to process calculation works") + // @Test + // void numberOfBeneficiariesToProcess() { + + // // Override BeforeEach method settings to make this test work for a smaller period of time + // contract.setAttestedOn(OffsetDateTime.now().minus(1, ChronoUnit.SECONDS)); + // contractServiceStub.updateContract(contract); + + // CoveragePeriod period = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), contract.getESTAttestationTime().getMonthValue(), contract.getESTAttestationTime().getYear()); + + // int total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); + // assertEquals(0, total); + + // CoverageSearchEvent event = new CoverageSearchEvent(); + // event.setOldStatus(CoverageJobStatus.SUBMITTED); + // event.setNewStatus(CoverageJobStatus.IN_PROGRESS); + // event.setDescription("test"); + // event.setCoveragePeriod(period); + // event = coverageSearchEventRepo.saveAndFlush(event); + // dataSetup.queueForCleanup(event); + + // Set members = new HashSet<>(); + // members.add(new Identifiers(1, "1234", new LinkedHashSet<>())); + // coverageService.insertCoverage(event.getId(), members); + + // total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); + // assertEquals(1, total); + // } private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) { CoverageSearchEvent event = new CoverageSearchEvent(); diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java index 2c7631664..be984ba94 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java @@ -201,50 +201,50 @@ void whenCoveragePeriodsPresent_passCoveragePresentCheck() { assertTrue(issues.isEmpty()); } - @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") - @Test - void whenCoverageUnstable_failCoverageStabilityCheck() { + // @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") + // @Test + // void whenCoverageUnstable_failCoverageStabilityCheck() { - // This test was using the actual month. Some month have their own logic which failed the test. - // Special cases should have their own test(s). This test should pass regardless of the current date. - //Hardcoding to May since we currently don't have any special logic for that month. - ZonedDateTime dateTime = ZonedDateTime.now().withMonth(5); + // // This test was using the actual month. Some month have their own logic which failed the test. + // // Special cases should have their own test(s). This test should pass regardless of the current date. + // //Hardcoding to May since we currently don't have any special logic for that month. + // ZonedDateTime dateTime = ZonedDateTime.now().withMonth(5); - createCoveragePeriods(dateTime); + // createCoveragePeriods(dateTime); - Set tenK = new LinkedHashSet<>(); - for (long idx = 0; idx < 10000; idx++) { - tenK.add(createIdentifier(idx)); - } + // Set tenK = new LinkedHashSet<>(); + // for (long idx = 0; idx < 10000; idx++) { + // tenK.add(createIdentifier(idx)); + // } - Set twelveK = new LinkedHashSet<>(); - for (long idx = 0; idx < 12000; idx++) { - twelveK.add(createIdentifier(idx)); - } + // Set twelveK = new LinkedHashSet<>(); + // for (long idx = 0; idx < 12000; idx++) { + // twelveK.add(createIdentifier(idx)); + // } - insertAndRunSearch(attestationMonth, tenK); - insertAndRunSearch(attestationMonthPlus1, twelveK); - insertAndRunSearch(attestationMonthPlus2, tenK); + // insertAndRunSearch(attestationMonth, tenK); + // insertAndRunSearch(attestationMonthPlus1, twelveK); + // insertAndRunSearch(attestationMonthPlus2, tenK); - Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) - .stream().collect(groupingBy(CoverageCount::getContractNumber)); + // Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) + // .stream().collect(groupingBy(CoverageCount::getContractNumber)); - coverageCounts.get(contract.getContractNumber()) - .forEach(count -> assertTrue(count.getBeneficiaryCount() >= 10000)); + // coverageCounts.get(contract.getContractNumber()) + // .forEach(count -> assertTrue(count.getBeneficiaryCount() >= 10000)); - List issues = new ArrayList<>(); - CoverageStableCheck stableCheck = - new CoverageStableCheck(coverageService, coverageCounts, issues); + // List issues = new ArrayList<>(); + // CoverageStableCheck stableCheck = + // new CoverageStableCheck(coverageService, coverageCounts, issues); - assertFalse(stableCheck.test(contract)); + // assertFalse(stableCheck.test(contract)); - int expectedIssues = 2; + // int expectedIssues = 2; - assertEquals(expectedIssues, issues.size()); - issues.forEach(issue -> assertTrue(issue.contains("enrollment changed"))); + // assertEquals(expectedIssues, issues.size()); + // issues.forEach(issue -> assertTrue(issue.contains("enrollment changed"))); - assertTrue(issues.get(0).contains("20%")); - } + // assertTrue(issues.get(0).contains("20%")); + // } @DisplayName("Coverage changes are limited to 10% between months passes when changes are 1000 benes or less") @Test @@ -381,40 +381,40 @@ void whenCoverageNotDuplicated_passCoverageDuplicatedCheck() { assertTrue(issues.isEmpty()); } - @DisplayName("Out of date enrollment causes a failure") - @Test - void whenCoverageOutOfDate_failCoverageDateCheck() { + // @DisplayName("Out of date enrollment causes a failure") + // @Test + // void whenCoverageOutOfDate_failCoverageDateCheck() { - createCoveragePeriods(); + // createCoveragePeriods(); - Set tenK = new LinkedHashSet<>(); - for (long idx = 0; idx < 10000; idx++) { - tenK.add(createIdentifier(idx)); - } + // Set tenK = new LinkedHashSet<>(); + // for (long idx = 0; idx < 10000; idx++) { + // tenK.add(createIdentifier(idx)); + // } - insertAndRunSearch(attestationMonth, tenK); - runSearchAndLeaveOld(attestationMonth); + // insertAndRunSearch(attestationMonth, tenK); + // runSearchAndLeaveOld(attestationMonth); - insertAndRunSearch(attestationMonthPlus1, tenK); - runSearchAndLeaveOld(attestationMonthPlus1); + // insertAndRunSearch(attestationMonthPlus1, tenK); + // runSearchAndLeaveOld(attestationMonthPlus1); - insertAndRunSearch(attestationMonthPlus2, tenK); - runSearchAndLeaveOld(attestationMonthPlus2); + // insertAndRunSearch(attestationMonthPlus2, tenK); + // runSearchAndLeaveOld(attestationMonthPlus2); - insertAndRunSearch(attestationMonthPlus3, tenK); - runSearchAndLeaveOld(attestationMonthPlus3); + // insertAndRunSearch(attestationMonthPlus3, tenK); + // runSearchAndLeaveOld(attestationMonthPlus3); - Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) - .stream().collect(groupingBy(CoverageCount::getContractNumber)); + // Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) + // .stream().collect(groupingBy(CoverageCount::getContractNumber)); - List issues = new ArrayList<>(); - CoverageUpToDateCheck upToDateCheck = new CoverageUpToDateCheck(coverageService, coverageCounts, issues); + // List issues = new ArrayList<>(); + // CoverageUpToDateCheck upToDateCheck = new CoverageUpToDateCheck(coverageService, coverageCounts, issues); - assertFalse(upToDateCheck.test(contract)); + // assertFalse(upToDateCheck.test(contract)); - assertEquals(4, issues.size()); - issues.forEach(issue -> assertTrue(issue.contains("old coverage search"))); - } + // assertEquals(4, issues.size()); + // issues.forEach(issue -> assertTrue(issue.contains("old coverage search"))); + // } @DisplayName("Up to date enrollment passes") @Test From d234e6ebfb850b068187b6f49eafebfa80b9bf79 Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 17:48:32 -0500 Subject: [PATCH 12/15] Revert "temporary - comment out failing integreation tests" This reverts commit 74c19135be2a7d951b1d3249d751507a74cdba9c. --- .../CoverageCheckIntegrationTest.java | 56 ++++----- .../coverage/CoverageDriverTest.java | 56 ++++----- ...overageCheckPredicatesIntegrationTest.java | 112 +++++++++--------- 3 files changed, 112 insertions(+), 112 deletions(-) diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java index 7cf4f235d..69ce449b9 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java @@ -235,34 +235,34 @@ void verifyCoverage_whenSomeCoverageMissing_fail() { assertFalse(exception.getAlertMessage().contains("old coverage search")); } - // @DisplayName("Verify coverage stops if some coverage periods change drastically") - // @Test - // void verifyCoverage_whenCoverageUnstable_fail() { - // createCoveragePeriods(); - - // Set tenK = new LinkedHashSet<>(); - // for (long idx = 0; idx < 10000; idx++) { - // tenK.add(createIdentifier(idx)); - // } - - // Set twelveK = new LinkedHashSet<>(); - // for (long idx = 0; idx < 12000; idx++) { - // twelveK.add(createIdentifier(idx)); - // } - - // insertAndRunSearch(attestationMonth, tenK); - // insertAndRunSearch(attestationMonthPlus1, twelveK); - // insertAndRunSearch(attestationMonthPlus2, tenK); - - // CoverageVerificationException exception = - // assertThrows(CoverageVerificationException.class, () ->coverageDriver.verifyCoverage()); - // assertFalse(exception.getAlertMessage().contains("coverage period missing")); - // assertFalse(exception.getAlertMessage().contains("has no enrollment")); - // assertFalse(exception.getAlertMessage().contains("no enrollment found")); - // assertTrue(exception.getAlertMessage().contains("enrollment changed")); - // assertFalse(exception.getAlertMessage().contains("sets of enrollment")); - // assertFalse(exception.getAlertMessage().contains("old coverage search")); - // } + @DisplayName("Verify coverage stops if some coverage periods change drastically") + @Test + void verifyCoverage_whenCoverageUnstable_fail() { + createCoveragePeriods(); + + Set tenK = new LinkedHashSet<>(); + for (long idx = 0; idx < 10000; idx++) { + tenK.add(createIdentifier(idx)); + } + + Set twelveK = new LinkedHashSet<>(); + for (long idx = 0; idx < 12000; idx++) { + twelveK.add(createIdentifier(idx)); + } + + insertAndRunSearch(attestationMonth, tenK); + insertAndRunSearch(attestationMonthPlus1, twelveK); + insertAndRunSearch(attestationMonthPlus2, tenK); + + CoverageVerificationException exception = + assertThrows(CoverageVerificationException.class, () ->coverageDriver.verifyCoverage()); + assertFalse(exception.getAlertMessage().contains("coverage period missing")); + assertFalse(exception.getAlertMessage().contains("has no enrollment")); + assertFalse(exception.getAlertMessage().contains("no enrollment found")); + assertTrue(exception.getAlertMessage().contains("enrollment changed")); + assertFalse(exception.getAlertMessage().contains("sets of enrollment")); + assertFalse(exception.getAlertMessage().contains("old coverage search")); + } @DisplayName("Verify coverage stops if some coverage periods have multiple copies of coverage") @Test diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java index 4d628de35..f6fa7b390 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java @@ -743,34 +743,34 @@ void availableCoverageWhenSinceContainsOnlySuccessful() { } - // @DisplayName("Number of beneficiaries to process calculation works") - // @Test - // void numberOfBeneficiariesToProcess() { - - // // Override BeforeEach method settings to make this test work for a smaller period of time - // contract.setAttestedOn(OffsetDateTime.now().minus(1, ChronoUnit.SECONDS)); - // contractServiceStub.updateContract(contract); - - // CoveragePeriod period = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), contract.getESTAttestationTime().getMonthValue(), contract.getESTAttestationTime().getYear()); - - // int total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); - // assertEquals(0, total); - - // CoverageSearchEvent event = new CoverageSearchEvent(); - // event.setOldStatus(CoverageJobStatus.SUBMITTED); - // event.setNewStatus(CoverageJobStatus.IN_PROGRESS); - // event.setDescription("test"); - // event.setCoveragePeriod(period); - // event = coverageSearchEventRepo.saveAndFlush(event); - // dataSetup.queueForCleanup(event); - - // Set members = new HashSet<>(); - // members.add(new Identifiers(1, "1234", new LinkedHashSet<>())); - // coverageService.insertCoverage(event.getId(), members); - - // total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); - // assertEquals(1, total); - // } + @DisplayName("Number of beneficiaries to process calculation works") + @Test + void numberOfBeneficiariesToProcess() { + + // Override BeforeEach method settings to make this test work for a smaller period of time + contract.setAttestedOn(OffsetDateTime.now().minus(1, ChronoUnit.SECONDS)); + contractServiceStub.updateContract(contract); + + CoveragePeriod period = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), contract.getESTAttestationTime().getMonthValue(), contract.getESTAttestationTime().getYear()); + + int total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); + assertEquals(0, total); + + CoverageSearchEvent event = new CoverageSearchEvent(); + event.setOldStatus(CoverageJobStatus.SUBMITTED); + event.setNewStatus(CoverageJobStatus.IN_PROGRESS); + event.setDescription("test"); + event.setCoveragePeriod(period); + event = coverageSearchEventRepo.saveAndFlush(event); + dataSetup.queueForCleanup(event); + + Set members = new HashSet<>(); + members.add(new Identifiers(1, "1234", new LinkedHashSet<>())); + coverageService.insertCoverage(event.getId(), members); + + total = driver.numberOfBeneficiariesToProcess(job, contract.toDTO()); + assertEquals(1, total); + } private CoverageSearchEvent createEvent(CoveragePeriod period, CoverageJobStatus status, OffsetDateTime created) { CoverageSearchEvent event = new CoverageSearchEvent(); diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java index be984ba94..2c7631664 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java @@ -201,50 +201,50 @@ void whenCoveragePeriodsPresent_passCoveragePresentCheck() { assertTrue(issues.isEmpty()); } - // @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") - // @Test - // void whenCoverageUnstable_failCoverageStabilityCheck() { + @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") + @Test + void whenCoverageUnstable_failCoverageStabilityCheck() { - // // This test was using the actual month. Some month have their own logic which failed the test. - // // Special cases should have their own test(s). This test should pass regardless of the current date. - // //Hardcoding to May since we currently don't have any special logic for that month. - // ZonedDateTime dateTime = ZonedDateTime.now().withMonth(5); + // This test was using the actual month. Some month have their own logic which failed the test. + // Special cases should have their own test(s). This test should pass regardless of the current date. + //Hardcoding to May since we currently don't have any special logic for that month. + ZonedDateTime dateTime = ZonedDateTime.now().withMonth(5); - // createCoveragePeriods(dateTime); + createCoveragePeriods(dateTime); - // Set tenK = new LinkedHashSet<>(); - // for (long idx = 0; idx < 10000; idx++) { - // tenK.add(createIdentifier(idx)); - // } + Set tenK = new LinkedHashSet<>(); + for (long idx = 0; idx < 10000; idx++) { + tenK.add(createIdentifier(idx)); + } - // Set twelveK = new LinkedHashSet<>(); - // for (long idx = 0; idx < 12000; idx++) { - // twelveK.add(createIdentifier(idx)); - // } + Set twelveK = new LinkedHashSet<>(); + for (long idx = 0; idx < 12000; idx++) { + twelveK.add(createIdentifier(idx)); + } - // insertAndRunSearch(attestationMonth, tenK); - // insertAndRunSearch(attestationMonthPlus1, twelveK); - // insertAndRunSearch(attestationMonthPlus2, tenK); + insertAndRunSearch(attestationMonth, tenK); + insertAndRunSearch(attestationMonthPlus1, twelveK); + insertAndRunSearch(attestationMonthPlus2, tenK); - // Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) - // .stream().collect(groupingBy(CoverageCount::getContractNumber)); + Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) + .stream().collect(groupingBy(CoverageCount::getContractNumber)); - // coverageCounts.get(contract.getContractNumber()) - // .forEach(count -> assertTrue(count.getBeneficiaryCount() >= 10000)); + coverageCounts.get(contract.getContractNumber()) + .forEach(count -> assertTrue(count.getBeneficiaryCount() >= 10000)); - // List issues = new ArrayList<>(); - // CoverageStableCheck stableCheck = - // new CoverageStableCheck(coverageService, coverageCounts, issues); + List issues = new ArrayList<>(); + CoverageStableCheck stableCheck = + new CoverageStableCheck(coverageService, coverageCounts, issues); - // assertFalse(stableCheck.test(contract)); + assertFalse(stableCheck.test(contract)); - // int expectedIssues = 2; + int expectedIssues = 2; - // assertEquals(expectedIssues, issues.size()); - // issues.forEach(issue -> assertTrue(issue.contains("enrollment changed"))); + assertEquals(expectedIssues, issues.size()); + issues.forEach(issue -> assertTrue(issue.contains("enrollment changed"))); - // assertTrue(issues.get(0).contains("20%")); - // } + assertTrue(issues.get(0).contains("20%")); + } @DisplayName("Coverage changes are limited to 10% between months passes when changes are 1000 benes or less") @Test @@ -381,40 +381,40 @@ void whenCoverageNotDuplicated_passCoverageDuplicatedCheck() { assertTrue(issues.isEmpty()); } - // @DisplayName("Out of date enrollment causes a failure") - // @Test - // void whenCoverageOutOfDate_failCoverageDateCheck() { + @DisplayName("Out of date enrollment causes a failure") + @Test + void whenCoverageOutOfDate_failCoverageDateCheck() { - // createCoveragePeriods(); + createCoveragePeriods(); - // Set tenK = new LinkedHashSet<>(); - // for (long idx = 0; idx < 10000; idx++) { - // tenK.add(createIdentifier(idx)); - // } + Set tenK = new LinkedHashSet<>(); + for (long idx = 0; idx < 10000; idx++) { + tenK.add(createIdentifier(idx)); + } - // insertAndRunSearch(attestationMonth, tenK); - // runSearchAndLeaveOld(attestationMonth); + insertAndRunSearch(attestationMonth, tenK); + runSearchAndLeaveOld(attestationMonth); - // insertAndRunSearch(attestationMonthPlus1, tenK); - // runSearchAndLeaveOld(attestationMonthPlus1); + insertAndRunSearch(attestationMonthPlus1, tenK); + runSearchAndLeaveOld(attestationMonthPlus1); - // insertAndRunSearch(attestationMonthPlus2, tenK); - // runSearchAndLeaveOld(attestationMonthPlus2); + insertAndRunSearch(attestationMonthPlus2, tenK); + runSearchAndLeaveOld(attestationMonthPlus2); - // insertAndRunSearch(attestationMonthPlus3, tenK); - // runSearchAndLeaveOld(attestationMonthPlus3); + insertAndRunSearch(attestationMonthPlus3, tenK); + runSearchAndLeaveOld(attestationMonthPlus3); - // Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) - // .stream().collect(groupingBy(CoverageCount::getContractNumber)); + Map> coverageCounts = coverageService.countBeneficiariesForContracts(List.of(contractForCoverageDTO)) + .stream().collect(groupingBy(CoverageCount::getContractNumber)); - // List issues = new ArrayList<>(); - // CoverageUpToDateCheck upToDateCheck = new CoverageUpToDateCheck(coverageService, coverageCounts, issues); + List issues = new ArrayList<>(); + CoverageUpToDateCheck upToDateCheck = new CoverageUpToDateCheck(coverageService, coverageCounts, issues); - // assertFalse(upToDateCheck.test(contract)); + assertFalse(upToDateCheck.test(contract)); - // assertEquals(4, issues.size()); - // issues.forEach(issue -> assertTrue(issue.contains("old coverage search"))); - // } + assertEquals(4, issues.size()); + issues.forEach(issue -> assertTrue(issue.contains("old coverage search"))); + } @DisplayName("Up to date enrollment passes") @Test From 2532f2f6b67bfa1ad9b80914ea9725266f975ddb Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Wed, 24 Jan 2024 17:50:37 -0500 Subject: [PATCH 13/15] Revert "temporary sonarqube workaround" This reverts commit 74167218bb07b7904c58bef56e9c63fdf9ac56ec. --- Jenkinsfile | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 60b868df7..fe9f382c0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -116,32 +116,32 @@ pipeline { } } } - // stage('SonarQube Analysis') { - // steps { - // withCredentials([usernamePassword(credentialsId: 'artifactoryuserpass', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { - // git branch: 'master', credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL - // git branch: env.BRANCH_NAME, credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL - // // Automatically saves the an id for the SonarQube build - // withSonarQubeEnv('CMSSonar') { - // sh ''' - // mvn -s settings.xml sonar:sonar -Dsonar.projectKey=ab2d-project -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} - // ''' - // } - // } - // } - // } - - // // New Way in declarative pipeline - // stage("Quality Gate") { - // options { - // timeout(time: 10, unit: 'MINUTES') - // } - // steps { - // // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails - // // true = set pipeline to UNSTABLE, false = don't - // waitForQualityGate abortPipeline: true - // } - // } + stage('SonarQube Analysis') { + steps { + withCredentials([usernamePassword(credentialsId: 'artifactoryuserpass', usernameVariable: 'ARTIFACTORY_USER', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { + git branch: 'master', credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL + git branch: env.BRANCH_NAME, credentialsId: 'GITHUB_AB2D_JENKINS_PAT', url: env.GIT_URL + // Automatically saves the an id for the SonarQube build + withSonarQubeEnv('CMSSonar') { + sh ''' + mvn -s settings.xml sonar:sonar -Dsonar.projectKey=ab2d-project -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} + ''' + } + } + } + } + + // New Way in declarative pipeline + stage("Quality Gate") { + options { + timeout(time: 10, unit: 'MINUTES') + } + steps { + // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails + // true = set pipeline to UNSTABLE, false = don't + waitForQualityGate abortPipeline: true + } + } stage('Run e2e-test') { From 68479e0c443f3bb6b63a4a66939c97cfc8568141 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Wed, 24 Jan 2024 18:28:35 -0800 Subject: [PATCH 14/15] commented out failed integration tests and switched steps in github actions --- .github/workflows/unit-integration-test.yml | 7 ++++--- .../processor/coverage/CoverageCheckIntegrationTest.java | 2 +- .../ab2d/worker/processor/coverage/CoverageDriverTest.java | 2 +- .../check/CoverageCheckPredicatesIntegrationTest.java | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit-integration-test.yml b/.github/workflows/unit-integration-test.yml index 29fa771a2..a194e431c 100644 --- a/.github/workflows/unit-integration-test.yml +++ b/.github/workflows/unit-integration-test.yml @@ -60,10 +60,11 @@ jobs: run: | mvn -ntp -U clean + - name: Run unit and integration tests + run: | + mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker + - name: SonarQube analysis run: | mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} compile sonar:sonar -Dsonar.projectKey=ab2d-project -Dsonar.qualitygate.wait=true -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} - - name: Run unit and integration tests - run: | - mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java index 69ce449b9..34788d69e 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java @@ -236,7 +236,7 @@ void verifyCoverage_whenSomeCoverageMissing_fail() { } @DisplayName("Verify coverage stops if some coverage periods change drastically") - @Test + // @Test void verifyCoverage_whenCoverageUnstable_fail() { createCoveragePeriods(); diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java index f6fa7b390..04b2c5f21 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java @@ -744,7 +744,7 @@ void availableCoverageWhenSinceContainsOnlySuccessful() { @DisplayName("Number of beneficiaries to process calculation works") - @Test + // @Test void numberOfBeneficiariesToProcess() { // Override BeforeEach method settings to make this test work for a smaller period of time diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java index 2c7631664..d7aee601f 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java @@ -202,7 +202,7 @@ void whenCoveragePeriodsPresent_passCoveragePresentCheck() { } @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") - @Test + // @Test void whenCoverageUnstable_failCoverageStabilityCheck() { // This test was using the actual month. Some month have their own logic which failed the test. @@ -382,7 +382,7 @@ void whenCoverageNotDuplicated_passCoverageDuplicatedCheck() { } @DisplayName("Out of date enrollment causes a failure") - @Test + // @Test void whenCoverageOutOfDate_failCoverageDateCheck() { createCoveragePeriods(); From b0525b94fc172c5777543f53cac702cd4df6c50a Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava Date: Mon, 29 Jan 2024 12:11:04 -0500 Subject: [PATCH 15/15] Revert "commented out failed integration tests and switched steps in github actions" This reverts commit 68479e0c443f3bb6b63a4a66939c97cfc8568141. --- .github/workflows/unit-integration-test.yml | 7 +++---- .../processor/coverage/CoverageCheckIntegrationTest.java | 2 +- .../ab2d/worker/processor/coverage/CoverageDriverTest.java | 2 +- .../check/CoverageCheckPredicatesIntegrationTest.java | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit-integration-test.yml b/.github/workflows/unit-integration-test.yml index a194e431c..29fa771a2 100644 --- a/.github/workflows/unit-integration-test.yml +++ b/.github/workflows/unit-integration-test.yml @@ -60,11 +60,10 @@ jobs: run: | mvn -ntp -U clean - - name: Run unit and integration tests - run: | - mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker - - name: SonarQube analysis run: | mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} compile sonar:sonar -Dsonar.projectKey=ab2d-project -Dsonar.qualitygate.wait=true -DskipTests -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} + - name: Run unit and integration tests + run: | + mvn -ntp -s settings.xml ${RUNNER_DEBUG:+"--debug"} -Dusername=${ARTIFACTORY_USER} -Dpassword=${ARTIFACTORY_PASSWORD} -Drepository_url=${ARTIFACTORY_URL} test -pl common,job,coverage,api,worker diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java index 34788d69e..69ce449b9 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageCheckIntegrationTest.java @@ -236,7 +236,7 @@ void verifyCoverage_whenSomeCoverageMissing_fail() { } @DisplayName("Verify coverage stops if some coverage periods change drastically") - // @Test + @Test void verifyCoverage_whenCoverageUnstable_fail() { createCoveragePeriods(); diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java index 04b2c5f21..f6fa7b390 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/CoverageDriverTest.java @@ -744,7 +744,7 @@ void availableCoverageWhenSinceContainsOnlySuccessful() { @DisplayName("Number of beneficiaries to process calculation works") - // @Test + @Test void numberOfBeneficiariesToProcess() { // Override BeforeEach method settings to make this test work for a smaller period of time diff --git a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java index d7aee601f..2c7631664 100644 --- a/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java +++ b/worker/src/test/java/gov/cms/ab2d/worker/processor/coverage/check/CoverageCheckPredicatesIntegrationTest.java @@ -202,7 +202,7 @@ void whenCoveragePeriodsPresent_passCoveragePresentCheck() { } @DisplayName("Coverage changes are limited to 10% between months fails when changes are large") - // @Test + @Test void whenCoverageUnstable_failCoverageStabilityCheck() { // This test was using the actual month. Some month have their own logic which failed the test. @@ -382,7 +382,7 @@ void whenCoverageNotDuplicated_passCoverageDuplicatedCheck() { } @DisplayName("Out of date enrollment causes a failure") - // @Test + @Test void whenCoverageOutOfDate_failCoverageDateCheck() { createCoveragePeriods();