summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy')
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy25
1 files changed, 25 insertions, 0 deletions
diff --git a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
index 94f62f8c2..16d106ba6 100755
--- a/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
+++ b/cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy
@@ -4,6 +4,7 @@
* Modifications Copyright (C) 2021 Pantheon.tech
* Modifications Copyright (C) 2021-2022 Bell Canada.
* Modifications Copyright (C) 2022 Deutsche Telekom AG
+ * Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,6 +69,7 @@ class DataRestControllerSpec extends Specification {
def basePath
def dataNodeBaseEndpoint
+ def dataNodeBaseEndpointV2
def dataspaceName = 'my_dataspace'
def anchorName = 'my_anchor'
def noTimestamp = null
@@ -94,6 +96,7 @@ class DataRestControllerSpec extends Specification {
def setup() {
dataNodeBaseEndpoint = "$basePath/v1/dataspaces/$dataspaceName"
+ dataNodeBaseEndpointV2 = "$basePath/v2/dataspaces/$dataspaceName"
}
def 'Create a node: #scenario.'() {
@@ -237,6 +240,28 @@ class DataRestControllerSpec extends Specification {
'with descendants' | dataNodeWithChild | 'true' || INCLUDE_ALL_DESCENDANTS | true | 'parent'
}
+
+ def 'Get data node using v2 api'() {
+ given: 'the service returns data node'
+ def xpath = 'some xPath'
+ def endpoint = "$dataNodeBaseEndpointV2/anchors/$anchorName/node"
+ mockCpsDataService.getDataNode(dataspaceName, anchorName, xpath, {descendantsOption -> {
+ assert descendantsOption.depth == 2}}) >> dataNodeWithChild
+ when: 'get request is performed through REST API'
+ def response =
+ mvc.perform(
+ get(endpoint)
+ .param('xpath', xpath)
+ .param('descendants', '2'))
+ .andReturn().response
+ then: 'a success response is returned'
+ assert response.status == HttpStatus.OK.value()
+ and: 'the response contains the root node identifier'
+ assert response.contentAsString.contains('parent')
+ and: 'the response contains child is true'
+ assert response.contentAsString.contains('"child"') == true
+ }
+
def 'Update data node leaves: #scenario.'() {
given: 'endpoint to update a node '
def endpoint = "$dataNodeBaseEndpoint/anchors/$anchorName/nodes"