-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: Add unit tests for BookmarkManagerService
Required unit tests have been implemented for BookmarkServiceManager class. In the tests, various aspects of bookmarking functionality (e.g., creating, updating, deleting, etc.) are checked. [Added] Required unit tests for bookmarking functionality Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
- Loading branch information
1 parent
b3e3509
commit 888c438
Showing
8 changed files
with
550 additions
and
123 deletions.
There are no files selected for viewing
352 changes: 352 additions & 0 deletions
352
...ss/incubator/trace/server/jersey/rest/core/tests/services/BookmarkManagerServiceTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
162 changes: 162 additions & 0 deletions
162
...e/tracecompass/incubator/trace/server/jersey/rest/core/tests/stubs/BookmarkModelStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Ericsson | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs; | ||
|
||
import java.io.Serializable; | ||
import java.nio.charset.Charset; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A Stub class for the bookmark model. It matches the trace server protocol's | ||
* <code>BookmarkModel</code> schema | ||
* | ||
* @author Kaveh Shahedi | ||
* @since 10.1 | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class BookmarkModelStub implements Serializable { | ||
private static final long serialVersionUID = -1945923534635091200L; | ||
|
||
private final UUID fUUID; | ||
private final String fName; | ||
private final long fStart; | ||
private final long fEnd; | ||
|
||
/** | ||
* {@link JsonCreator} Constructor for final fields | ||
* | ||
* @param uuid | ||
* The bookmark's UUID | ||
* @param name | ||
* The bookmark name | ||
* @param start | ||
* The start time | ||
* @param end | ||
* The end time | ||
*/ | ||
@JsonCreator | ||
public BookmarkModelStub( | ||
@JsonProperty("uuid") UUID uuid, | ||
@JsonProperty("name") String name, | ||
@JsonProperty("start") long start, | ||
@JsonProperty("end") long end) { | ||
fUUID = Objects.requireNonNull(uuid, "The 'UUID' json field was not set"); | ||
fName = Objects.requireNonNull(name, "The 'name' json field was not set"); | ||
fStart = start; | ||
fEnd = end; | ||
} | ||
|
||
/** | ||
* Constructor for comparing equality | ||
* | ||
* @param name | ||
* bookmark name | ||
* @param start | ||
* start time | ||
* @param end | ||
* end time | ||
*/ | ||
public BookmarkModelStub(String name, long start, long end) { | ||
this(getUUID(name), name, start, end); | ||
} | ||
|
||
private static UUID getUUID(String name) { | ||
return UUID.nameUUIDFromBytes(Objects.requireNonNull(name.getBytes(Charset.defaultCharset()))); | ||
} | ||
|
||
/** | ||
* Get the UUID | ||
* | ||
* @return The UUID | ||
*/ | ||
public UUID getUUID() { | ||
return fUUID; | ||
} | ||
|
||
/** | ||
* Get the bookmark name | ||
* | ||
* @return The bookmark name | ||
*/ | ||
public String getName() { | ||
return fName; | ||
} | ||
|
||
/** | ||
* Get the start time | ||
* | ||
* @return The start time | ||
*/ | ||
public long getStart() { | ||
return fStart; | ||
} | ||
|
||
/** | ||
* Get the end time | ||
* | ||
* @return The end time | ||
*/ | ||
public long getEnd() { | ||
return fEnd; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
BookmarkModelStub other = (BookmarkModelStub) obj; | ||
if (fEnd != other.fEnd) { | ||
return false; | ||
} | ||
if (fName == null) { | ||
if (other.fName != null) { | ||
return false; | ||
} | ||
} else if (!fName.equals(other.fName)) { | ||
return false; | ||
} | ||
if (fStart != other.fStart) { | ||
return false; | ||
} | ||
if (fUUID == null) { | ||
if (other.fUUID != null) { | ||
return false; | ||
} | ||
} else if (!fUUID.equals(other.fUUID)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "BookmarkModelStub [fUUID=" + fUUID + ", fName=" + fName + ", fStart=" + fStart + ", fEnd=" + fEnd + "]"; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return super.hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.