@Before
  public void setUp() throws Exception {
    initMocks(this);

    conf = new HiveConf();
    when(mockRegistry.getInstances()).thenReturn(mockInstanceSet);
    when(mockRegistry.lockForConfigChange(anyLong(), anyLong())).thenReturn(
        new ConfigChangeLockResult(true, Long.MIN_VALUE));
    when(mockRegistry.getInstances().getInstance(anyString())).thenReturn(mockLlapServiceInstance);
    when(mockClientFactory.create(any(LlapServiceInstance.class))).thenReturn(mockClient);
    when(mockClient.setCapacity(
        any(),
        any(SetCapacityRequestProto.class))).thenReturn(TEST_RESPONSE);

    listener = new BlacklistingLlapMetricsListener();
    listener.init(conf, mockRegistry, mockClientFactory);
  }
Test class to test BlacklistingLlapMetricsListener object.
llap-tez/src/test/org/apache/hadoop/hive/llap/tezplugins/metrics/TestBlacklistingLlapMetricsListener.java