use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class CoverageDriverUnitTest method whenLockInterruptedPropagateException.
@DisplayName("When locking is interrupted propagate exception")
@Test
void whenLockInterruptedPropagateException() {
when(lockWrapper.getCoverageLock()).thenReturn(tryLockInterrupt);
Properties monthsProp = new Properties();
monthsProp.setValue("3");
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_UPDATE_MONTHS))).thenReturn(monthsProp);
Properties stuckProp = new Properties();
stuckProp.setValue("72");
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_STUCK_HOURS))).thenReturn(stuckProp);
Properties overrideProp = new Properties();
overrideProp.setValue("false");
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_OVERRIDE))).thenReturn(overrideProp);
ContractDTO contract = new ContractDTO("contractNum", null, null, null);
Job job = new Job();
job.setContractNumber(contract.getContractNumber());
CoverageDriver driver = new CoverageDriverImpl(null, null, coverageService, propertiesService, null, lockWrapper, null);
assertThrows(InterruptedException.class, driver::discoverCoveragePeriods);
assertThrows(InterruptedException.class, driver::queueStaleCoveragePeriods);
assertThrows(InterruptedException.class, () -> driver.isCoverageAvailable(job, contract));
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method engagedSearchNotTuesdayAtMidnightDoesNotFire.
@DisplayName("Engaging coverage search works")
@Test
void engagedSearchNotTuesdayAtMidnightDoesNotFire() {
PropertiesService propertiesService = mock(PropertiesService.class);
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_DISCOVERY))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_DISCOVERY);
engaged.setValue("engaged");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_QUEUEING))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_QUEUEING);
engaged.setValue("engaged");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(COVERAGE_SEARCH_OVERRIDE))).thenAnswer((arg) -> {
Properties override = new Properties();
override.setKey(COVERAGE_SEARCH_OVERRIDE);
override.setValue("false");
return override;
});
CoverageDriverStub coverageDriverStub = new CoverageDriverStub();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverStub, propertiesService, logManager);
try {
quartzJob.executeInternal(null);
assertTrue(coverageDriverStub.discoveryCalled);
OffsetDateTime date = OffsetDateTime.now(AB2D_ZONE);
if (date.getDayOfWeek() == DayOfWeek.TUESDAY && date.getHour() == 0) {
assertTrue(coverageDriverStub.queueingCalled);
} else {
assertFalse(coverageDriverStub.queueingCalled);
}
} catch (JobExecutionException jobExecutionException) {
fail("could not execute normally", jobExecutionException);
}
}
use of gov.cms.ab2d.common.model.Properties in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method disengageSearchWorks.
@DisplayName("Disengaging coverage search works")
@Test
void disengageSearchWorks() {
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_DISCOVERY))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_DISCOVERY);
engaged.setValue("idle");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(Constants.COVERAGE_SEARCH_QUEUEING))).thenAnswer((arg) -> {
Properties engaged = new Properties();
engaged.setKey(Constants.COVERAGE_SEARCH_QUEUEING);
engaged.setValue("idle");
return engaged;
});
when(propertiesService.getPropertiesByKey(eq(COVERAGE_SEARCH_OVERRIDE))).thenAnswer((arg) -> {
Properties override = new Properties();
override.setKey(COVERAGE_SEARCH_OVERRIDE);
override.setValue("true");
return override;
});
CoverageDriverStub coverageDriverStub = new CoverageDriverStub();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverStub, propertiesService, logManager);
try {
quartzJob.executeInternal(null);
assertFalse(coverageDriverStub.discoveryCalled);
assertFalse(coverageDriverStub.queueingCalled);
} catch (JobExecutionException jobExecutionException) {
// Exception never thrown by stubbed method
}
}
Aggregations