@Test(timeout = DEFAULT_TIMEOUT)
  public void testWithoutListener() {
    // Given
    when(mockConf.get(HiveConf.ConfVars.LLAP_TASK_SCHEDULER_AM_COLLECT_DAEMON_METRICS_LISTENER.varname,
        HiveConf.ConfVars.LLAP_TASK_SCHEDULER_AM_COLLECT_DAEMON_METRICS_LISTENER.defaultStrVal)).thenReturn("");
    collector = new LlapMetricsCollector(mockConf, mockExecutor, mockClientFactory);

    LlapServiceInstance mockService1 = mock(LlapServiceInstance.class);
    when(mockService1.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    LlapServiceInstance mockService2 = mock(LlapServiceInstance.class);
    when(mockService2.getWorkerIdentity()).thenReturn(TEST_IDENTITY_2);

    // Check that there is no exception with start / create / remove / collect
    collector.start();
    collector.onCreate(mockService1, TEST_SEQ_VERSION);
    collector.onCreate(mockService2, TEST_SEQ_VERSION);
    collector.onRemove(mockService2, TEST_SEQ_VERSION);
    collector.collectMetrics();

    // Then
    assertNull(collector.listener);
  }
Check that the collector is working without the listener too.
llap-tez/src/test/org/apache/hadoop/hive/llap/tezplugins/metrics/TestLlapMetricsCollector.java