return new ResponseEntity<>(HttpStatus.OK);
}
+ @Override
+ public ResponseEntity<Void> deleteListNodeElements(final String dataspaceName, final String anchorName,
+ final String listNodeXpath) {
+ cpsDataService.deleteListNodeData(dataspaceName, anchorName, listNodeXpath);
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+
private static boolean isRootXpath(final String xpath) {
return ROOT_XPATH.equals(xpath);
}
'403':
$ref: 'components.yml#/components/responses/Forbidden'
+ delete:
+ description: Delete list-node child elements under existing node for a given anchor and dataspace
+ tags:
+ - cps-data
+ summary: Delete list-node child element(s) under existing parent node
+ operationId: deleteListNodeElements
+ parameters:
+ - $ref: 'components.yml#/components/parameters/dataspaceNameInPath'
+ - $ref: 'components.yml#/components/parameters/anchorNameInPath'
+ - $ref: 'components.yml#/components/parameters/requiredXpathInQuery'
+ responses:
+ '204':
+ $ref: 'components.yml#/components/responses/NoContent'
+ '400':
+ $ref: 'components.yml#/components/responses/BadRequest'
+ '401':
+ $ref: 'components.yml#/components/responses/Unauthorized'
+ '403':
+ $ref: 'components.yml#/components/responses/Forbidden'
+
nodesByDataspaceAndAnchor:
post:
description: Create a node for a given anchor and dataspace
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.delete
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
then: 'the java API was called with the correct parameters'
1 * mockCpsDataService.replaceListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData)
}
+
+ def 'Delete list node child elements.'() {
+ given: 'list node xpath'
+ def listNodeXpath = 'list node xpath'
+ when: 'delete is invoked list-node endpoint'
+ def response = mvc.perform(
+ delete("$dataNodeBaseEndpoint/anchors/$anchorName/list-node")
+ .param('xpath', listNodeXpath)
+ ).andReturn().response
+ then: 'a success response is returned'
+ response.status == HttpStatus.NO_CONTENT.value()
+ then: 'the java API was called with the correct parameters'
+ 1 * mockCpsDataService.deleteListNodeData(dataspaceName, anchorName, listNodeXpath)
+ }
}