use of gov.cms.ab2d.coverage.model.CoverageJobStatus in project ab2d by CMSgov.
the class CoverageDriverTest method normalExecution.
@DisplayName("Normal workflow functions")
@Test
void normalExecution() {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10);
bundle1.setLink(singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20);
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
processor.queueCoveragePeriod(january, false);
CoverageJobStatus status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUBMITTED, status);
driver.loadMappingJob();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
sleep(1000);
processor.monitorMappingJobs();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
processor.insertJobResults();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUCCESSFUL, status);
}
use of gov.cms.ab2d.coverage.model.CoverageJobStatus in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method mappingRetried.
@DisplayName("Mapping failure leads to retry but still can succeed on retry")
@Test
void mappingRetried() {
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt())).thenThrow(new RuntimeException("oops"));
processor.queueCoveragePeriod(january, false);
CoverageJobStatus status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUBMITTED, status);
driver.loadMappingJob();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
sleep(1000);
processor.monitorMappingJobs();
assertTrue(coverageSearchEventRepo.findAll().stream().anyMatch(event -> event.getNewStatus() == CoverageJobStatus.FAILED));
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUBMITTED, status);
reset(bfdClient);
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10);
bundle1.setLink(Collections.singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20);
Mockito.clearInvocations();
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
driver.loadMappingJob();
sleep(1000);
processor.monitorMappingJobs();
sleep(1000);
processor.insertJobResults();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUCCESSFUL, status);
}
use of gov.cms.ab2d.coverage.model.CoverageJobStatus in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method iterateFailingJob.
private CoverageJobStatus iterateFailingJob() {
CoverageJobStatus status;
driver.loadMappingJob();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
sleep(1000);
processor.monitorMappingJobs();
status = coverageService.getSearchStatus(january.getId());
return status;
}
use of gov.cms.ab2d.coverage.model.CoverageJobStatus in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method mappingFailsAfterXRetries.
@DisplayName("Mapping failure after x retries")
@Test
void mappingFailsAfterXRetries() {
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt())).thenThrow(new RuntimeException("oops"));
processor.queueCoveragePeriod(january, false);
CoverageJobStatus status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUBMITTED, status);
// Should retry x times
for (int i = 0; i < maxRetries; i++) {
status = iterateFailingJob();
assertEquals(CoverageJobStatus.SUBMITTED, status);
}
status = iterateFailingJob();
assertEquals(CoverageJobStatus.FAILED, status);
}
use of gov.cms.ab2d.coverage.model.CoverageJobStatus in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method normalExecution.
@DisplayName("Normal workflow functions")
@Test
void normalExecution() throws CoverageDriverException, InterruptedException {
org.hl7.fhir.dstu3.model.Bundle bundle1 = buildBundle(0, 10);
bundle1.setLink(Collections.singletonList(new org.hl7.fhir.dstu3.model.Bundle.BundleLinkComponent().setRelation(org.hl7.fhir.dstu3.model.Bundle.LINK_NEXT)));
org.hl7.fhir.dstu3.model.Bundle bundle2 = buildBundle(10, 20);
when(bfdClient.requestPartDEnrolleesFromServer(eq(STU3), anyString(), anyInt(), anyInt())).thenReturn(bundle1);
when(bfdClient.requestNextBundleFromServer(eq(STU3), any(org.hl7.fhir.dstu3.model.Bundle.class))).thenReturn(bundle2);
processor.queueCoveragePeriod(january, false);
CoverageJobStatus status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUBMITTED, status);
driver.loadMappingJob();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
sleep(1000);
processor.monitorMappingJobs();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.IN_PROGRESS, status);
processor.insertJobResults();
status = coverageService.getSearchStatus(january.getId());
assertEquals(CoverageJobStatus.SUCCESSFUL, status);
}
Aggregations