Source:
<code>public void testGetCompletionTimesThreeFragmentCausedBy() throws Exception { String suffix="3cb"; Trace trace1 = new Trace(); trace1.setId("1_"+suffix); <START> trace1.setStartTime(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) - 4000); END> Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(1000); trace1.getNodes().add(c1); Component comp1 = new Component(); comp1.setUri("comp1"); comp1.getProperties().add(new Property("prop1", "value1")); comp1.setBaseTime(500); comp1.setDuration(500); 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(1000); c2.getProperties().add(new Property("prop2", "value2")); c2.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace1.getId()+":0:0")); trace2.getNodes().add(c2); Component comp2 = new Component(); comp2.setUri("comp2"); comp2.setBaseTime(500); comp2.setDuration(500); 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.getProperties().add(new Property("prop3", "value3")); c3.setDuration(4000); c3.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace2.getId()+":0:0")); trace3.getNodes().add(c3); tracePublisher.publish(null, Arrays.asList(trace1, trace2, trace3)); Wait.until(() -> traceService.searchFragments(null, new Criteria()).size() == 3); Wait.until(() -> analyticsService.getTraceCompletionTimes(null, new Criteria()).size() == 1, 15, TimeUnit.SECONDS); List<CompletionTime> times = analyticsService.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(5000, times.get(0).getDuration()); assertEquals(3, times.get(0).getProperties().size()); }</code><technical_language>60000000</technical_language>

Target:
public void testGetCompletionTimesThreeFragmentCausedBy() throws Exception { String suffix="3cb"; Trace trace1 = new Trace(); trace1.setId("1_"+suffix); trace1.setStartTime(TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) - FOUR_MS_IN_MICRO_SEC); Consumer c1 = new Consumer(); c1.setUri("testuri"); c1.setDuration(1000); trace1.getNodes().add(c1); Component comp1 = new Component(); comp1.setUri("comp1"); comp1.getProperties().add(new Property("prop1", "value1")); comp1.setBaseTime(500); comp1.setDuration(500); 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(1000); c2.getProperties().add(new Property("prop2", "value2")); c2.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace1.getId()+":0:0")); trace2.getNodes().add(c2); Component comp2 = new Component(); comp2.setUri("comp2"); comp2.setBaseTime(500); comp2.setDuration(500); 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.getProperties().add(new Property("prop3", "value3")); c3.setDuration(4000); c3.getCorrelationIds().add(new CorrelationIdentifier(Scope.CausedBy, trace2.getId()+":0:0")); trace3.getNodes().add(c3); tracePublisher.publish(null, Arrays.asList(trace1, trace2, trace3)); Wait.until(() -> traceService.searchFragments(null, new Criteria()).size() == 3); Wait.until(() -> analyticsService.getTraceCompletionTimes(null, new Criteria()).size() == 1, 15, TimeUnit.SECONDS); List<CompletionTime> times = analyticsService.getTraceCompletionTimes(null, new Criteria()); assertNotNull(times); assertEquals(1, times.size()); assertEquals(5000, times.get(0).getDuration()); assertEquals(3, times.get(0).getProperties().size()); }