tmf: Add a few tests to TmfTraceUtilsSearchingTest
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 28 Jun 2016 23:06:09 +0000 (19:06 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Wed, 29 Jun 2016 19:54:56 +0000 (15:54 -0400)
Test the behavior of the search when there is no event match.

Change-Id: I6c6bfb76acf73151851cab766f5d57026f7da7d8
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/76226
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
ctf/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/trace/TmfTraceUtilsSearchingTest.java

index b220989654c2aa052a7d8f1d2a59bd08ad487a4b..66e6d31f67d859548b347c88b53bde75d76411a5 100644 (file)
@@ -80,6 +80,21 @@ public class TmfTraceUtilsSearchingTest {
         assertEquals(expectedEvent, actualEvent);
     }
 
+    /**
+     * Test the {@link TmfTraceUtils#getNextEventMatching} method where no event
+     * matches the passed predicate. It should return null.
+     */
+    @Test
+    public void testNextMatchingEventNoMatch() {
+        ITmfTrace trace = fTrace;
+        assertNotNull(trace);
+
+        Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event");
+
+        ITmfEvent actualEvent = TmfTraceUtils.getNextEventMatching(trace, START_RANK, predicate);
+        assertNull(actualEvent);
+    }
+
     /**
      * Test the {@link TmfTraceUtils#getNextEventMatching} method, where the
      * event from which we start the search already matches the criterion (it
@@ -115,6 +130,21 @@ public class TmfTraceUtilsSearchingTest {
         assertEquals(expectedEvent, actualEvent);
     }
 
+    /**
+     * Test the {@link TmfTraceUtils#getPreviousEventMatching} method where no event
+     * matches the passed predicate. It should return null.
+     */
+    @Test
+    public void testPreviousMatchingEventNoMatch() {
+        ITmfTrace trace = fTrace;
+        assertNotNull(trace);
+
+        Predicate<@NonNull ITmfEvent> predicate = event -> event.getName().equals("non-existent-event");
+
+        ITmfEvent actualEvent = TmfTraceUtils.getPreviousEventMatching(trace, START_RANK, predicate);
+        assertNull(actualEvent);
+    }
+
     /**
      * Test the {@link TmfTraceUtils#getPreviousEventMatching} method, where the
      * event from which we start the search already matches the criterion (it
This page took 0.025402 seconds and 5 git commands to generate.