Search in sources :

Example 1 with LogManager

use of gov.cms.ab2d.eventlogger.LogManager 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 2 with LogManager

use of gov.cms.ab2d.eventlogger.LogManager in project ab2d by CMSgov.

the class JobPreProcessorIntegrationTest method setUp.

@BeforeEach
void setUp() {
    MockitoAnnotations.openMocks(this);
    LogManager manager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
    cut = new JobPreProcessorImpl(contractWorkerClient, jobRepository, manager, coverageDriver);
    Contract tmpContract = new Contract();
    tmpContract.setContractNumber(UUID.randomUUID().toString());
    tmpContract.setContractName(UUID.randomUUID().toString());
    contract = contractRepository.save(tmpContract);
    pdpClient = createClient(tmpContract);
    job = createJob(pdpClient, contract.getContractNumber());
}
Also used : LogManager(gov.cms.ab2d.eventlogger.LogManager) Contract(gov.cms.ab2d.common.model.Contract) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with LogManager

use of gov.cms.ab2d.eventlogger.LogManager in project ab2d by CMSgov.

the class CoverageCheckQuartzJobTest method whenVerificationException_alertWithIssues.

@DisplayName("Report issues when verification detects issues")
@Test
void whenVerificationException_alertWithIssues() {
    when(propertiesService.isInMaintenanceMode()).thenReturn(false);
    doThrow(new CoverageVerificationException("testing123", List.of("alertalert"))).when(coverageDriver).verifyCoverage();
    CoverageCheckQuartzJob job = new CoverageCheckQuartzJob(logManager, coverageDriver, propertiesService);
    JobExecutionException exception = assertThrows(JobExecutionException.class, () -> job.executeInternal(null));
    assertTrue(exception.getMessage().contains("testing123"));
    verify(propertiesService, times(1)).isInMaintenanceMode();
    verify(coverageDriver, times(1)).verifyCoverage();
    verify(logManager, times(1)).alert(argThat(alert -> alert.contains("alertalert") && alert.contains("Coverage verification failed")), anyList());
}
Also used : MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) LogManager(gov.cms.ab2d.eventlogger.LogManager) CoverageDriver(gov.cms.ab2d.worker.processor.coverage.CoverageDriver) Mock(org.mockito.Mock) CoverageVerificationException(gov.cms.ab2d.worker.processor.coverage.CoverageVerificationException) DisplayName(org.junit.jupiter.api.DisplayName) Test(org.junit.jupiter.api.Test) JobExecutionException(org.quartz.JobExecutionException) Mockito(org.mockito.Mockito) AfterEach(org.junit.jupiter.api.AfterEach) List(java.util.List) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) PropertiesService(gov.cms.ab2d.common.service.PropertiesService) Assertions(org.junit.jupiter.api.Assertions) JobExecutionException(org.quartz.JobExecutionException) CoverageVerificationException(gov.cms.ab2d.worker.processor.coverage.CoverageVerificationException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with LogManager

use of gov.cms.ab2d.eventlogger.LogManager in project ab2d by CMSgov.

the class JobServiceTest method setup.

// Be safe and make sure nothing from another test will impact current test
@BeforeEach
public void setup() {
    MockitoAnnotations.openMocks(this);
    LogManager logManager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
    jobService = new JobServiceImpl(jobRepository, jobOutputService, logManager, loggerEventSummary, tmpJobLocation);
    ReflectionTestUtils.setField(jobService, "fileDownloadPath", tmpJobLocation);
    dataSetup.setupNonStandardClient(CLIENTID, CONTRACT_NUMBER, of());
    setupRegularClientSecurityContext();
}
Also used : LogManager(gov.cms.ab2d.eventlogger.LogManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

LogManager (gov.cms.ab2d.eventlogger.LogManager)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)1 Contract (gov.cms.ab2d.common.model.Contract)1 Job (gov.cms.ab2d.common.model.Job)1 PdpClient (gov.cms.ab2d.common.model.PdpClient)1 PropertiesService (gov.cms.ab2d.common.service.PropertiesService)1 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)1 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)1 SearchConfig (gov.cms.ab2d.worker.config.SearchConfig)1 CoverageDriver (gov.cms.ab2d.worker.processor.coverage.CoverageDriver)1 CoverageVerificationException (gov.cms.ab2d.worker.processor.coverage.CoverageVerificationException)1 List (java.util.List)1 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Assertions (org.junit.jupiter.api.Assertions)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 Mock (org.mockito.Mock)1