summaryrefslogtreecommitdiffstats
path: root/cps-rest/src
diff options
context:
space:
mode:
Diffstat (limited to 'cps-rest/src')
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java9
-rwxr-xr-xcps-rest/src/test/groovy/org/onap/cps/rest/controller/DataRestControllerSpec.groovy22
2 files changed, 26 insertions, 5 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 c8b7412593..3d16539b3e 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
@@ -52,6 +52,13 @@ public class DataRestController implements CpsDataApi {
}
@Override
+ public ResponseEntity<String> addListNodeElements(final String jsonData, final String parentNodeXpath,
+ final String dataspaceName, final String anchorName) {
+ cpsDataService.saveListNodeData(dataspaceName, anchorName, parentNodeXpath, jsonData);
+ return new ResponseEntity<>(HttpStatus.CREATED);
+ }
+
+ @Override
public ResponseEntity<Object> getNodesByDataspace(final String dataspaceName) {
return null;
}
@@ -62,7 +69,7 @@ public class DataRestController implements CpsDataApi {
final FetchDescendantsOption fetchDescendantsOption = Boolean.TRUE.equals(includeDescendants)
? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS;
final var dataNode = cpsDataService.getDataNode(dataspaceName, anchorName, xpath,
- fetchDescendantsOption);
+ fetchDescendantsOption);
return new ResponseEntity<>(DataMapUtils.toDataMap(dataNode), HttpStatus.OK);
}
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 b64b56178a..18d20a8e20 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
@@ -33,10 +33,6 @@ import org.onap.cps.api.CpsAdminService
import org.onap.cps.api.CpsDataService
import org.onap.cps.api.CpsModuleService
import org.onap.cps.api.CpsQueryService
-import org.onap.cps.spi.exceptions.AlreadyDefinedException
-import org.onap.cps.spi.exceptions.AnchorNotFoundException
-import org.onap.cps.spi.exceptions.DataNodeNotFoundException
-import org.onap.cps.spi.exceptions.DataspaceNotFoundException
import org.onap.cps.spi.model.DataNode
import org.onap.cps.spi.model.DataNodeBuilder
import org.spockframework.spring.SpringBean
@@ -131,6 +127,24 @@ class DataRestControllerSpec extends Specification {
1 * mockCpsDataService.saveData(dataspaceName, anchorName, parentNodeXpath, json)
}
+ def 'Create list node child elements.'() {
+ given: 'parent node xpath and json data inputs'
+ def parentNodeXpath = 'parent node xpath'
+ def jsonData = 'json data'
+ when: 'post is invoked list-node endpoint'
+ def response = mvc.perform(
+ post("$dataNodeBaseEndpoint/anchors/$anchorName/list-node")
+ .contentType(MediaType.APPLICATION_JSON)
+ .param('xpath', parentNodeXpath)
+ .content(jsonData)
+ ).andReturn().response
+ then: 'a created response is returned'
+ 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'() {
given: 'the service returns data node leaves'
def xpath = 'some xPath'