diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/BookmarkManagerServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/BookmarkManagerServiceTest.java index dd81aead..8ce3958a 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/BookmarkManagerServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/BookmarkManagerServiceTest.java @@ -26,6 +26,7 @@ import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.BookmarkModelStub; import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.ExperimentModelStub; import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.utils.RestServerTest; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,8 +47,7 @@ public class BookmarkManagerServiceTest extends RestServerTest { private static final String END = "end"; /** - * Setup method to run before each test. Creates a clean experiment and removes all - * existing bookmarks. + * Setup method to run before each test */ @Before public void setUp() { @@ -56,8 +56,14 @@ public void setUp() { CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB); assertNotNull("Experiment should not be null", experiment); assertNotNull("Experiment UUID should not be null", experiment.getUUID()); + } - // Get all existing bookmarks and delete them + /** + * Tear down method to run after each test + */ + @After + public void tearDown() { + // Remove all bookmarks WebTarget application = getApplicationEndpoint(); WebTarget bookmarkTarget = application.path(EXPERIMENTS) .path(experiment.getUUID().toString()) @@ -141,6 +147,32 @@ public void testCreateBookmark() { assertNotNull("UUID should not be null", expStub.getUUID()); } + /* + * Test the creation of a bookmark with no end time (i.e., just start time). + */ + @Test + public void testCreateBookmarkNoEndTime() { + WebTarget application = getApplicationEndpoint(); + WebTarget bookmarkTarget = application.path(EXPERIMENTS) + .path(experiment.getUUID().toString()) + .path(BOOKMARKS); + + Map parameters = new HashMap<>(); + parameters.put(NAME, BOOKMARK.getName()); + parameters.put(START, START_TIME); + parameters.put(END, START_TIME); + + Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList()))); + assertEquals("Response status should be 200", 200, response.getStatus()); + + BookmarkModelStub expStub = response.readEntity(BookmarkModelStub.class); + assertNotNull("Response body should not be null", expStub); + assertEquals("Bookmark name should match", BOOKMARK.getName(), expStub.getName()); + assertEquals("Start time should match", BOOKMARK.getStart(), expStub.getStart()); + assertEquals("End time should match", BOOKMARK.getStart(), expStub.getEnd()); + assertNotNull("UUID should not be null", expStub.getUUID()); + } + /** * Test the creation of a bookmark with a repetitive name. */