Search in sources :

Example 1 with CoveragePeriod

use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.

the class CoverageDriverTest method discoverCoveragePeriodsIgnoresTestContracts.

@DisplayName("Ignore contracts marked test")
@Test
void discoverCoveragePeriodsIgnoresTestContracts() {
    Contract testContract = dataSetup.setupContract("TST-AFTER-EPOCH", AB2D_EPOCH.toOffsetDateTime().plusMonths(3));
    testContract.setUpdateMode(Contract.UpdateMode.NONE);
    contractRepo.saveAndFlush(testContract);
    try {
        driver.discoverCoveragePeriods();
    } catch (CoverageDriverException | InterruptedException exception) {
        fail("could not queue periods due to driver exception", exception);
    }
    List<CoveragePeriod> periods = coveragePeriodRepo.findAllByContractNumber(testContract.getContractNumber());
    assertTrue(periods.isEmpty());
}
Also used : CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) Contract(gov.cms.ab2d.common.model.Contract) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with CoveragePeriod

use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.

the class CoverageDriverTest method availableCoverageWhenAllSuccessful.

@DisplayName("Do start an eob job if all coverage periods are in progress")
@Test
void availableCoverageWhenAllSuccessful() {
    Job job = new Job();
    job.setContractNumber(contractForCoverageDTO.getContractNumber());
    job.setCreatedAt(OffsetDateTime.now());
    try {
        changeStatus(contractForCoverageDTO, AB2D_EPOCH.toOffsetDateTime(), CoverageJobStatus.SUCCESSFUL);
        // Make sure that there is a lastSuccessfulJob
        ZonedDateTime now = ZonedDateTime.now(AB2D_ZONE);
        CoveragePeriod currentMonth = coverageService.getCoveragePeriod(contractForCoverageDTO, now.getMonthValue(), now.getYear());
        currentMonth.setLastSuccessfulJob(OffsetDateTime.now().plusHours(2));
        currentMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
        coveragePeriodRepo.saveAndFlush(currentMonth);
        boolean submittedCoverageStatus = driver.isCoverageAvailable(job, contract.toDTO());
        assertTrue(submittedCoverageStatus, "eob searches should not run if a " + "coverage period is submitted");
    } catch (InterruptedException | CoverageDriverException exception) {
        fail("could not check for available coverage", exception);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) Job(gov.cms.ab2d.common.model.Job) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with CoveragePeriod

use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.

the class CoverageDriverTest method changeStatus.

private void changeStatus(ContractForCoverageDTO contract, OffsetDateTime attestationTime, CoverageJobStatus status) {
    OffsetDateTime now = OffsetDateTime.now();
    while (attestationTime.isBefore(now)) {
        CoveragePeriod period = coverageService.getCreateIfAbsentCoveragePeriod(contract, attestationTime.getMonthValue(), attestationTime.getYear());
        period.setStatus(status);
        if (status == CoverageJobStatus.SUCCESSFUL) {
            period.setLastSuccessfulJob(now);
        }
        coveragePeriodRepo.saveAndFlush(period);
        attestationTime = attestationTime.plusMonths(1);
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod)

Example 4 with CoveragePeriod

use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.

the class CoverageDriverTest method availableCoverageWhenPeriodInProgress.

@DisplayName("Do not start an eob job if any relevant coverage period is being updated")
@Test
void availableCoverageWhenPeriodInProgress() {
    Job job = new Job();
    job.setContractNumber(contract.getContractNumber());
    job.setCreatedAt(OffsetDateTime.now());
    try {
        changeStatus(contractForCoverageDTO, AB2D_EPOCH.toOffsetDateTime(), CoverageJobStatus.IN_PROGRESS);
        // Make sure that there is a lastSuccessfulJob
        ZonedDateTime now = ZonedDateTime.now(AB2D_ZONE);
        CoveragePeriod currentMonth = coverageService.getCoveragePeriod(contractForCoverageDTO, now.getMonthValue(), now.getYear());
        currentMonth.setLastSuccessfulJob(OffsetDateTime.now().plusHours(2));
        currentMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
        coveragePeriodRepo.saveAndFlush(currentMonth);
        boolean inProgressCoverageStatus = driver.isCoverageAvailable(job, contract.toDTO());
        assertFalse(inProgressCoverageStatus, "eob searches should not run when a coverage period is in progress");
    } catch (InterruptedException | CoverageDriverException exception) {
        fail("could not check for available coverage", exception);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) Job(gov.cms.ab2d.common.model.Job) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with CoveragePeriod

use of gov.cms.ab2d.coverage.model.CoveragePeriod in project ab2d by CMSgov.

the class CoverageDriverTest method availableCoverageWhenPeriodSubmitted.

@DisplayName("Do not start an eob job if any relevant coverage period is queued for an update")
@Test
void availableCoverageWhenPeriodSubmitted() {
    Job job = new Job();
    job.setContractNumber(contractForCoverageDTO.getContractNumber());
    job.setCreatedAt(OffsetDateTime.now());
    try {
        changeStatus(contractForCoverageDTO, AB2D_EPOCH.toOffsetDateTime(), CoverageJobStatus.SUBMITTED);
        // Make sure that there is a lastSuccessfulJob
        ZonedDateTime now = ZonedDateTime.now(AB2D_ZONE);
        CoveragePeriod currentMonth = coverageService.getCoveragePeriod(contractForCoverageDTO, now.getMonthValue(), now.getYear());
        currentMonth.setLastSuccessfulJob(OffsetDateTime.now().plusHours(2));
        currentMonth.setStatus(CoverageJobStatus.SUCCESSFUL);
        coveragePeriodRepo.saveAndFlush(currentMonth);
        boolean submittedCoverageStatus = driver.isCoverageAvailable(job, contract.toDTO());
        assertFalse(submittedCoverageStatus, "eob searches should not run if a " + "coverage period is submitted");
    } catch (InterruptedException | CoverageDriverException exception) {
        fail("could not check for available coverage", exception);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) Job(gov.cms.ab2d.common.model.Job) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)62 Test (org.junit.jupiter.api.Test)40 DisplayName (org.junit.jupiter.api.DisplayName)38 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)22 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)20 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)19 OffsetDateTime (java.time.OffsetDateTime)18 CoverageJobStatus (gov.cms.ab2d.coverage.model.CoverageJobStatus)15 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)15 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)14 ContractForCoverageDTO (gov.cms.ab2d.coverage.model.ContractForCoverageDTO)12 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)11 ZonedDateTime (java.time.ZonedDateTime)11 ArrayList (java.util.ArrayList)11 LinkedHashSet (java.util.LinkedHashSet)11 Job (gov.cms.ab2d.common.model.Job)10 AB2D_EPOCH (gov.cms.ab2d.common.util.DateUtil.AB2D_EPOCH)9 CoveragePagingRequest (gov.cms.ab2d.coverage.model.CoveragePagingRequest)9 CoveragePagingResult (gov.cms.ab2d.coverage.model.CoveragePagingResult)9