CPS-635 - Module Resource call does not include body
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / operation / DmiOperationsSpec.groovy
index 3c9b164..6a1ce1a 100644 (file)
@@ -41,7 +41,7 @@ class DmiOperationsSpec extends Specification {
 
     def 'call get resource data for pass-through:operational datastore from DMI.'() {
         given: 'expected url'
-        def expectedUrl = 'testDmiBasePath/dmi/api/v1/ch/testCmhandle/data/ds' +
+        def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
                 '/ncmp-datastore:passthrough-operational/testResourceId?fields=testFieldsQuery&depth=10'
         when: 'get resource data is called to DMI'
         objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath',
@@ -56,7 +56,7 @@ class DmiOperationsSpec extends Specification {
     }
     def 'call get resource data for pass-through:running datastore from DMI.'() {
         given: 'expected url'
-        def expectedUrl = 'testDmiBasePath/dmi/api/v1/ch/testCmhandle/data/ds' +
+        def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
                 '/ncmp-datastore:passthrough-running/testResourceId?fields=testFieldsQuery&depth=10'
         when: 'get resource data is called to DMI'
         objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath',
@@ -71,7 +71,7 @@ class DmiOperationsSpec extends Specification {
     }
     def 'call create resource data for pass-through:running datastore from DMI.'() {
         given: 'expected url'
-        def expectedUrl = 'testDmiBasePath/dmi/api/v1/ch/testCmhandle/data/ds' +
+        def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' +
                 '/ncmp-datastore:passthrough-running/testResourceId'
         when: 'get resource data is called to DMI'
         objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath',
@@ -84,7 +84,7 @@ class DmiOperationsSpec extends Specification {
 
     def 'Call get resource from dmi.'() {
         given: 'expected url'
-            def expectedUrl = 'testDmiBasePath/dmi/api/v1/ch/testCmhandle/modules'
+            def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/modules'
         when: 'get resource data is called to dmi'
             objectUnderTest.getResourceFromDmi('testDmiBasePath',
                     'testCmhandle',
@@ -92,4 +92,18 @@ class DmiOperationsSpec extends Specification {
         then: 'the post operation is executed with the correct URL'
             1 * mockDmiRestClient.postOperation(expectedUrl, _ as HttpHeaders)
     }
+
+    def 'Call get resource from dmi with json data.'() {
+        given: 'expected url & json data'
+            def requestBody = 'some json'
+            def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmHandle/modules'
+            def expectedHttpHeaders = new HttpHeaders()
+        when: 'get resource data is called to dmi'
+            objectUnderTest.getResourceFromDmiWithJsonData('testDmiBasePath',
+                    requestBody,
+                    'testCmHandle',
+                    'modules')
+        then: 'the post operation is executed with the correct URL and json data'
+            1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, requestBody, expectedHttpHeaders)
+    }
 }
\ No newline at end of file