### Question:
TracezDataAggregator { List<SpanData> getOkSpans(String spanName, long lowerBound, long upperBound) { Map<String, TracezSpanBuckets> completedSpanCache = spanProcessor.getCompletedSpanCache(); TracezSpanBuckets buckets = completedSpanCache.get(spanName); if (buckets == null) { return Collections.emptyList(); } Collection<ReadableSpan> allOkSpans = buckets.getOkSpans(); List<SpanData> filteredSpans = new ArrayList<>(); for (ReadableSpan span : allOkSpans) { if (span.getLatencyNanos() >= lowerBound && span.getLatencyNanos() < upperBound) { filteredSpans.add(span.toSpanData()); } } return Collections.unmodifiableList(filteredSpans); } TracezDataAggregator(TracezSpanProcessor spanProcessor);   }### Answer:
@Test void getOkSpans_noSpans() { assertThat(dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, Long.MAX_VALUE)).isEmpty(); assertThat(dataAggregator.getOkSpans(SPAN_NAME_TWO, 0, Long.MAX_VALUE)).isEmpty(); }
@Test void getOkSpans_oneSpanNameWithDifferentLatencies() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); assertThat(dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, Long.MAX_VALUE)).isEmpty(); span1.end(); testClock.advanceNanos(1000); span2.end(); List<SpanData> spans = dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, Long.MAX_VALUE); assertThat(spans) .containsExactly(((ReadableSpan) span1).toSpanData(), ((ReadableSpan) span2).toSpanData()); spans = dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, 1000); assertThat(spans).containsExactly(((ReadableSpan) span1).toSpanData()); spans = dataAggregator.getOkSpans(SPAN_NAME_ONE, 1000, Long.MAX_VALUE); assertThat(spans).containsExactly(((ReadableSpan) span2).toSpanData()); }
@Test void getOkSpans_twoSpanNames() { Span span1 = tracer.spanBuilder(SPAN_NAME_ONE).startSpan(); Span span2 = tracer.spanBuilder(SPAN_NAME_TWO).startSpan(); assertThat(dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, Long.MAX_VALUE)).isEmpty(); assertThat(dataAggregator.getOkSpans(SPAN_NAME_TWO, 0, Long.MAX_VALUE)).isEmpty(); span1.end(); span2.end(); assertThat(dataAggregator.getOkSpans(SPAN_NAME_ONE, 0, Long.MAX_VALUE)) .containsExactly(((ReadableSpan) span1).toSpanData()); assertThat(dataAggregator.getOkSpans(SPAN_NAME_TWO, 0, Long.MAX_VALUE)) .containsExactly(((ReadableSpan) span2).toSpanData()); }