@Test
public void testDontDeleteIncidentIfThereAreNonOkResultsFromOtherInstances() {

	Check check = createCheckCheckingMean(2, 6);
	when(alertingPlugin.getChecks()).thenReturn(Collections.singletonMap(check.getId(), check));
	incidentRepository.createIncident(
			new Incident(check, new MeasurementSession("testApp", "testHost2", "testInstance"),
					Arrays.asList(new CheckResult("test", 10, CheckResult.Status.CRITICAL))));
	checkMetrics(7, 0, 0);
	verify(alerter, times(0)).alert(any(Alerter.AlertArguments.class));
	verify(incidentRepository).updateIncident(any(Incident.class));
	Incident storedIncident = incidentRepository.getIncidentByCheckId(check.getId());
	assertEquals(CheckResult.Status.CRITICAL, storedIncident.getOldStatus());
	assertEquals(CheckResult.Status.CRITICAL, storedIncident.getNewStatus());
	assertEquals(2, storedIncident.getCheckResults().size());
	assertEquals(2, storedIncident.getVersion());
	boolean containsTestHost = false;
	boolean containsTestHost2 = false;
	for (CheckResults checkResults : storedIncident.getCheckResults()) {
		if (checkResults.getMeasurementSession().getHostName().equals("testHost2")) {
			containsTestHost2 = true;
		} else if (checkResults.getMeasurementSession().getHostName().equals("testHost")) {
			containsTestHost = true;
		}
	}
	assertTrue(containsTestHost);
	assertTrue(containsTestHost2);
	System.out.println(storedIncident);
	System.out.println(JsonUtils.toJson(storedIncident));
	checkMetrics(1, 0, 0);
	verify(alerter, times(0)).alert(any(Alerter.AlertArguments.class));
	verify(incidentRepository, times(0)).deleteIncident(any(Incident.class));
	verify(incidentRepository, times(2)).updateIncident(any(Incident.class));
	storedIncident = incidentRepository.getIncidentByCheckId(check.getId());
	assertEquals(CheckResult.Status.CRITICAL, storedIncident.getOldStatus());
	assertEquals(CheckResult.Status.CRITICAL, storedIncident.getNewStatus());
	assertEquals(1, storedIncident.getCheckResults().size());
	assertEquals(3, storedIncident.getVersion());
}