@Test
  public void testAlertNotices() throws Exception {
    List<AlertNoticeEntity> notices = m_dispatchDao.findAllNotices();
    assertEquals( 0, notices.size() );

    List<AlertDefinitionEntity> definitions = m_definitionDao.findAll(m_cluster.getClusterId());
    AlertDefinitionEntity definition = definitions.get(0);

    AlertHistoryEntity history = new AlertHistoryEntity();
    history.setServiceName(definition.getServiceName());
    history.setClusterId(m_cluster.getClusterId());
    history.setAlertDefinition(definition);
    history.setAlertLabel(definition.getDefinitionName());
    history.setAlertText(definition.getDefinitionName());
    history.setAlertTimestamp(System.currentTimeMillis());
    history.setHostName(HOST1);
    history.setAlertState(AlertState.OK);
    m_dao.create(history);

    List<AlertHistoryEntity> histories = m_dao.findAll(m_cluster.getClusterId());
    assertEquals(1, histories.size());

    AlertCurrentEntity currentAlert = new AlertCurrentEntity();
    currentAlert.setAlertHistory(histories.get(0));
    currentAlert.setMaintenanceState(MaintenanceState.OFF);
    currentAlert.setOriginalTimestamp(System.currentTimeMillis());
    currentAlert.setLatestTimestamp(System.currentTimeMillis());
    m_dao.create(currentAlert);

    AlertTargetEntity target = m_helper.createAlertTarget();
    Set<AlertTargetEntity> targets = new HashSet<>();
    targets.add(target);

    AlertGroupEntity group = m_helper.createAlertGroup(
        m_cluster.getClusterId(), targets);
    group.addAlertDefinition( definitions.get(0) );
    m_dispatchDao.merge(group);

    Alert alert1 = new Alert(ALERT_DEFINITION, null, SERVICE, COMPONENT, HOST1,
        AlertState.OK);

    AlertStateChangeEvent event = new AlertStateChangeEvent(
        m_cluster.getClusterId(), alert1,
        currentAlert, AlertState.CRITICAL, AlertFirmness.HARD);

    AlertStateChangedListener listener = m_injector.getInstance(AlertStateChangedListener.class);
    listener.onAlertEvent(event);

    notices = m_dispatchDao.findAllNotices();
    assertEquals(1, notices.size());
  }
Tests that {@link AlertStateChangeEvent} cause an {@link AlertNoticeEntity}
entry.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/AlertDataManagerTest.java