+ def 'Update data node leaves: #scenario.'() {
+ given: 'json data'
+ def jsonData = 'json data'
+ def endpoint = "$dataNodeBaseEndpoint/anchors/$anchorName/nodes"
+ when: 'patch request is performed'
+ def response =
+ mvc.perform(
+ patch(endpoint)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(jsonData)
+ .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 | inputXpath || xpathServiceParameter
+ 'root node by default' | '' || '/'
+ 'root node by choice' | '/' || '/'
+ 'some xpath by parent' | '/some/xpath' || '/some/xpath'
+ }
+
+ def 'Replace data node tree: #scenario.'() {
+ given: 'json data'
+ def jsonData = 'json data'
+ def endpoint = "$dataNodeBaseEndpoint/anchors/$anchorName/nodes"
+ when: 'put request is performed'
+ def response =
+ mvc.perform(
+ put(endpoint)
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(jsonData)
+ .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 | inputXpath || xpathServiceParameter
+ 'root node by default' | '' || '/'
+ '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'