@Test
  public void testAlertFiresUnknownEvent() {
    // mock one area, leaving others to fail
    RequestDAO requestDAO = m_injector.getInstance(RequestDAO.class);
    expect(requestDAO.findAllRequestIds(EasyMock.anyInt(), EasyMock.anyBoolean())).andReturn(new ArrayList<>());

    replay(requestDAO);

    // instantiate and inject mocks
    AmbariPerformanceRunnable runnable = new AmbariPerformanceRunnable(
        m_definition.getDefinitionName());

    m_injector.injectMembers(runnable);

    // run the alert
    runnable.run();

    assertEquals(1,
        m_listener.getAlertEventReceivedCount(AlertReceivedEvent.class));

    List<AlertEvent> events = m_listener.getAlertEventInstances(AlertReceivedEvent.class);
    assertEquals(1, events.size());

    AlertReceivedEvent event = (AlertReceivedEvent) events.get(0);
    Alert alert = event.getAlert();
    assertEquals("AMBARI", alert.getService());
    assertEquals("AMBARI_SERVER", alert.getComponent());
    assertEquals(AlertState.UNKNOWN, alert.getState());
    assertEquals(DEFINITION_NAME, alert.getName());

    // verify that even though there is 1 UNKNOWN, there should also be 1 OK as
    // well
    assertTrue(alert.getText().contains("(OK)"));

    verify(m_cluster, m_clusters, m_definitionDao);
  }
Tests that the event is triggerd with a status of UNKNOWN.
ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java