AlertService { public List<Stat> getStatNoTypeChange(final String from) { final Collection<Alert> alerts = this.getAlerts(from); final Stat.StatBuilder stat = new Stat.StatBuilder(); for (final Alert a : alerts) { if (a.getFromType() == a.getToType()) { stat.increment(a.getAlarmId(), a.getToType()); } else { stat.removeAndIgnore(a.getAlarmId()); } } return stat.build(); }  Alert.Alerts getAlerts(); Alert.Alerts getAlerts(final int nbItem); Alert.Alerts getAlerts(final int nbItem, final int start); List<Stat> getStatNoTypeChange(final String from); List<Stat> getStatTypeChange(final String from); Collection<Alert> getAlerts(final String from); Alert.Alerts getAlarmAlerts(final String id); static final int DEFAULT_NB_ITEMS_ALERTS; }
@Test public void getStatNoTypeChangeTest() throws Exception { final Alert.Alerts alerts = new Alerts(); final List<Alert> listAlerts = new ArrayList<>(); Alert alert = TestUtils.getDefaultAlert(); alert.setTimestamp(Instant.now().minus(30, ChronoUnit.DAYS)); listAlerts.add(alert); alert = TestUtils.getDefaultAlert(); alert.setFromType(alert.getToType()); listAlerts.add(alert); alert = TestUtils.getDefaultAlertNoChanged(); alert.setTimestamp(Instant.now().minus(30, ChronoUnit.DAYS)); listAlerts.add(alert); alert = TestUtils.getDefaultAlertNoChanged(); alert.setFromType(alert.getToType()); listAlerts.add(alert); alerts.setValues(listAlerts); when(seyrenRepository.getAlerts(0, 50)).thenReturn(alerts); final List<Stat> statsM = service.getStatNoTypeChange("2m"); final List<Stat> statsD = service.getStatNoTypeChange("2d"); final List<Stat> statsH = service.getStatNoTypeChange("2h"); assertNotNull(statsM); assertNotNull(statsD); assertNotNull(statsH); assertEquals(statsM.size(), 0); assertEquals(statsD.size(), 0); assertEquals(statsH.size(), 0); }