use of gov.cms.ab2d.fhir.FhirVersion.STU3 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);
}
Aggregations