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

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

    replayAll();

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

    PowerMockito.verifyPrivate(service).invoke("stopAsync");
    verifyAll();
  }
Tests that the flush service does not run if caching is disabled.

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