@Test
  public void testMergeCounter() throws Exception {
    final TableName tn = tableName.getTableName();
    final TableDescriptor tnDescriptor =
      TableDescriptorBuilder.newBuilder(tn).setNormalizationEnabled(true).build();
    when(masterServices.getTableDescriptors().get(tn)).thenReturn(tnDescriptor);
    when(masterServices.mergeRegions(any(), anyBoolean(), anyLong(), anyLong())).thenReturn(1L);
    when(regionNormalizer.computePlansForTable(tnDescriptor)).thenReturn(singletonList(
      new MergeNormalizationPlan.Builder().addTarget(RegionInfoBuilder.newBuilder(tn).build(), 10)
        .addTarget(RegionInfoBuilder.newBuilder(tn).build(), 20).build()));

    final RegionNormalizerWorker worker = new RegionNormalizerWorker(
      testingUtility.getConfiguration(), masterServices, regionNormalizer, queue);
    final long beforeMergePlanCount = worker.getMergePlanCount();
    workerPool.submit(worker);
    queue.put(tn);

    assertThatEventually("executing work should see plan count increase", worker::getMergePlanCount,
      greaterThan(beforeMergePlanCount));
  }
A test over {@link RegionNormalizerWorker}. Being a background thread, the only points of
interaction we have to this class are its input source ({@link RegionNormalizerWorkQueue} and its
callbacks invoked against {@link RegionNormalizer} and {@link MasterServices}. The work queue is
simple enough to use directly; for {@link MasterServices}, use a mock because, as of now, the
worker only invokes 4 methods.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/normalizer/TestRegionNormalizerWorker.java