### Question:
TracezDataAggregator { List<SpanData> getErrorSpans(String spanName) { Map<String, TracezSpanBuckets> completedSpanCache = spanProcessor.getCompletedSpanCache(); TracezSpanBuckets buckets = completedSpanCache.get(spanName); if (buckets == null) { return Collections.emptyList(); } Collection<ReadableSpan> allErrorSpans = buckets.getErrorSpans(); List<SpanData> errorSpans = new ArrayList<>(); for (ReadableSpan span : allErrorSpans) { errorSpans.add(span.toSpanData()); } return Collections.unmodifiableList(errorSpans); } TracezDataAggregator(TracezSpanProcessor spanProcessor);   }### Answer:
@Test void getErrorSpans_noSpans() { assertThat(dataAggregator.getErrorSpans(SPAN_NAME_ONE)).isEmpty(); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_TWO)).isEmpty(); }
@Test void getErrorSpans_oneSpanNameWithDifferentErrors() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_ONE)).isEmpty(); span1.setStatus(StatusCanonicalCode.ERROR); span1.end(); span2.setStatus(StatusCanonicalCode.ERROR, "ABORTED"); span2.end(); List<SpanData> errorSpans = dataAggregator.getErrorSpans(SPAN_NAME_ONE); assertThat(errorSpans) .containsExactly(((ReadableSpan) span1).toSpanData(), ((ReadableSpan) span2).toSpanData()); }
@Test void getErrorSpans_twoSpanNames() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_TWO).startSpan(); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_ONE)).isEmpty(); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_TWO)).isEmpty(); span1.setStatus(StatusCanonicalCode.ERROR); span1.end(); span2.setStatus(StatusCanonicalCode.ERROR); span2.end(); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_ONE)) .containsExactly(((ReadableSpan) span1).toSpanData()); assertThat(dataAggregator.getErrorSpans(SPAN_NAME_TWO)) .containsExactly(((ReadableSpan) span2).toSpanData()); }