@Test
  @SuppressWarnings("unchecked")
  public void testRunnableWithFailedCallNullHelper() throws Exception {
    final String expectedHostName = "c6401.ambari.apache.org";
    final String expectedComponentName = "DATANODE";
    final String expectedClusterName = "clusterone";
    final String expectedComponentAndHostName = expectedComponentName + "+" + expectedHostName;

    EasyMockSupport mockSupport = new EasyMockSupport();

    LoggingRequestHelperFactory helperFactoryMock = mockSupport.createMock(LoggingRequestHelperFactory.class);
    AmbariManagementController controllerMock = mockSupport.createMock(AmbariManagementController.class);

    Cache<String, Set<String>> cacheMock = mockSupport.createMock(Cache.class);
    Set<String> currentRequestsMock = mockSupport.createMock(Set.class);
    Map<String, AtomicInteger> componentFailureCounts = mockSupport.createMock(Map.class);

    // return null to simulate an error during helper instance creation
    expect(helperFactoryMock.getHelper(controllerMock, expectedClusterName)).andReturn(null);
    // expect that the completed request is removed from the current request set,
    // even in the event of a failure to obtain the LogSearch data
    expect(currentRequestsMock.remove(expectedComponentAndHostName)).andReturn(true).once();

    mockSupport.replayAll();

    LogSearchDataRetrievalService.LogSearchFileNameRequestRunnable loggingRunnable =
      new LogSearchDataRetrievalService.LogSearchFileNameRequestRunnable(expectedHostName, expectedComponentName, expectedClusterName,
          cacheMock, currentRequestsMock, helperFactoryMock, componentFailureCounts, controllerMock);
    loggingRunnable.run();

    mockSupport.verifyAll();

  }
This test verifies the basic behavior of the
  LogSearchDataRetrievalServiceTest, and should
  verify the interaction with its dependencies, as
  well as the interaction with the LogSearch
  server.
ambari-server/src/test/java/org/apache/ambari/server/controller/logging/LogSearchDataRetrievalServiceTest.java