Create list-node elements (part3): NCMP REST and service layers
[cps.git] / cps-ncmp-rest / src / test / groovy / org / onap / cps / ncmp / rest / controller / NetworkCmProxyControllerSpec.groovy
index f0a3d09..45e8f11 100644 (file)
@@ -39,7 +39,6 @@ import org.springframework.http.HttpStatus
 import org.springframework.http.MediaType
 import org.springframework.test.web.servlet.MockMvc
 import spock.lang.Specification
-import spock.lang.Unroll
 
 @WebMvcTest
 class NetworkCmProxyControllerSpec extends Specification {
@@ -62,7 +61,6 @@ class NetworkCmProxyControllerSpec extends Specification {
     def cmHandle = 'some handle'
     def xpath = 'some xpath'
 
-    @Unroll
     def 'Query data node by cps path for the given cm handle with #scenario.'() {
         given: 'service method returns a list containing a data node'
             def dataNode = new DataNodeBuilder().withXpath('/xpath').build()
@@ -86,7 +84,6 @@ class NetworkCmProxyControllerSpec extends Specification {
             'descendants'               | 'true'                   || INCLUDE_ALL_DESCENDANTS
     }
 
-    @Unroll
     def 'Create data node: #scenario.'() {
         given: 'json data'
             def jsonData = 'json data'
@@ -108,6 +105,23 @@ class NetworkCmProxyControllerSpec extends Specification {
             'parent node xpath'  | '/xpath' || '/xpath'
     }
 
+    def 'Add list-node elements.'() {
+        given: 'json data and parent node xpath'
+            def jsonData = 'json data'
+            def parentNodeXpath = 'parent node xpath'
+        when: 'post request is performed'
+            def response = mvc.perform(
+                    post("$dataNodeBaseEndpoint/cm-handles/$cmHandle/list-node")
+                            .contentType(MediaType.APPLICATION_JSON)
+                            .content(jsonData)
+                            .param('xpath', parentNodeXpath)
+            ).andReturn().response
+        then: 'the service method is invoked once with expected parameters'
+            1 * mockNetworkCmProxyDataService.addListNodeElements(cmHandle, parentNodeXpath, jsonData)
+        and: 'response status indicates success'
+            response.status == HttpStatus.CREATED.value()
+    }
+
     def 'Update data node leaves.'() {
         given: 'json data'
             def jsonData = 'json data'