summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/test/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest/src/test/groovy')
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy40
1 files changed, 11 insertions, 29 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 299299ce28..b7337e02a5 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
@@ -174,27 +174,7 @@ class DataRestControllerSpec extends Specification {
'no descendant explicitly' | dataNodeWithLeavesNoChildren | 'false' || OMIT_DESCENDANTS | false
'with descendants' | dataNodeWithChild | 'true' || INCLUDE_ALL_DESCENDANTS | true
}
-
- @Unroll
- def 'Get data node error scenario: #scenario.'() {
- given: 'the service throws an exception'
- def endpoint = "$dataNodeBaseEndpoint/anchors/$anchorName/node"
- mockCpsDataService.getDataNode(dataspaceName, anchorName, xpath, _) >> { throw exception }
- when: 'get request is performed through REST API'
- def response =
- mvc.perform(get(endpoint).param("xpath", xpath))
- .andReturn().response
- then: 'a success response is returned'
- response.status == httpStatus.value()
- where:
- scenario | xpath | exception || httpStatus
- 'no dataspace' | '/x-path' | new DataspaceNotFoundException('') || HttpStatus.BAD_REQUEST
- 'no anchor' | '/x-path' | new AnchorNotFoundException('', '') || HttpStatus.BAD_REQUEST
- 'no data' | '/x-path' | new DataNodeNotFoundException('', '', '') || HttpStatus.NOT_FOUND
- 'root path' | '/' | new DataNodeNotFoundException('', '') || HttpStatus.NOT_FOUND
- 'already defined' | '/x-path' | new AlreadyDefinedException('', new Throwable()) || HttpStatus.CONFLICT
- }
-
+
@Unroll
def 'Update data node leaves: #scenario.'() {
given: 'json data'
@@ -206,16 +186,17 @@ class DataRestControllerSpec extends Specification {
patch(endpoint)
.contentType(MediaType.APPLICATION_JSON)
.content(jsonData)
- .param('xpath', xpath)
+ .param('xpath', inputXpath)
).andReturn().response
then: 'the service method is invoked with expected parameters'
1 * mockCpsDataService.updateNodeLeaves(dataspaceName, anchorName, xpathServiceParameter, jsonData)
and: 'response status indicates success'
response.status == HttpStatus.OK.value()
where:
- scenario | xpath | xpathServiceParameter
- 'root node by default' | '' | '/'
- 'node by parent xpath' | '/xpath' | '/xpath'
+ scenario | inputXpath || xpathServiceParameter
+ 'root node by default' | '' || '/'
+ 'root node by choice' | '/' || '/'
+ 'some xpath by parent' | '/some/xpath' || '/some/xpath'
}
@Unroll
@@ -229,15 +210,16 @@ class DataRestControllerSpec extends Specification {
put(endpoint)
.contentType(MediaType.APPLICATION_JSON)
.content(jsonData)
- .param('xpath', xpath))
+ .param('xpath', inputXpath))
.andReturn().response
then: 'the service method is invoked with expected parameters'
1 * mockCpsDataService.replaceNodeTree(dataspaceName, anchorName, xpathServiceParameter, jsonData)
and: 'response status indicates success'
response.status == HttpStatus.OK.value()
where:
- scenario | xpath | xpathServiceParameter
- 'root node by default' | '' | '/'
- 'node by parent xpath' | '/xpath' | '/xpath'
+ scenario | inputXpath || xpathServiceParameter
+ 'root node by default' | '' || '/'
+ 'root node by choice' | '/' || '/'
+ 'some xpath by parent' | '/some/xpath' || '/some/xpath'
}
}