/** * {@inheritDoc} */ @Override public List<Alert> getAlerts() { return alertRegistry.getAlerts(); }
/** * Returns all business transaction alerts in the registry. * * @return Returns all business transaction alerts in the registry. */ public List<Alert> getBusinessTransactionAlerts() { List<Alert> resultList = new ArrayList<>(); for (Alert alert : getAlerts()) { if (AlertingUtils.isBusinessTransactionAlert(alert.getAlertingDefinition())) { resultList.add(alert); } } return resultList; } }
@Test public void getAlerts() { Alert alertOne = Mockito.mock(Alert.class, Mockito.RETURNS_MOCKS); Alert alertTwo = Mockito.mock(Alert.class, Mockito.RETURNS_MOCKS); when(alertOne.getId()).thenReturn("id_1"); when(alertTwo.getId()).thenReturn("id_2"); alertRegistry.registerAlert(alertOne); alertRegistry.registerAlert(alertTwo); List<Alert> alerts = alertRegistry.getAlerts(); verify(alertOne, times(2)).getId(); verify(alertOne).getAlertingDefinition(); verify(alertTwo, times(2)).getId(); verify(alertTwo).getAlertingDefinition(); verifyNoMoreInteractions(alertOne, alertTwo); assertThat(alerts, hasSize(2)); assertThat(alerts, hasItems(alertOne, alertTwo)); } }