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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations