diff options
author | niamhcore <niamh.core@est.tech> | 2021-08-10 16:39:53 +0100 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2021-08-11 10:31:45 +0100 |
commit | 4802d46c0d3e7d65a9dcfbf6c168c6466d55c0b2 (patch) | |
tree | 263fe222a0a05019fe025ab0db9b3a1879bf7535 /cps-rest/src/test | |
parent | dce1d58005d90950e00b22078d82559748dcb255 (diff) |
Update response query format
Issue-ID: CPS-560
Change-Id: I1c71270a8cde7e940c5af80bc743d0f01ab6b9bb
Signed-off-by: niamhcore <niamh.core@est.tech>
Diffstat (limited to 'cps-rest/src/test')
-rw-r--r-- | cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy index 6b6bdeeeb5..83c83f8359 100644 --- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy +++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/QueryRestControllerSpec.groovy @@ -22,6 +22,8 @@ package org.onap.cps.rest.controller +import org.onap.cps.spi.model.DataNode + import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get @@ -67,11 +69,12 @@ class QueryRestControllerSpec extends Specification { def 'Query data node by cps path for the given dataspace and anchor with #scenario.'() { given: 'service method returns a list containing a data node' - def dataNode = new DataNodeBuilder().withXpath('/xpath').build() + def dataNode1 = new DataNodeBuilder().withXpath('/xpath') + .withLeaves([leaf: 'value', leafList: ['leaveListElement1', 'leaveListElement2']]).build() def dataspaceName = 'my_dataspace' def anchorName = 'my_anchor' def cpsPath = 'some cps-path' - mockCpsQueryService.queryDataNodes(dataspaceName, anchorName, cpsPath, expectedCpsDataServiceOption) >> [dataNode] + mockCpsQueryService.queryDataNodes(dataspaceName, anchorName, cpsPath, expectedCpsDataServiceOption) >> [dataNode1, dataNode1] and: 'the query endpoint' def dataNodeEndpoint = "$basePath/v1/dataspaces/$dataspaceName/anchors/$anchorName/nodes/query" when: 'query data nodes API is invoked' @@ -83,7 +86,7 @@ class QueryRestControllerSpec extends Specification { .andReturn().response then: 'the response contains the the datanode in json format' response.status == HttpStatus.OK.value() - response.getContentAsString().contains(new Gson().toJson(dataNode)) + response.getContentAsString() == '[{"leaf":"value","leafList":["leaveListElement1","leaveListElement2"]},{"leaf":"value","leafList":["leaveListElement1","leaveListElement2"]}]' where: 'the following options for include descendants are provided in the request' scenario | includeDescendantsOption || expectedCpsDataServiceOption 'no descendants by default' | '' || OMIT_DESCENDANTS |