* Test span merging with some extra invalid spans;
*/
@Test
public void testInvalidSpanCompletion() {
// Trace: 1, Span: 1, Parent: null
Span span1a = createClientSpan(idValue(1), idValue(1), null, new Utf8("a"));
Span span1b = createServerSpan(idValue(1), idValue(1), null, new Utf8("a"));
// Trace: 1, Span: 10, Parent: 3
Span spanBogus1 = createClientSpan(idValue(1), idValue(10), idValue(3), new Utf8("not"));
Span spanBogus2 = createServerSpan(idValue(1), idValue(10), idValue(3), new Utf8("equal"));
// Trace: 1, Span: 5, Parent: (2/3)
Span spanBogus3 = createClientSpan(idValue(1), idValue(5), idValue(2), new Utf8("equal"));
Span spanBogus4 = createServerSpan(idValue(1), idValue(5), idValue(3), new Utf8("equal"));
// Trace:1, Span: 4, Parent: 1
Span spanBogus5 = createClientSpan(idValue(1), idValue(4), idValue(1), new Utf8("alone"));
List<Span> partials = new ArrayList<Span>();
partials.add(span1a);
partials.add(span1b);
partials.add(spanBogus1);
partials.add(spanBogus2);
partials.add(spanBogus3);
partials.add(spanBogus4);
partials.add(spanBogus5);
SpanAggregationResults results = SpanAggregator.getFullSpans(partials);
assertNotNull(results.completeSpans);
assertNotNull(results.incompleteSpans);
assertTrue(results.incompleteSpans.size() == 5);
assertTrue(results.incompleteSpans.contains(spanBogus1));
assertTrue(results.incompleteSpans.contains(spanBogus2));
assertTrue(results.incompleteSpans.contains(spanBogus3));
assertTrue(results.incompleteSpans.contains(spanBogus4));
assertTrue(results.incompleteSpans.contains(spanBogus5));
assertTrue(results.completeSpans.size() == 1);
Span result = results.completeSpans.get(0);
assertTrue(result.complete);
assertTrue(idsEqual(idValue(1), result.spanID));
assertEquals(new Utf8("requestorHostname"), result.requestorHostname);
assertEquals(new Utf8("responderHostname"), result.responderHostname);
assertNull(result.parentSpanID);
assertEquals(new Utf8("a"), result.messageName);
}