Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: serialize ITmfXyEntryModel specific attributes
Add unit tests that queries the histogram data provider which uses the new API. With this the serialization of the new boolean flag is tested. Bug 581326 [Added] Serialization of ITmfXyEntryModel specific attributes Change-Id: I226c88eabc29e20fa167ab093e6937b15a473570 Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/199322 Tested-by: Marco Miller <marco.miller@ericsson.com> Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org> Reviewed-by: Marco Miller <marco.miller@ericsson.com>
- Loading branch information
Showing
5 changed files
with
261 additions
and
10 deletions.
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
...se/tracecompass/incubator/trace/server/jersey/rest/core/tests/stubs/XyEntryModelStub.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,68 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2023 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.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A Stub class for the entry model. It matches the trace server protocol's | ||
* <code>XYEntryModel</code> schema | ||
* | ||
* @author Bernd Hufmann | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class XyEntryModelStub implements Serializable { | ||
|
||
private static final long serialVersionUID = -5846598539343152768L; | ||
|
||
private final List<XyEntryStub> fEntries; | ||
private final List<EntryHeaderStub> fHeaders; | ||
|
||
/** | ||
* {@link JsonCreator} Constructor for final fields | ||
* | ||
* @param entries | ||
* The set of entries for this model | ||
* @param headers | ||
* The set of headers for this model | ||
*/ | ||
@JsonCreator | ||
public XyEntryModelStub(@JsonProperty("entries") List<XyEntryStub> entries, | ||
@JsonProperty("headers") List<EntryHeaderStub> headers) { | ||
fEntries = Objects.requireNonNull(entries, "The 'entries' json field was not set"); | ||
fHeaders = headers == null ? Collections.emptyList() : headers; | ||
} | ||
|
||
/** | ||
* Get the entries described by this model | ||
* | ||
* @return The entries in this model | ||
*/ | ||
public List<XyEntryStub> getEntries() { | ||
return fEntries; | ||
} | ||
|
||
/** | ||
* Get the headers that describe this model | ||
* | ||
* @return The headers in this model | ||
*/ | ||
public List<EntryHeaderStub> getHeaders() { | ||
return fHeaders; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/stubs/XyEntryStub.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,64 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2023 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.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A Stub class for the entry elements. It matches the trace server protocol's | ||
* <code>XY Entry</code> schema | ||
* | ||
* @author Bernd Hufmann | ||
*/ | ||
public class XyEntryStub extends EntryStub { | ||
|
||
private static final long serialVersionUID = 8369475974133990978L; | ||
|
||
private final boolean fIsDefault; | ||
|
||
/** | ||
* {@link JsonCreator} Constructor for final fields | ||
* | ||
* @param labels | ||
* The labels of this entry | ||
* @param id | ||
* The unique ID of the entry | ||
* @param parentId | ||
* The unique id of the parent of this entry | ||
* @param hasRowModel | ||
* Whether this entry has data | ||
* @param style | ||
* The style of this entry | ||
* @param isDefault | ||
* whether the entry is a default entry (default selection) | ||
*/ | ||
@JsonCreator | ||
public XyEntryStub(@JsonProperty("labels") List<String> labels, | ||
@JsonProperty("id") Integer id, | ||
@JsonProperty("parentId") Integer parentId, | ||
@JsonProperty("hasData") boolean hasRowModel, | ||
@JsonProperty("style") OutputElementStyleStub style, | ||
@JsonProperty("isDefault") boolean isDefault) { | ||
super(labels, id, parentId, hasRowModel, style); | ||
fIsDefault = isDefault; | ||
} | ||
|
||
/** | ||
* @return whether the entry is a default entry and should be selected by | ||
* default | ||
*/ | ||
public boolean isDefault() { | ||
return fIsDefault; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...compass/incubator/trace/server/jersey/rest/core/tests/stubs/XyTreeOutputResponseStub.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,52 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2023 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 com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A stub class for the response to a tree request for xy charts and data trees. | ||
* It contains the generic response, as well as an {@link XyEntryModelStub} | ||
* | ||
* @author Bernd Hufmann | ||
*/ | ||
public class XyTreeOutputResponseStub extends OutputResponseStub { | ||
|
||
private static final long serialVersionUID = -4155622509432733184L; | ||
private final XyEntryModelStub fModel; | ||
|
||
/** | ||
* {@link JsonCreator} Constructor from json | ||
* | ||
* @param model | ||
* The model for this response | ||
* @param status | ||
* The status of the response | ||
* @param statusMessage | ||
* The custom status message of the response | ||
*/ | ||
public XyTreeOutputResponseStub(@JsonProperty("model") XyEntryModelStub model, | ||
@JsonProperty("status") String status, | ||
@JsonProperty("statusMessage") String statusMessage) { | ||
super(status, statusMessage); | ||
fModel = model; | ||
} | ||
|
||
/** | ||
* Get the model for this response | ||
* | ||
* @return The model for the response | ||
*/ | ||
public XyEntryModelStub getModel() { | ||
return fModel; | ||
} | ||
} |
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