@Test
  public void testServiceIsEnabled() throws Exception {
    Configuration configuration = m_injector.getInstance(Configuration.class);
    EasyMock.expect(configuration.isAlertCacheEnabled()).andReturn(Boolean.TRUE).atLeastOnce();

    AlertsDAO alertsDAO = m_injector.getInstance(AlertsDAO.class);
    alertsDAO.flushCachedEntitiesToJPA();
    EasyMock.expectLastCall().once();

    // mock the stopAsync method
    CachedAlertFlushService service = PowerMockito.spy(new CachedAlertFlushService());
    PowerMockito.doReturn(null).when(service).stopAsync();

    replayAll();

    m_injector.injectMembers(service);
    service.startUp();
    service.runOneIteration();

    PowerMockito.verifyPrivate(service, new Times(0)).invoke("stopAsync");
    verifyAll();
  }
Tests that the flush service runs and flushes if it's enabled.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/services/CachedAlertFlushServiceTest.java