Incidents { static boolean findFailure(IncidentTree r) { return mlist(r.getIncidents()).exists(isFailure) || mlist(r.getDescendants()).exists(findFailureFn); } Incidents(ServiceRegistry sr, IncidentService is); void record(Job job, Severity severity, int code, Map<String, String> params,
          List<Tuple<String, String>> details); void record(Job job, Severity severity, int code); void recordFailure(Job job, int code, Map<String, String> params); void recordFailure(Job job, int code, Throwable t, Map<String, String> params,
          List<Tuple<String, String>> details); void recordJobCreationIncident(Job job, Throwable t); void unhandledException(Job job, Severity severity, Throwable t); void unhandledException(long jobId, Severity severity, Throwable t); boolean alreadyRecordedFailureIncident(long jobId); static final Map<String, String> NO_PARAMS; static final List<Tuple<String, String>> NO_DETAILS; }
@Test public void testFindFailure1() { final IncidentTree r = new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.WARNING), mkIncident(Severity.FAILURE)), Collections.emptyList()))))); assertTrue(Incidents.findFailure(r)); }
@Test public void testFindFailure2() { final IncidentTree r = new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.INFO), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Collections.emptyList()))))); assertFalse(Incidents.findFailure(r)); }
@Test public void testFindFailure3() { final IncidentTree r = new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.FAILURE), mkIncident(Severity.INFO), mkIncident(Severity.INFO)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.INFO), mkIncident(Severity.WARNING)), Collections.singletonList(new IncidentTreeImpl( Arrays.asList(mkIncident(Severity.WARNING), mkIncident(Severity.INFO)), Collections.emptyList()))))); assertTrue(Incidents.findFailure(r)); }