@Test public void shouldHandleSchedulerException() throws SchedulerException { List<String> schedulesToProbe = Arrays.asList("schedule1", "schedule2"); when(diagnosticsContext.get("SCHEDULE_LIST_TO_PROBE")).thenReturn(schedulesToProbe); when(schedulerDiagnosticsService.diagnoseSchedules(schedulesToProbe, diagnosticsLogger)) .thenThrow(new SchedulerException("my scheduler exception")); expectedException.expect(RuntimeException.class); expectedException.expectMessage("my scheduler exception"); schedulerProbe.diagnose(diagnosticsContext, diagnosticsLogger); }
@Test public void shouldInvokeServiceWithSchedulesToProbe() throws SchedulerException { List<String> schedulesToProbe = Arrays.asList("schedule1", "schedule2"); when(diagnosticsContext.get("SCHEDULE_LIST_TO_PROBE")).thenReturn(schedulesToProbe); when(schedulerDiagnosticsService.diagnoseSchedules(schedulesToProbe, diagnosticsLogger)) .thenReturn(DiagnosticsStatus.PASS); assertEquals( DiagnosticsStatus.PASS, schedulerProbe.diagnose(diagnosticsContext, diagnosticsLogger)); when(schedulerDiagnosticsService.diagnoseSchedules(schedulesToProbe, diagnosticsLogger)) .thenReturn(DiagnosticsStatus.FAIL); assertEquals( DiagnosticsStatus.FAIL, schedulerProbe.diagnose(diagnosticsContext, diagnosticsLogger)); when(schedulerDiagnosticsService.diagnoseSchedules(schedulesToProbe, diagnosticsLogger)) .thenReturn(DiagnosticsStatus.UNKNOWN); assertEquals( DiagnosticsStatus.UNKNOWN, schedulerProbe.diagnose(diagnosticsContext, diagnosticsLogger)); }