### Question:
UniqueSpanId implements ModelRunner { public static Map<String, List<Span>> computeScore(Graph graph) { TraceTraversal<Vertex, Map<Object, Object>> by = Util.traceTraversal(graph).V() .group().by(Keys.SPAN_ID); Map<String, List<Span>> result = new LinkedHashMap<>(); while (by.hasNext()) { Map<Object, Object> map = by.next(); for (Map.Entry<Object, Object> entry: map.entrySet()) { Collection<Vertex> vertices = (Collection<Vertex>) entry.getValue(); String id = (String) entry.getKey(); List<Span> spans = result.get(id); if (spans == null) { spans = new ArrayList<>(vertices.size()); result.put(id, spans); } for (Vertex vertex: vertices) { Span span = GraphCreator.toSpan(vertex); spans.add(span); } } } return result; }  @Override void runWithMetrics(Graph graph); static Map<String, List<Span>> computeScore(Graph graph);  }### Answer:
@Test public void empty() { Map<String, List<Span>> result = UniqueSpanId.computeScore(GraphCreator.create(new Trace())); Assert.assertTrue(result.isEmpty()); }
@Test public void uniqueSpan() { Span root = Util.newTrace("foo", "op"); Span child = Util.newChild("foo", "op2", root); Span child2 = Util.newChild("foo", "op23", root); child.spanId = root.spanId; Trace trace = new Trace(); trace.spans = Arrays.asList(root, child, child2); Graph graph = GraphCreator.create(trace); Map<String, List<Span>> result = UniqueSpanId.computeScore(graph); Assert.assertEquals(2, result.size()); Assert.assertEquals(2, result.get(root.spanId).size()); Assert.assertEquals(1, result.get(child2.spanId).size()); }