### Question:
TracezDataAggregator { Map<String, Integer> getRunningSpanCounts() { Collection<ReadableSpan> allRunningSpans = spanProcessor.getRunningSpans(); Map<String, Integer> numSpansPerName = new HashMap<>(); for (ReadableSpan span : allRunningSpans) { Integer prevValue = numSpansPerName.get(span.getName()); numSpansPerName.put(span.getName(), prevValue != null ? prevValue + 1 : 1); } return numSpansPerName; } TracezDataAggregator(TracezSpanProcessor spanProcessor);   }### Answer:
@Test void getRunningSpanCounts_noSpans() { Map<String, Integer> counts = dataAggregator.getRunningSpanCounts(); assertThat(counts).isEmpty(); }
@Test void getRunningSpanCounts_oneSpanName() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span3 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Map<String, Integer> counts = dataAggregator.getRunningSpanCounts(); assertThat(counts.get(SPAN_NAME_ONE)).isEqualTo(3); span1.end(); span2.end(); span3.end(); counts = dataAggregator.getRunningSpanCounts(); assertThat(counts).isEmpty(); }
@Test void getRunningSpanCounts_twoSpanNames() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_TWO).startSpan(); Map<String, Integer> counts = dataAggregator.getRunningSpanCounts(); assertThat(counts.get(SPAN_NAME_ONE)).isEqualTo(1); assertThat(counts.get(SPAN_NAME_TWO)).isEqualTo(1); span1.end(); counts = dataAggregator.getRunningSpanCounts(); assertThat(counts.get(SPAN_NAME_ONE)).isNull(); assertThat(counts.get(SPAN_NAME_TWO)).isEqualTo(1); span2.end(); counts = dataAggregator.getRunningSpanCounts(); assertThat(counts).isEmpty(); }