### Question:
ReplicationMetrics extends MasterMetrics { protected void addReplicationQueueTimeMetrics() { Set<Path> paths = replicationUtil.getPendingReplicationPaths(); long currentTime = getCurrentTime(); for (Path path : paths) { if (!pathModTimes.containsKey(path)) { try { pathModTimes.put(path, master.getVolumeManager().getFileStatus(path).getModificationTime()); } catch (IOException e) { log.trace( "Failed to get file status for {}, file system is unavailable or it does not exist", path); } } } Set<Path> deletedPaths = new HashSet<>(pathModTimes.keySet()); deletedPaths.removeAll(paths); if (deletedPaths.isEmpty()) { return; } replicationQueueTimeStat.resetMinMax(); for (Path path : deletedPaths) { Long modTime = pathModTimes.remove(path); if (modTime != null) { long diff = Math.max(0, currentTime - modTime); replicationQueueTimeQuantiles.add(diff); replicationQueueTimeStat.add(diff); } } } ReplicationMetrics(Master master);   }### Answer:
@Test public void testAddReplicationQueueTimeMetrics() throws Exception { Master master = EasyMock.createMock(Master.class); ServerContext context = EasyMock.createMock(ServerContext.class); VolumeManager fileSystem = EasyMock.createMock(VolumeManager.class); ReplicationUtil util = EasyMock.createMock(ReplicationUtil.class); MutableStat stat = EasyMock.createMock(MutableStat.class); MutableQuantiles quantiles = EasyMock.createMock(MutableQuantiles.class); Path path1 = new Path("hdfs: Path path2 = new Path("hdfs: EasyMock.expect(master.getContext()).andReturn(context).anyTimes(); EasyMock.expect(util.getPendingReplicationPaths()).andReturn(Set.of(path1, path2)); EasyMock.expect(master.getVolumeManager()).andReturn(fileSystem); EasyMock.expect(fileSystem.getFileStatus(path1)).andReturn(createStatus(100)); EasyMock.expect(master.getVolumeManager()).andReturn(fileSystem); EasyMock.expect(fileSystem.getFileStatus(path2)).andReturn(createStatus(200)); EasyMock.expect(util.getPendingReplicationPaths()).andReturn(Set.of(path2)); stat.resetMinMax(); EasyMock.expectLastCall(); quantiles.add(currentTime - 100); EasyMock.expectLastCall(); stat.add(currentTime - 100); EasyMock.expectLastCall(); EasyMock.replay(master, fileSystem, util, stat, quantiles); ReplicationMetrics metrics = new ReplicationMetricsTestMetrics(master); replaceField(metrics, "replicationUtil", util); replaceField(metrics, "replicationQueueTimeQuantiles", quantiles); replaceField(metrics, "replicationQueueTimeStat", stat); metrics.addReplicationQueueTimeMetrics(); metrics.addReplicationQueueTimeMetrics(); EasyMock.verify(master, fileSystem, util, stat, quantiles); }