@Test
  public void testAtlasDumpMetrics() throws Exception {
    Mockito.when(work.getMetricCollector()).thenReturn(metricCollector);
    Mockito.when(conf.get(HiveConf.ConfVars.REPL_ATLAS_ENDPOINT.varname)).thenReturn("http://localhost:21000/atlas");
    Mockito.when(conf.get(HiveConf.ConfVars.REPL_ATLAS_REPLICATED_TO_DB.varname)).thenReturn("tgtDb");
    Mockito.when(conf.get(HiveConf.ConfVars.REPL_SOURCE_CLUSTER_NAME.varname)).thenReturn("srcCluster");
    Mockito.when(conf.get(HiveConf.ConfVars.REPL_TARGET_CLUSTER_NAME.varname)).thenReturn("tgtCluster");
    Mockito.when(conf.get(ReplUtils.DEFAULT_FS_CONFIG)).thenReturn("hdfs:tgtFsUri:8020");
    Mockito.when(work.getStagingDir()).thenReturn(new Path("hdfs://tmp:8020/staging"));
    Mockito.when(work.getSrcDB()).thenReturn("srcDB");
    Mockito.when(work.isBootstrap()).thenReturn(true);
    atlasDumpTask = new AtlasDumpTask(atlasRestClient, conf, work);
    AtlasDumpTask atlasDumpTaskSpy = Mockito.spy(atlasDumpTask);
    Mockito.when(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST_REPL)).thenReturn(true);
    Logger logger = LoggerFactory.getLogger("ReplState");
    StringAppender appender = StringAppender.createStringAppender(null);
    appender.addToLogger(logger.getName(), Level.INFO);
    appender.start();
    Mockito.doReturn(0L).when(atlasDumpTaskSpy)
            .dumpAtlasMetaData(Mockito.any(AtlasRequestBuilder.class), Mockito.any(AtlasReplInfo.class));
    Mockito.doNothing().when(atlasDumpTaskSpy).createDumpMetadata(Mockito.any(AtlasReplInfo.class),
            Mockito.any(Long.class));
    int status = atlasDumpTaskSpy.execute();
    Assert.assertEquals(0, status);
    String logStr = appender.getOutput();
    Assert.assertEquals(2, StringUtils.countMatches(logStr, "REPL::"));
    Assert.assertTrue(logStr.contains("ATLAS_DUMP_START"));
    Assert.assertTrue(logStr.contains("ATLAS_DUMP_END"));
    Assert.assertTrue(logStr.contains("{\"dbName\":\"srcDB\",\"dumpStartTime"));
    Assert.assertTrue(logStr.contains("{\"dbName\":\"srcDB\",\"dumpEndTime\""));
    appender.removeFromLogger(logger.getName());
  }
Unit test class for testing Atlas metadata Dump.
ql/src/test/org/apache/hadoop/hive/ql/exec/repl/TestAtlasDumpTask.java