use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class CoverageDriverUnitTest method failPagingWhenCoveragePeriodMissing.
@DisplayName("Paging coverage fails when coverage periods are missing")
@Test
void failPagingWhenCoveragePeriodMissing() {
when(coverageService.getCoveragePeriod(any(), anyInt(), anyInt())).thenThrow(new EntityNotFoundException());
Job job = new Job();
ContractDTO contract = new ContractDTO(null, null, AB2D_EPOCH.toOffsetDateTime(), null);
CoverageDriverException startDateInFuture = assertThrows(CoverageDriverException.class, () -> driver.pageCoverage(job, contract));
assertEquals(EntityNotFoundException.class, startDateInFuture.getCause().getClass());
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method coverageAvailabilityLimitsRetries.
@DisplayName("Coverage availability throws exception after max attempts retries")
@Test
void coverageAvailabilityLimitsRetries() {
Job job = new Job();
job.setCreatedAt(OffsetDateTime.now());
job.setContractNumber(contract.getContractNumber());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
fail("could not complete test");
}
january.setStatus(CoverageJobStatus.FAILED);
coveragePeriodRepo.saveAndFlush(january);
february.setStatus(CoverageJobStatus.FAILED);
coveragePeriodRepo.saveAndFlush(february);
try {
driver.isCoverageAvailable(job, contract.toDTO());
} catch (CoverageDriverException coverageDriverException) {
// passed
} catch (InterruptedException interruptedException) {
fail("could not complete test");
}
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobPreProcessorUnitTest method testDownloadedAll.
@Test
void testDownloadedAll() {
Job job = new Job();
// Error file that was downloaded
JobOutput jo1 = createJobOutput(job, true, true);
// Error file that was not downloaded
JobOutput jo2 = createJobOutput(job, true, false);
// Data file that was downloaded
JobOutput jo3 = createJobOutput(job, false, true);
// Data file that was not downloaded - anything that includes this should return false
JobOutput jo4 = createJobOutput(job, false, false);
JobPreProcessorImpl impl = (JobPreProcessorImpl) cut;
// Start with null or empty results
assertTrue(impl.downloadedAll(null));
assertTrue(impl.downloadedAll(Collections.emptyList()));
// Try each individual
assertTrue(impl.downloadedAll(List.of(jo1)));
assertTrue(impl.downloadedAll(List.of(jo2)));
assertTrue(impl.downloadedAll(List.of(jo3)));
assertFalse(impl.downloadedAll(List.of(jo4)));
// Try combinations
assertTrue(impl.downloadedAll(List.of(jo1, jo2, jo3)));
assertFalse(impl.downloadedAll(List.of(jo1, jo2, jo3, jo4)));
assertFalse(impl.downloadedAll(List.of(jo1, jo4)));
assertFalse(impl.downloadedAll(List.of(jo2, jo3, jo4)));
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobPreProcessorUnitTest method createJob.
// Not first run, since supplied
private Job createJob() {
Job job = new Job();
job.setJobUuid(JOB_UUID);
job.setStatusMessage("0%");
job.setFhirVersion(STU3);
job.setContractNumber(contract.getContractNumber());
return job;
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobProcessorIntegrationTest method setUp.
@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
LogManager logManager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
PdpClient pdpClient = createClient();
contract = createContract();
contractForCoverageDTO = mapping.map(contract);
fail = new RuntimeException("TEST EXCEPTION");
job = createJob(pdpClient);
job.setContractNumber(contract.getContractNumber());
job.setStatus(JobStatus.IN_PROGRESS);
jobRepository.saveAndFlush(job);
when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong())).thenAnswer((args) -> {
ExplanationOfBenefit copy = EOB.copy();
copy.getPatient().setReference("Patient/" + args.getArgument(1));
return EobTestDataUtil.createBundle(copy);
});
when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong(), any())).thenAnswer((args) -> {
ExplanationOfBenefit copy = EOB.copy();
copy.getPatient().setReference("Patient/" + args.getArgument(1));
return EobTestDataUtil.createBundle(copy);
});
when(mockCoverageDriver.numberOfBeneficiariesToProcess(any(Job.class), any(ContractDTO.class))).thenReturn(100);
when(mockCoverageDriver.pageCoverage(any(CoveragePagingRequest.class))).thenReturn(new CoveragePagingResult(loadFauxMetadata(contractForCoverageDTO, 99), null));
SearchConfig searchConfig = new SearchConfig(tmpEfsMountDir.getAbsolutePath(), STREAMING_DIR, FINISHED_DIR, 0, 0, MULTIPLIER, NUMBER_PATIENT_REQUESTS_PER_THREAD);
PatientClaimsProcessor patientClaimsProcessor = new PatientClaimsProcessorImpl(mockBfdClient, logManager, searchConfig);
ReflectionTestUtils.setField(patientClaimsProcessor, "earliestDataDate", "01/01/1900");
ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.initialize();
ContractProcessor contractProcessor = new ContractProcessorImpl(contractWorkerClient, jobRepository, mockCoverageDriver, patientClaimsProcessor, logManager, eobClaimRequestsQueue, jobChannelService, jobProgressService, mapping, pool, searchConfig);
cut = new JobProcessorImpl(fileService, jobChannelService, jobProgressService, jobProgressUpdateService, jobRepository, jobOutputRepository, contractProcessor, logManager);
ReflectionTestUtils.setField(cut, "efsMount", tmpEfsMountDir.toString());
ReflectionTestUtils.setField(cut, "failureThreshold", 10);
}
Aggregations