Skip to content

Commit

Permalink
server: Use standard IMarker structure for storing bookmarks
Browse files Browse the repository at this point in the history
The new changes aim to re-structure the algorithm of storing bookmarks.
Previously, we stored each bookmark (of an experiment) under a specific
directory inside the .webapp directory of Trace Compass. Right now, we
are using Eclipse's markers system to store and fetch the benchmarks.

[Changed] Bookmark storing/fetching system is changed to IMarker

Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
  • Loading branch information
kavehshahedi committed Nov 14, 2024
1 parent 6159498 commit 4175e90
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* Test class for BookmarkManagerService
*
* @author Kaveh Shahedi
* @since 10.1
*/
public class BookmarkManagerServiceTest extends RestServerTest {

Expand All @@ -43,6 +42,9 @@ public class BookmarkManagerServiceTest extends RestServerTest {
private static final @NonNull BookmarkModelStub BOOKMARK = new BookmarkModelStub(BOOKMARK_NAME, START_TIME, END_TIME);
private ExperimentModelStub experiment;

private static final String START = "start";
private static final String END = "end";

/**
* Setup method to run before each test. Creates a clean experiment and removes all
* existing bookmarks.
Expand Down Expand Up @@ -90,24 +92,24 @@ public void testCreateBookmarkInvalidParams() {
// Test with null name
Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, null);
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Should return 400 for null name", 400, response.getStatus());

// Test with non-numeric start and end times
parameters.put(NAME, BOOKMARK_NAME);
parameters.put("start", "not a number");
parameters.put("end", "not a number");
parameters.put(START, "not a number");
parameters.put(END, "not a number");

response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Should return 400 for non-numeric times", 400, response.getStatus());

// Test with end time before start time
parameters.put(NAME, BOOKMARK_NAME);
parameters.put("start", END_TIME);
parameters.put("end", START_TIME);
parameters.put(START, END_TIME);
parameters.put(END, START_TIME);

response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Should return 400 for invalid time range", 400, response.getStatus());
Expand All @@ -125,8 +127,8 @@ public void testCreateBookmark() {

Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, BOOKMARK.getName());
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Response status should be 200", 200, response.getStatus());
Expand All @@ -152,17 +154,17 @@ public void testCreateBookmarkRepetitiveName() {
// Create first bookmark
Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, BOOKMARK.getName());
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
BookmarkModelStub firstBookmark = response.readEntity(BookmarkModelStub.class);
assertEquals("First bookmark creation should succeed", 200, response.getStatus());
assertNotNull("First bookmark should not be null", firstBookmark);

// Try to create second bookmark with same name but different times
parameters.replace("start", START_TIME + 1);
parameters.replace("end", END_TIME + 1);
parameters.replace(START, START_TIME + 1);
parameters.replace(END, END_TIME + 1);

response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Should return conflict for duplicate name", 409, response.getStatus());
Expand Down Expand Up @@ -190,8 +192,8 @@ public void testGetAllBookmarks() {

// Create multiple bookmarks
Map<String, Object> parameters = new HashMap<>();
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

// Create first bookmark
parameters.put(NAME, "Bookmark1");
Expand Down Expand Up @@ -232,8 +234,8 @@ public void testGetSpecificBookmark() {
// Create a bookmark
Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, BOOKMARK.getName());
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Bookmark creation should succeed", 200, response.getStatus());
Expand Down Expand Up @@ -264,8 +266,8 @@ public void testUpdateBookmark() {
// Create initial bookmark
Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, BOOKMARK.getName());
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
BookmarkModelStub originalBookmark = response.readEntity(BookmarkModelStub.class);
Expand All @@ -278,17 +280,17 @@ public void testUpdateBookmark() {
assertEquals("Should return 404 for non-existent bookmark", 404, nonExistentResponse.getStatus());

// Test updating with invalid parameters
parameters.put("start", END_TIME);
parameters.put("end", START_TIME);
parameters.put(START, END_TIME);
parameters.put(END, START_TIME);
Response invalidResponse = bookmarkTarget.path(originalBookmark.getUUID().toString())
.request()
.put(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
assertEquals("Should return 400 for invalid parameters", 400, invalidResponse.getStatus());

// Test successful update
parameters.put("name", "Updated Name");
parameters.put("start", START_TIME + 5);
parameters.put("end", END_TIME + 5);
parameters.put(START, START_TIME + 5);
parameters.put(END, END_TIME + 5);

response = bookmarkTarget.path(originalBookmark.getUUID().toString())
.request()
Expand Down Expand Up @@ -323,8 +325,8 @@ public void testDeleteBookmark() {
// Create a bookmark to delete
Map<String, Object> parameters = new HashMap<>();
parameters.put(NAME, BOOKMARK.getName());
parameters.put("start", START_TIME);
parameters.put("end", END_TIME);
parameters.put(START, START_TIME);
parameters.put(END, END_TIME);

Response response = bookmarkTarget.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())));
BookmarkModelStub createdBookmark = response.readEntity(BookmarkModelStub.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* <code>BookmarkModel</code> schema
*
* @author Kaveh Shahedi
* @since 10.1
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class BookmarkModelStub implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* Contributes to the model used for TSP swagger-core annotations.
*
* @author Kaveh Shahedi
* @since 10.1
*/
public interface Bookmark {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Parameters for bookmark creation and update operations
*
* @author Kaveh Shahedi
* @since 10.1
*/
public interface BookmarkQueryParameters {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* Bookmark model for TSP
*
* @author Kaveh Shahedi
* @since 10.1
*/
public class Bookmark implements Serializable {

Expand Down
Loading

0 comments on commit 4175e90

Please sign in to comment.