@Test
  public void testAggregateAlertFirmness() throws Exception {
    AlertDefinitionEntity definition = new AlertDefinitionEntity();
    definition.setDefinitionName("aggregate-alert-firmness-test");
    definition.setServiceName("HDFS");
    definition.setComponentName("NAMENODE");
    definition.setClusterId(m_cluster.getClusterId());
    definition.setHash(UUID.randomUUID().toString());
    definition.setScheduleInterval(Integer.valueOf(60));
    definition.setScope(Scope.SERVICE);
    definition.setSource("{\"type\" : \"AGGREGATE\"}");
    definition.setSourceType(SourceType.AGGREGATE);

    // turn this up way high to ensure that we correctly short-circuit these
    // types of alerts and always consider them HARD
    definition.setRepeatTolerance(100);
    definition.setRepeatToleranceEnabled(true);

    m_definitionDao.create(definition);

    Alert alert = new Alert(definition.getDefinitionName(), null, definition.getServiceName(),
        definition.getComponentName(), HOST1, AlertState.OK);

    alert.setClusterId(m_cluster.getClusterId());
    alert.setLabel(ALERT_LABEL);
    alert.setText("Aggregate alerts are always HARD");
    alert.setTimestamp(1L);

    // fire the alert, and check that the new entry was created
    AlertReceivedListener listener = m_injector.getInstance(AlertReceivedListener.class);
    AlertReceivedEvent event = new AlertReceivedEvent(m_cluster.getClusterId(), alert);
    listener.onAlertEvent(event);

    List<AlertCurrentEntity> allCurrent = m_dao.findCurrent();
    assertEquals(AlertFirmness.HARD, allCurrent.get(0).getFirmness());

    // change state
    alert.setState(AlertState.CRITICAL);
    listener.onAlertEvent(event);
    allCurrent = m_dao.findCurrent();
    assertEquals(1, (long) allCurrent.get(0).getOccurrences());
    assertEquals(AlertFirmness.HARD, allCurrent.get(0).getFirmness());

    // change state
    alert.setState(AlertState.WARNING);
    listener.onAlertEvent(event);
    allCurrent = m_dao.findCurrent();
    assertEquals(2, (long) allCurrent.get(0).getOccurrences());
    assertEquals(AlertFirmness.HARD, allCurrent.get(0).getFirmness());

    // change state
    alert.setState(AlertState.OK);
    listener.onAlertEvent(event);
    allCurrent = m_dao.findCurrent();
    assertEquals(1, (long) allCurrent.get(0).getOccurrences());
    assertEquals(AlertFirmness.HARD, allCurrent.get(0).getFirmness());
  }
Tests that {@link SourceType#AGGREGATE} alerts are always HARD.
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertReceivedListenerTest.java