Source:
public void testGetCompletionTimesThreeFragmentCausedBy() { String suffix="3cb"; Trace trace1 = new Trace(); trace1.setId("1_"+suffix); trace1.setStartTime(System.currentTimeMillis() - 60000); Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(TimeUnit.NANOSECONDS.convert(1000, TimeUnit.MILLISECONDS)); trace1.getNodes().add(c1); Component comp1 = new Component(); comp1.setUri("comp1"); comp1.setBaseTime(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); comp1.setDuration(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); c1.getNodes().add(comp1); Trace trace2 = new Trace(); trace2.setId("2_"+suffix); trace2.setStartTime(trace1.getStartTime() + 500); Consumer c2 = new Consumer(); c2.setUri("testuri2"); c2.setDuration(TimeUnit.NANOSECONDS.convert(1000, TimeUnit.MILLISECONDS)); c2.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace1.getId()+":0:0")); trace2.getNodes().add(c2); Component comp2 = new Component(); comp2.setUri("comp2"); comp2.setBaseTime(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); comp2.setDuration(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); c2.getNodes().add(comp2); Trace trace3 = new Trace(); trace3.setId("3_"+suffix); trace3.setStartTime(trace2.getStartTime() + 500); Consumer c3 = new Consumer(); c3.setUri("testuri3"); c3.setDuration(TimeUnit.NANOSECONDS.convert(4000, TimeUnit.MILLISECONDS)); c3.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace2.getId()+":0:0")); trace3.getNodes().add(c3); try { publisher.publish(null, Arrays.asList(trace1, trace2, trace3)); } catch (Exception e1) { fail("Failed to store: " + e1); } Wait.until(() -> service.searchFragments(null, new Criteria()).size() == 3); Wait.until(() -> analytics.getTraceCompletionTimes(null, new Criteria()).size() == 1, 15, TimeUnit.SECONDS); List<CompletionTime> times = analytics.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(5000, times.get(0).getDuration()); }

Target:
public void testGetCompletionTimesThreeFragmentCausedBy() throws Exception { String suffix="3cb"; Trace trace1 = new Trace(); trace1.setId("1_"+suffix); trace1.setStartTime(System.currentTimeMillis() - 60000); Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(TimeUnit.NANOSECONDS.convert(1000, TimeUnit.MILLISECONDS)); trace1.getNodes().add(c1); Component comp1 = new Component(); comp1.setUri("comp1"); comp1.setBaseTime(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); comp1.setDuration(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); c1.getNodes().add(comp1); Trace trace2 = new Trace(); trace2.setId("2_"+suffix); trace2.setStartTime(trace1.getStartTime() + 500); Consumer c2 = new Consumer(); c2.setUri("testuri2"); c2.setDuration(TimeUnit.NANOSECONDS.convert(1000, TimeUnit.MILLISECONDS)); c2.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace1.getId()+":0:0")); trace2.getNodes().add(c2); Component comp2 = new Component(); comp2.setUri("comp2"); comp2.setBaseTime(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); comp2.setDuration(TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS)); c2.getNodes().add(comp2); Trace trace3 = new Trace(); trace3.setId("3_"+suffix); trace3.setStartTime(trace2.getStartTime() + 500); Consumer c3 = new Consumer(); c3.setUri("testuri3"); c3.setDuration(TimeUnit.NANOSECONDS.convert(4000, TimeUnit.MILLISECONDS)); c3.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace2.getId()+":0:0")); trace3.getNodes().add(c3); publisher.publish(null, Arrays.asList(trace1, trace2, trace3)); Wait.until(() -> service.searchFragments(null, new Criteria()).size() == 3); Wait.until(() -> analytics.getTraceCompletionTimes(null, new Criteria()).size() == 1, 15, TimeUnit.SECONDS); List<CompletionTime> times = analytics.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(5000, times.get(0).getDuration()); }