Source:
public void testTrimEvents() { CtfTmfTrace initialTrace = fOriginalTrace; CtfTmfTrace trimmedTrace = fNewTrace; Path newTracePath = fNewTracePath; assertNotNull(initialTrace); assertNotNull(trimmedTrace); assertNotNull(newTracePath); final long newTraceStartTime = trimmedTrace.getStartTime().toNanos(); final long newTraceEndTime = trimmedTrace.getEndTime().toNanos(); assertTrue("Cut trace start time " + newTraceStartTime + " is earlier than the requested " + fRequestedTraceCutStart, newTraceStartTime >= fOriginalTrace.getStartTime().toNanos()); assertTrue("Cut trace end time " + newTraceEndTime + " is later than the requested " + fRequestedTraceCutEnd, newTraceEndTime <= fOriginalTrace.getEndTime().toNanos()); ITmfTimestamp startTime = fRequestedTraceCutEnd; ITmfContext initialContext = initialTrace.seekEvent(startTime); CtfTmfEvent initialEvent = initialTrace.getNext(initialContext); ITmfContext trimmedContext = trimmedTrace.seekEvent(startTime); CtfTmfEvent trimmedEvent = trimmedTrace.getNext(trimmedContext); int count = 0; while (initialEvent.getTimestamp().compareTo(fRequestedTraceCutEnd) <= 0) { assertNotNull(initialEvent); assertNotNull("Expected event not present in trimmed trace: " + eventToString(initialEvent), trimmedEvent); if (!eventsEquals(initialEvent, trimmedEvent)) { String comparator = eventToString(initialEvent) + "\n" + eventToString(trimmedEvent); if (!Objects.equals(initialEvent.getTimestamp(), trimmedEvent.getTimestamp())) { new Object(); } assertEquals(fRequestedTraceCutEnd + "\n" + count + "\n" + comparator, initialEvent.getTimestamp(), trimmedEvent.getTimestamp()); System.err.println("The following events have the exact same timestamp, and may be read in any order:"); System.err.println(comparator); } initialEvent = initialTrace.getNext(initialContext); trimmedEvent = trimmedTrace.getNext(trimmedContext); count++; } assertTrue("Trimmed trace is too small", count <= trimmedTrace.getNbEvents()); }

Target:
public void testTrimEvents() { CtfTmfTrace initialTrace = fOriginalTrace; CtfTmfTrace trimmedTrace = fNewTrace; Path newTracePath = fNewTracePath; assertNotNull(initialTrace); assertNotNull(trimmedTrace); assertNotNull(newTracePath); final long newTraceStartTime = trimmedTrace.getStartTime().toNanos(); final long newTraceEndTime = trimmedTrace.getEndTime().toNanos(); assertTrue("Cut trace start time " + newTraceStartTime + " is earlier than the requested " + fRequestedTraceCutStart, newTraceStartTime >= fOriginalTrace.getStartTime().toNanos()); assertTrue("Cut trace end time " + newTraceEndTime + " is later than the requested " + fRequestedTraceCutEnd, newTraceEndTime <= fOriginalTrace.getEndTime().toNanos()); ITmfTimestamp startTime = fRequestedTraceCutStart; ITmfContext initialContext = initialTrace.seekEvent(startTime); CtfTmfEvent initialEvent = initialTrace.getNext(initialContext); ITmfContext trimmedContext = trimmedTrace.seekEvent(startTime); CtfTmfEvent trimmedEvent = trimmedTrace.getNext(trimmedContext); int count = 0; while (initialEvent.getTimestamp().compareTo(fRequestedTraceCutEnd) <= 0) { assertNotNull(initialEvent); assertNotNull("Expected event not present in trimmed trace: " + eventToString(initialEvent), trimmedEvent); if (!eventsEquals(initialEvent, trimmedEvent)) { String comparator = eventToString(initialEvent) + "\n" + eventToString(trimmedEvent); assertEquals(fRequestedTraceCutEnd + "\n" + count + "\n" + comparator, initialEvent.getTimestamp(), trimmedEvent.getTimestamp()); System.err.println("The following events have the exact same timestamp, and may be read in any order:"); System.err.println(comparator); } initialEvent = initialTrace.getNext(initialContext); trimmedEvent = trimmedTrace.getNext(trimmedContext); count++; } assertTrue("Trimmed trace is too small", count <= trimmedTrace.getNbEvents()); }