### Question:
NumberOfErrors implements ModelRunner { public static Set<Span> calculate(Graph graph) { TraceTraversal<Vertex, Vertex> errorSpansTraversal = graph.traversal(TraceTraversalSource.class) .hasTag(Tags.ERROR.getKey(), "true"); Set<Span> result = new LinkedHashSet<>(); while (errorSpansTraversal.hasNext()) { Vertex errorSpanVertex = errorSpansTraversal.next(); Span errorSpan = GraphCreator.toSpan(errorSpanVertex); result.add(errorSpan); } return result; }  @Override void runWithMetrics(Graph graph); static Set<Span> calculate(Graph graph);  }### Answer:
@Test public void testEmpty() { Assert.assertEquals(0, NumberOfErrors.calculate(GraphCreator.create(new Trace())).size()); }
@Test public void testCalculate() { Span root = Util.newTrace("root", "root"); root.tags.put(Tags.ERROR.getKey(), "true"); Span child = Util.newChild("root", "child", root); child.tags.put(Tags.ERROR.getKey(), "false"); Span childChild = Util.newChild("root", "child", child); child.tags.put(Tags.ERROR.getKey(), "true"); Trace trace = new Trace(); trace.spans.addAll(Arrays.asList(root, child, childChild)); Set<Span> errorSpans = NumberOfErrors.calculate(GraphCreator.create(trace)); Assert.assertEquals(2, errorSpans.size()); }