use of gov.cms.ab2d.bfd.client.BFDClient in project ab2d by CMSgov.
the class CoverageDriverTest method before.
@BeforeEach
void before() {
mapping = new ContractToContractCoverageMapping();
// Set properties values in database
addPropertiesTableValues();
contract = dataSetup.setupContract("TST-12", AB2D_EPOCH.toOffsetDateTime());
contract1 = dataSetup.setupContract("TST-45", AB2D_EPOCH.toOffsetDateTime());
contractForCoverageDTO = new ContractForCoverageDTO("TST-12", AB2D_EPOCH.toOffsetDateTime(), ContractForCoverageDTO.ContractType.NORMAL);
contractForCoverageDTO1 = new ContractForCoverageDTO("TST-45", AB2D_EPOCH.toOffsetDateTime(), ContractForCoverageDTO.ContractType.NORMAL);
contractRepo.saveAndFlush(contract);
january = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 1, 2020);
february = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 2, 2020);
march = coverageDataSetup.createCoveragePeriod(contract.getContractNumber(), 3, 2020);
PdpClientDTO contractPdpClient = createClient(contract, "TST-12", SPONSOR_ROLE);
pdpClientService.createClient(contractPdpClient);
dataSetup.queueForCleanup(pdpClientService.getClientById("TST-12"));
PdpClient pdpClient = dataSetup.setupPdpClient(List.of());
job = new Job();
job.setContractNumber(contract.getContractNumber());
job.setJobUuid("unique");
job.setOrganization(pdpClient.getOrganization());
job.setStatus(gov.cms.ab2d.common.model.JobStatus.SUBMITTED);
job.setCreatedAt(OffsetDateTime.now());
job.setFhirVersion(STU3);
jobRepo.saveAndFlush(job);
dataSetup.queueForCleanup(job);
bfdClient = mock(BFDClient.class);
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setMaxPoolSize(6);
taskExecutor.setCorePoolSize(3);
taskExecutor.initialize();
processor = new CoverageProcessorImpl(coverageService, bfdClient, taskExecutor, MAX_ATTEMPTS, contractWorkerClient);
driver = new CoverageDriverImpl(coverageSearchRepo, pdpClientService, coverageService, propertiesService, processor, searchLock, contractToContractCoverageMapping);
}
use of gov.cms.ab2d.bfd.client.BFDClient 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.bfd.client.BFDClient in project ab2d by CMSgov.
the class CoverageUpdateAndProcessorTest method before.
@BeforeEach
void before() {
// Set values used to find jobs to update
addPropertiesTableValues();
originalValues.clear();
contract = dataSetup.setupContract("TST-12", AB2D_EPOCH.toOffsetDateTime());
contractRepo.saveAndFlush(contract);
january = coverageDataSetup.createCoveragePeriod("TST-12", 1, 2020);
february = coverageDataSetup.createCoveragePeriod("TST-12", 2, 2020);
march = coverageDataSetup.createCoveragePeriod("TST-12", 3, 2020);
PdpClientDTO contractPdpClient = createClient(contract.toDTO(), "TST-12", SPONSOR_ROLE);
pdpClientService.createClient(contractPdpClient);
dataSetup.queueForCleanup(pdpClientService.getClientById("TST-12"));
bfdClient = mock(BFDClient.class);
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setMaxPoolSize(6);
taskExecutor.setCorePoolSize(3);
taskExecutor.initialize();
processor = new CoverageProcessorImpl(coverageService, bfdClient, taskExecutor, MAX_ATTEMPTS, contractWorkerClient);
driver = new CoverageDriverImpl(coverageSearchRepo, pdpClientService, coverageService, propertiesService, processor, searchLock, mapping);
}
Aggregations