Search in sources :

Example 1 with JobChannelStubServiceImpl

use of gov.cms.ab2d.worker.service.JobChannelStubServiceImpl 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 2 with JobChannelStubServiceImpl

use of gov.cms.ab2d.worker.service.JobChannelStubServiceImpl 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 3 with JobChannelStubServiceImpl

use of gov.cms.ab2d.worker.service.JobChannelStubServiceImpl in project ab2d by CMSgov.

the class ContractProcessorInvalidPatientTest method setup.

@BeforeEach
void setup() {
    contractWorkerClient = new ContractWorkerClientMock();
    contract = new ContractDTO(contractId, contractId, OffsetDateTime.now().minusYears(50), null);
    SearchConfig searchConfig = new SearchConfig(tmpDirFolder.getAbsolutePath(), STREAMING_DIR, FINISHED_DIR, 0, 0, 1, 2);
    job.setJobUuid(jobId);
    job.setContractNumber(contract.getContractNumber());
    JobRepository jobRepository = new StubJobRepository(job);
    patientClaimsProcessor = new PatientClaimsProcessorImpl(bfdClient, eventLogger, searchConfig);
    JobProgressServiceImpl jobProgressUpdateService = new JobProgressServiceImpl(jobRepository);
    jobProgressUpdateService.initJob(jobId);
    JobChannelService jobChannelService = new JobChannelStubServiceImpl(jobProgressUpdateService);
    ThreadPoolTaskExecutor aggTP = new ThreadPoolTaskExecutor();
    aggTP.initialize();
    cut = new ContractProcessorImpl(contractWorkerClient, jobRepository, coverageDriver, patientClaimsProcessor, eventLogger, requestQueue, jobChannelService, jobProgressUpdateService, mapping, aggTP, searchConfig);
    ReflectionTestUtils.setField(cut, "eobJobPatientQueueMaxSize", 1);
    ReflectionTestUtils.setField(cut, "eobJobPatientQueuePageSize", 1);
    jobChannelService.sendUpdate(jobId, JobMeasure.FAILURE_THRESHHOLD, 100);
    ReflectionTestUtils.setField(patientClaimsProcessor, "earliestDataDate", "01/01/2020");
}
Also used : JobChannelStubServiceImpl(gov.cms.ab2d.worker.service.JobChannelStubServiceImpl) JobChannelService(gov.cms.ab2d.worker.service.JobChannelService) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ContractWorkerClientMock(gov.cms.ab2d.worker.util.ContractWorkerClientMock) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) SearchConfig(gov.cms.ab2d.worker.config.SearchConfig) JobRepository(gov.cms.ab2d.common.repository.JobRepository) StubJobRepository(gov.cms.ab2d.worker.repository.StubJobRepository) StubJobRepository(gov.cms.ab2d.worker.repository.StubJobRepository) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

JobChannelStubServiceImpl (gov.cms.ab2d.worker.service.JobChannelStubServiceImpl)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 PdpClient (gov.cms.ab2d.common.model.PdpClient)2 SearchConfig (gov.cms.ab2d.worker.config.SearchConfig)2 StubJobRepository (gov.cms.ab2d.worker.repository.StubJobRepository)2 ContractWorkerClientMock (gov.cms.ab2d.worker.util.ContractWorkerClientMock)2 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)2 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)1 JobRepository (gov.cms.ab2d.common.repository.JobRepository)1 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)1 PatientClaimsProcessorStub (gov.cms.ab2d.worker.processor.stub.PatientClaimsProcessorStub)1 ContractWorkerClient (gov.cms.ab2d.worker.service.ContractWorkerClient)1 JobChannelService (gov.cms.ab2d.worker.service.JobChannelService)1 Path (java.nio.file.Path)1