SlaCheckerService { void checkForIncidents() { logger.debug("Checking for SLA incident"); SlaIncident openIncident = slaIncidentRepository.findFirstByClosedDateIsNull(); if (openIncident != null) { checkWithOpenIncident(openIncident); } else { checkWithNoOpenIncident(); } }    }
@Test public void testCheckForIncidents() { SlaIncident openIncident = mock(SlaIncident.class); doReturn(openIncident).when(slaIncidentRepository).findFirstByClosedDateIsNull(); doNothing().when(slaCheckerService).checkWithOpenIncident(openIncident); slaCheckerService.checkForIncidents(); verify(slaCheckerService).checkWithOpenIncident(openIncident); }