use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobProcessorIntegrationTest method createJob.
private Job createJob(PdpClient pdpClient) {
Job job = new Job();
job.setJobUuid(JOB_UUID);
job.setStatus(JobStatus.SUBMITTED);
job.setStatusMessage("0%");
job.setOrganization(pdpClient.getOrganization());
job.setOutputFormat(NDJSON_FIRE_CONTENT_TYPE);
job.setCreatedAt(OffsetDateTime.now());
job.setFhirVersion(STU3);
job.setContractNumber(contract.getContractNumber());
job = jobRepository.saveAndFlush(job);
dataSetup.queueForCleanup(job);
return job;
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobProcessorUnitTest method createJob.
private Job createJob(PdpClient pdpClient) {
Job job = new Job();
job.setJobUuid(jobUuid);
job.setStatusMessage("0%");
job.setStatus(JobStatus.IN_PROGRESS);
job.setOrganization(pdpClient.getOrganization());
return job;
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class JobHandlerTest method processUntilSuccessfulForAJob.
@DisplayName("Handler attempts to start jobs until it finds one that it can start")
@Test
void processUntilSuccessfulForAJob() {
ReentrantLock lock = new ReentrantLock();
when(workerService.getEngagement()).thenReturn(FeatureEngagement.IN_GEAR);
when(lockRegistry.obtain(anyString())).thenReturn(lock);
Job submittedJob = new Job();
submittedJob.setStatus(JobStatus.SUBMITTED);
Job startedJob = new Job();
startedJob.setStatus(JobStatus.IN_PROGRESS);
when(workerService.process(anyString())).thenReturn(submittedJob, submittedJob, startedJob, startedJob);
JobHandler jobHandler = new JobHandler(lockRegistry, workerService);
Map<String, Object> first = new HashMap<>() {
{
put("job_uuid", "first job id");
}
};
Map<String, Object> second = new HashMap<>() {
{
put("job_uuid", "second job id");
}
};
Map<String, Object> third = new HashMap<>() {
{
put("job_uuid", "third job id");
}
};
Map<String, Object> fourth = new HashMap<>() {
{
put("job_uuid", "fourth job id");
}
};
List<Map<String, Object>> payload = List.of(first, second, third, fourth);
jobHandler.handleMessage(new GenericMessage<>(payload));
assertFalse(lock.isLocked());
verify(workerService, times(1)).getEngagement();
verify(workerService, times(3)).process(anyString());
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class ContractProcessorInvalidPatientTest method testInvalidBenes.
@Test
void testInvalidBenes() throws IOException {
when(mapping.map(any(ContractDTO.class))).thenReturn(new ContractForCoverageDTO(contract.getContractNumber(), contract.getAttestedOn(), ContractForCoverageDTO.ContractType.NORMAL));
org.hl7.fhir.dstu3.model.Bundle b1 = BundleUtils.createBundle(createBundleEntry("1"));
org.hl7.fhir.dstu3.model.Bundle b2 = BundleUtils.createBundle(createBundleEntry("2"));
org.hl7.fhir.dstu3.model.Bundle b4 = BundleUtils.createBundle(createBundleEntry("4"));
when(bfdClient.requestEOBFromServer(eq(STU3), eq(1L), any())).thenReturn(b1);
when(bfdClient.requestEOBFromServer(eq(STU3), eq(2L), any())).thenReturn(b2);
when(bfdClient.requestEOBFromServer(eq(STU3), eq(3L), any())).thenReturn(b4);
when(coverageDriver.numberOfBeneficiariesToProcess(any(Job.class), any(ContractDTO.class))).thenReturn(3);
List<FilterOutByDate.DateRange> dates = singletonList(TestUtil.getOpenRange());
List<CoverageSummary> summaries = List.of(new CoverageSummary(createIdentifierWithoutMbi(1L), null, dates), new CoverageSummary(createIdentifierWithoutMbi(2L), null, dates), new CoverageSummary(createIdentifierWithoutMbi(3L), null, dates));
when(coverageDriver.pageCoverage(any(CoveragePagingRequest.class))).thenReturn(new CoveragePagingResult(summaries, null));
List<JobOutput> outputs = cut.process(job);
assertNotNull(outputs);
assertEquals(1, outputs.size());
String fileName1 = contractId + "_0001.ndjson";
String output1 = outputs.get(0).getFilePath();
assertTrue(output1.equalsIgnoreCase(fileName1));
String actual1 = Files.readString(Path.of(tmpDirFolder.getAbsolutePath() + File.separator + job.getJobUuid() + "/" + output1));
assertTrue(actual1.contains("Patient/1") && actual1.contains("Patient/2"));
assertFalse(actual1.contains("Patient/3") || actual1.contains("Patient/4"));
}
use of gov.cms.ab2d.common.model.Job in project ab2d by CMSgov.
the class ContractProcessorUnitTest method createJob.
private Job createJob(PdpClient pdpClient) {
Job job = new Job();
job.setJobUuid(jobUuid);
job.setStatusMessage("0%");
job.setStatus(JobStatus.IN_PROGRESS);
job.setOrganization(pdpClient.getOrganization());
job.setFhirVersion(STU3);
return job;
}
Aggregations