diff options
Diffstat (limited to 'cps-rest/src')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java | 7 | ||||
-rwxr-xr-x | cps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy | 18 |
2 files changed, 24 insertions, 1 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java index 3d16539b3e..0c70a6c2e9 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java @@ -87,6 +87,13 @@ public class DataRestController implements CpsDataApi { return new ResponseEntity<>(HttpStatus.OK); } + @Override + public ResponseEntity<String> replaceListNodeElements(final String jsonData, final String parentNodeXpath, + final String dataspaceName, final String anchorName) { + cpsDataService.replaceListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData); + return new ResponseEntity<>(HttpStatus.OK); + } + private static boolean isRootXpath(final String xpath) { return ROOT_XPATH.equals(xpath); } 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 18d20a8e20..344e603727 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 @@ -142,7 +142,6 @@ class DataRestControllerSpec extends Specification { response.status == HttpStatus.CREATED.value() then: 'the java API was called with the correct parameters' 1 * mockCpsDataService.saveListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData) - } def 'Get data node with leaves'() { @@ -230,4 +229,21 @@ class DataRestControllerSpec extends Specification { 'root node by choice' | '/' || '/' 'some xpath by parent' | '/some/xpath' || '/some/xpath' } + + def 'Replace list node child elements.'() { + given: 'parent node xpath and json data inputs' + def parentNodeXpath = 'parent node xpath' + def jsonData = 'json data' + when: 'patch is invoked list-node endpoint' + def response = mvc.perform( + patch("$dataNodeBaseEndpoint/anchors/$anchorName/list-node") + .contentType(MediaType.APPLICATION_JSON) + .param('xpath', parentNodeXpath) + .content(jsonData) + ).andReturn().response + then: 'a success response is returned' + response.status == HttpStatus.OK.value() + then: 'the java API was called with the correct parameters' + 1 * mockCpsDataService.replaceListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData) + } } |