Search in sources :

Example 11 with PdpClient

use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.

the class JobProcessorIntegrationTest method createClient.

private PdpClient createClient() {
    PdpClient pdpClient = new PdpClient();
    pdpClient.setClientId("Harry_Potter");
    pdpClient.setOrganization("Harry_Potter");
    pdpClient.setEnabled(TRUE);
    pdpClient = pdpClientRepository.saveAndFlush(pdpClient);
    dataSetup.queueForCleanup(pdpClient);
    return pdpClient;
}
Also used : PdpClient(gov.cms.ab2d.common.model.PdpClient)

Example 12 with PdpClient

use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.

the class JobProcessorIntegrationTest method setUp.

@BeforeEach
void setUp() {
    MockitoAnnotations.openMocks(this);
    LogManager logManager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
    PdpClient pdpClient = createClient();
    contract = createContract();
    contractForCoverageDTO = mapping.map(contract);
    fail = new RuntimeException("TEST EXCEPTION");
    job = createJob(pdpClient);
    job.setContractNumber(contract.getContractNumber());
    job.setStatus(JobStatus.IN_PROGRESS);
    jobRepository.saveAndFlush(job);
    when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong())).thenAnswer((args) -> {
        ExplanationOfBenefit copy = EOB.copy();
        copy.getPatient().setReference("Patient/" + args.getArgument(1));
        return EobTestDataUtil.createBundle(copy);
    });
    when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong(), any())).thenAnswer((args) -> {
        ExplanationOfBenefit copy = EOB.copy();
        copy.getPatient().setReference("Patient/" + args.getArgument(1));
        return EobTestDataUtil.createBundle(copy);
    });
    when(mockCoverageDriver.numberOfBeneficiariesToProcess(any(Job.class), any(ContractDTO.class))).thenReturn(100);
    when(mockCoverageDriver.pageCoverage(any(CoveragePagingRequest.class))).thenReturn(new CoveragePagingResult(loadFauxMetadata(contractForCoverageDTO, 99), null));
    SearchConfig searchConfig = new SearchConfig(tmpEfsMountDir.getAbsolutePath(), STREAMING_DIR, FINISHED_DIR, 0, 0, MULTIPLIER, NUMBER_PATIENT_REQUESTS_PER_THREAD);
    PatientClaimsProcessor patientClaimsProcessor = new PatientClaimsProcessorImpl(mockBfdClient, logManager, searchConfig);
    ReflectionTestUtils.setField(patientClaimsProcessor, "earliestDataDate", "01/01/1900");
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.initialize();
    ContractProcessor contractProcessor = new ContractProcessorImpl(contractWorkerClient, jobRepository, mockCoverageDriver, patientClaimsProcessor, logManager, eobClaimRequestsQueue, jobChannelService, jobProgressService, mapping, pool, searchConfig);
    cut = new JobProcessorImpl(fileService, jobChannelService, jobProgressService, jobProgressUpdateService, jobRepository, jobOutputRepository, contractProcessor, logManager);
    ReflectionTestUtils.setField(cut, "efsMount", tmpEfsMountDir.toString());
    ReflectionTestUtils.setField(cut, "failureThreshold", 10);
}
Also used : SearchConfig(gov.cms.ab2d.worker.config.SearchConfig) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) PdpClient(gov.cms.ab2d.common.model.PdpClient) CoveragePagingRequest(gov.cms.ab2d.coverage.model.CoveragePagingRequest) CoveragePagingResult(gov.cms.ab2d.coverage.model.CoveragePagingResult) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Job(gov.cms.ab2d.common.model.Job) LogManager(gov.cms.ab2d.eventlogger.LogManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with PdpClient

use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.

the class JobProcessorUnitTest method setUp.

@BeforeEach
void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    JobProgressServiceImpl jobProgressUpdateService = spy(new JobProgressServiceImpl(jobRepository));
    jobProgressUpdateService.initJob(jobUuid);
    jobProgressService = jobProgressUpdateService;
    jobChannelService = new JobChannelStubServiceImpl(jobProgressUpdateService);
    cut = spy(new JobProcessorImpl(fileService, jobChannelService, jobProgressService, jobProgressUpdateService, jobRepository, jobOutputRepository, contractProcessor, eventLogger));
    ReflectionTestUtils.setField(cut, "efsMount", efsMountTmpDir.toString());
    final PdpClient pdpClient = createClient();
    job = createJob(pdpClient);
    var contract = createContract();
    job.setContractNumber(contract.getContractNumber());
    final Path outputDirPath = Paths.get(efsMountTmpDir.toString(), jobUuid);
    final Path outputDir = Files.createDirectories(outputDirPath);
    lenient().when(jobRepository.findByJobUuid(job.getJobUuid())).thenReturn(job);
    lenient().when(fileService.createDirectory(any(Path.class))).thenReturn(outputDir);
}
Also used : Path(java.nio.file.Path) JobChannelStubServiceImpl(gov.cms.ab2d.worker.service.JobChannelStubServiceImpl) PdpClient(gov.cms.ab2d.common.model.PdpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with PdpClient

use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.

the class ContractProcessorUnitTest method setUp.

@BeforeEach
void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    patientClaimsProcessor = spy(PatientClaimsProcessorStub.class);
    mapping = new ContractToContractCoverageMapping();
    contract = createContractDTO();
    contractForCoverageDTO = mapping.map(contract);
    PdpClient pdpClient = createClient();
    job = createJob(pdpClient);
    job.setContractNumber(contract.getContractNumber());
    jobRepository = new StubJobRepository(job);
    JobProgressServiceImpl jobProgressImpl = new JobProgressServiceImpl(jobRepository);
    jobProgressImpl.initJob(jobUuid);
    ReflectionTestUtils.setField(jobProgressImpl, "reportProgressDbFrequency", 2);
    ReflectionTestUtils.setField(jobProgressImpl, "reportProgressLogFrequency", 3);
    jobChannelService = new JobChannelStubServiceImpl(jobProgressImpl);
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.initialize();
    SearchConfig searchConfig = new SearchConfig(efsMountTmpDir.toFile().getAbsolutePath(), STREAMING, FINISHED, 0, 0, 2, 1);
    ContractWorkerClient contractWorkerClient = new ContractWorkerClientMock();
    cut = new ContractProcessorImpl(contractWorkerClient, jobRepository, coverageDriver, patientClaimsProcessor, eventLogger, requestQueue, jobChannelService, jobProgressImpl, mapping, pool, searchConfig);
    // ReflectionTestUtils.setField(cut, "numberPatientRequestsPerThread", 2);
    var outputDirPath = Paths.get(efsMountTmpDir.toString(), jobUuid);
    Files.createDirectories(outputDirPath);
}
Also used : ContractWorkerClient(gov.cms.ab2d.worker.service.ContractWorkerClient) JobChannelStubServiceImpl(gov.cms.ab2d.worker.service.JobChannelStubServiceImpl) PatientClaimsProcessorStub(gov.cms.ab2d.worker.processor.stub.PatientClaimsProcessorStub) ContractWorkerClientMock(gov.cms.ab2d.worker.util.ContractWorkerClientMock) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) SearchConfig(gov.cms.ab2d.worker.config.SearchConfig) StubJobRepository(gov.cms.ab2d.worker.repository.StubJobRepository) PdpClient(gov.cms.ab2d.common.model.PdpClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with PdpClient

use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.

the class ContractProcessorUnitTest method createClient.

private PdpClient createClient() {
    PdpClient pdpClient = new PdpClient();
    pdpClient.setClientId("Harry_Potter");
    pdpClient.setEnabled(TRUE);
    pdpClient.setContract(createContract());
    return pdpClient;
}
Also used : PdpClient(gov.cms.ab2d.common.model.PdpClient)

Aggregations

PdpClient (gov.cms.ab2d.common.model.PdpClient)43 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 BeforeEach (org.junit.jupiter.api.BeforeEach)8 Test (org.junit.jupiter.api.Test)7 Contract (gov.cms.ab2d.common.model.Contract)6 Job (gov.cms.ab2d.common.model.Job)5 ApiResponseEvent (gov.cms.ab2d.eventlogger.events.ApiResponseEvent)5 Role (gov.cms.ab2d.common.model.Role)4 PdpClientDTO (gov.cms.ab2d.common.dto.PdpClientDTO)3 LoggableEvent (gov.cms.ab2d.eventlogger.LoggableEvent)3 ApiRequestEvent (gov.cms.ab2d.eventlogger.events.ApiRequestEvent)3 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)3 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)3 TooManyRequestsException (gov.cms.ab2d.api.controller.TooManyRequestsException)2 BFDClient (gov.cms.ab2d.bfd.client.BFDClient)2 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)2 StaleJob (gov.cms.ab2d.common.dto.StaleJob)2 StartJobDTO (gov.cms.ab2d.common.dto.StartJobDTO)2 JobOutput (gov.cms.ab2d.common.model.JobOutput)2 LogManager (gov.cms.ab2d.eventlogger.LogManager)2