Search in sources :

Example 16 with Job

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;
}
Also used : Job(gov.cms.ab2d.common.model.Job)

Example 17 with 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;
}
Also used : Job(gov.cms.ab2d.common.model.Job)

Example 18 with 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());
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) HashMap(java.util.HashMap) Job(gov.cms.ab2d.common.model.Job) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with Job

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"));
}
Also used : CoverageSummary(gov.cms.ab2d.coverage.model.CoverageSummary) ContractForCoverageDTO(gov.cms.ab2d.coverage.model.ContractForCoverageDTO) CoveragePagingRequest(gov.cms.ab2d.coverage.model.CoveragePagingRequest) CoveragePagingResult(gov.cms.ab2d.coverage.model.CoveragePagingResult) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) Job(gov.cms.ab2d.common.model.Job) JobOutput(gov.cms.ab2d.common.model.JobOutput) Test(org.junit.jupiter.api.Test)

Example 20 with Job

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;
}
Also used : Job(gov.cms.ab2d.common.model.Job)

Aggregations

Job (gov.cms.ab2d.common.model.Job)67 Test (org.junit.jupiter.api.Test)39 DisplayName (org.junit.jupiter.api.DisplayName)31 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)21 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 OffsetDateTime (java.time.OffsetDateTime)15 JobOutput (gov.cms.ab2d.common.model.JobOutput)9 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)9 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)9 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)8 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)6 Map (java.util.Map)5 Contract (gov.cms.ab2d.common.model.Contract)4 PdpClient (gov.cms.ab2d.common.model.PdpClient)4 ZonedDateTime (java.time.ZonedDateTime)4 Transactional (org.springframework.transaction.annotation.Transactional)4 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)3 List (java.util.List)3 Trace (com.newrelic.api.agent.Trace)2 PdpClientService (gov.cms.ab2d.common.service.PdpClientService)2