@Test(timeout = DEFAULT_TIMEOUT)
  public void testListener() {
    // Given
    LlapServiceInstance mockService1 = mock(LlapServiceInstance.class);
    when(mockService1.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    LlapServiceInstance mockService2 = mock(LlapServiceInstance.class);
    when(mockService2.getWorkerIdentity()).thenReturn(TEST_IDENTITY_2);

    // When
    collector.onCreate(mockService1, TEST_SEQ_VERSION);
    collector.onCreate(mockService2, TEST_SEQ_VERSION);
    collector.collectMetrics();
    collector.collectMetrics();
    collector.collectMetrics();

    // Then
    assertNotNull(collector.listener);
    assertEquals(1, ((MockListener)collector.listener).initCount);
    assertEquals(3, ((MockListener)collector.listener).fullMetricsCount);
    assertEquals(6, ((MockListener)collector.listener).daemonMetricsCount);
  }
Check that the listener is created and called. The default config contains the mock listener.
llap-tez/src/test/org/apache/hadoop/hive/llap/tezplugins/metrics/TestLlapMetricsCollector.java