use of gov.cms.ab2d.common.service.PropertiesService 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());
}
use of gov.cms.ab2d.common.service.PropertiesService in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method engageSearchWorks.
@DisplayName("Engaging coverage search works")
@Test
void engageSearchWorks() {
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("true");
return override;
});
CoverageDriverStub coverageDriverStub = new CoverageDriverStub();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverStub, propertiesService, logManager);
try {
quartzJob.executeInternal(null);
assertTrue(coverageDriverStub.discoveryCalled);
assertTrue(coverageDriverStub.queueingCalled);
} catch (JobExecutionException jobExecutionException) {
fail("could not execute normally", jobExecutionException);
}
}
use of gov.cms.ab2d.common.service.PropertiesService in project ab2d by CMSgov.
the class CoveragePeriodQuartzJobTest method failingSearchesTriggerAlerts.
@DisplayName("Failing searches trigger alerts")
@Test
void failingSearchesTriggerAlerts() {
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(COVERAGE_SEARCH_OVERRIDE))).thenAnswer((arg) -> {
Properties override = new Properties();
override.setKey(COVERAGE_SEARCH_OVERRIDE);
override.setValue("true");
return override;
});
try {
doThrow(new RuntimeException("testing123")).when(coverageDriverMock).discoverCoveragePeriods();
CoveragePeriodQuartzJob quartzJob = new CoveragePeriodQuartzJob(coverageDriverMock, propertiesService, logManager);
JobExecutionException exception = assertThrows(JobExecutionException.class, () -> quartzJob.executeInternal(null));
assertTrue(exception.getMessage().contains("testing123"));
verify(logManager, times(1)).alert(contains("coverage period updates could not be conducted"), anyList());
} catch (Exception ex) {
fail("could not execute test due to interruption", ex);
}
}
use of gov.cms.ab2d.common.service.PropertiesService 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);
}
}
Aggregations