@Test
  public void testSkippedAlertUpdatesTimestampAndText() throws AmbariException {
    String definitionName = ALERT_DEFINITION + "1";
    String serviceName = "HDFS";
    String componentName = "NAMENODE";
    String text = serviceName + " " + componentName + " is OK";

    Alert alert = new Alert(definitionName, null, serviceName, componentName, HOST1, AlertState.OK);

    alert.setClusterId(m_cluster.getClusterId());
    alert.setLabel(ALERT_LABEL);
    alert.setText(text);
    alert.setTimestamp(1L);

    // fire the alert, and check that the new entry was created with the right
    // timestamp
    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(1, allCurrent.size());

    // check timestamp
    assertEquals(1L, (long) allCurrent.get(0).getOriginalTimestamp());
    assertEquals(1L, (long) allCurrent.get(0).getLatestTimestamp());

    // update the timestamp and the state
    alert.setState(AlertState.SKIPPED);
    alert.setTimestamp(2L);

    // we should allow updating the text if the text is provided
    text = text + " Updated";
    alert.setText(text);

    // get the current make sure the fields were updated
    listener.onAlertEvent(event);
    allCurrent = m_dao.findCurrent();
    assertEquals(1L, (long) allCurrent.get(0).getOriginalTimestamp());
    assertEquals(2L, (long) allCurrent.get(0).getLatestTimestamp());
    assertEquals(text, allCurrent.get(0).getLatestText());

    // verify that blank text does not update
    alert.setText("");
    alert.setTimestamp(3L);

    // get the current make sure the text was not updated
    listener.onAlertEvent(event);
    allCurrent = m_dao.findCurrent();
    assertEquals(1L, (long) allCurrent.get(0).getOriginalTimestamp());
    assertEquals(3L, (long) allCurrent.get(0).getLatestTimestamp());
    assertEquals(text, allCurrent.get(0).getLatestText());
  }
Tests that receiving and alert with {@link AlertState#SKIPPED} does not
create an entry if there is currently no current alert.
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertReceivedListenerTest.java