### Question:
Metrics implements Serializable { public Metrics merge(Metrics that) { this.writeVertex.merge(that.writeVertex); this.writeEdge.merge(that.writeEdge); this.batchCommit.merge(that.batchCommit); this.readVertex.merge(that.readVertex); this.readEdge.merge(that.readEdge); this.subgraph.merge(that.subgraph); this.subgraphVertexCount.addAndGet(that.subgraphVertexCount.get()); this.subgraphEdgeCount.addAndGet(that.subgraphEdgeCount.get()); this.subgraphWithEdgesCount.addAndGet(that.subgraphWithEdgesCount.get()); return this; } Metrics(); void printOut(OutputStream out); void collectMetrics(JsonMetricsOutput jsonOutput, LatencyHistogram m); Metrics merge(Metrics that); public LatencyHistogram writeVertex; public LatencyHistogram writeEdge; public LatencyHistogram batchCommit; public LatencyHistogram readVertex; public LatencyHistogram readEdge; public LatencyHistogram subgraph; public AtomicLong subgraphVertexCount; public AtomicLong subgraphEdgeCount; public AtomicLong subgraphWithEdgesCount; }### Answer:
@Test public void testMerge() throws IOException { Metrics m = new Metrics(); Metrics m2 = new Metrics(); m2.writeVertex.measure(1L); m.merge(m2); JsonMetricsOutput export = new JsonMetricsOutput(); m.writeVertex.printout(export); JsonObject category = export.getJson().getAsJsonObject("write.vertex"); assertEquals(category.get("Operations").getAsString(), "1"); assertEquals(category.get("Min(us)").getAsString(), "0.001"); assertEquals(category.get("Max(us)").getAsString(), "0.001"); }