@Test(timeout = 2000)
  public void testCheckTime() throws Exception {
    Map<String, LlapMetrics> data = generateClusterMetrics();

    // Return that we can not yet blacklist a node
    long targetTime = System.currentTimeMillis() + 10000;
    when(mockRegistry.lockForConfigChange(anyLong(), anyLong())).thenReturn(
        new ConfigChangeLockResult(false, targetTime));
    listener.newClusterMetrics(data);

    verify(mockClient, never()).setCapacity(any(RpcController.class), any(SetCapacityRequestProto.class));
    assertEquals(targetTime, listener.nextCheckTime);

    // reset mock stuff
    reset(mockRegistry);
    when(mockRegistry.getInstances()).thenReturn(mockInstanceSet);

    // We will not try to set the capacity, or even lock until the time is reached
    listener.newClusterMetrics(data);
    verify(mockRegistry, never()).lockForConfigChange(anyLong(), anyLong());
    verify(mockClient, never()).setCapacity(any(RpcController.class), any(SetCapacityRequestProto.class));

    // If the time is reached, then we lock and blacklist
    listener.nextCheckTime = System.currentTimeMillis() - 1;
    when(mockRegistry.lockForConfigChange(anyLong(), anyLong())).thenReturn(
        new ConfigChangeLockResult(true, targetTime));
    listener.newClusterMetrics(data);

    ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(mockClient, times(1)).setCapacity(any(), any(SetCapacityRequestProto.class));
    verify(mockInstanceSet, times(1)).getInstance(argumentCaptor.capture());
    assertEquals("3", argumentCaptor.getValue());
  }
Test class to test BlacklistingLlapMetricsListener object.
llap-tez/src/test/org/apache/hadoop/hive/llap/tezplugins/metrics/TestBlacklistingLlapMetricsListener.java