Post impl for passthrough running (Ncmp impl.)
[cps.git] / cps-ncmp-service / src / test / groovy / org / onap / cps / ncmp / api / impl / client / DmiRestClientSpec.groovy
index 98bbe87..879c73c 100644 (file)
@@ -35,7 +35,7 @@ class DmiRestClientSpec extends Specification {
     def objectUnderTest = new DmiRestClient(mockRestTemplate, mockDmiProperties)
 
     def 'DMI PUT operation.'() {
-        given: 'a get url'
+        given: 'a PUT url'
             def getResourceDataUrl = 'http://some-uri/getResourceDataUrl'
         and: 'dmi properties'
             setupTestConfigurationData()
@@ -48,6 +48,20 @@ class DmiRestClientSpec extends Specification {
             result == mockResponseEntity
     }
 
+    def 'DMI POST operation.'() {
+        given: 'a POST url'
+            def getResourceDataUrl = 'http://some-uri/createResourceDataUrl'
+        and: 'dmi properties'
+            setupTestConfigurationData()
+        and: 'the rest template returns a valid response entity'
+            def mockResponseEntity = Mock(ResponseEntity)
+            mockRestTemplate.postForEntity(getResourceDataUrl, _ as HttpEntity, Void.class) >> mockResponseEntity
+        when: 'POST operation is invoked'
+            def result = objectUnderTest.postOperationWithJsonData(getResourceDataUrl, 'json-data', new HttpHeaders())
+        then: 'the output of the method is equal to the output from the test template'
+            result == mockResponseEntity
+    }
+
     def setupTestConfigurationData() {
         mockDmiProperties.authUsername >> 'some-username'
         mockDmiProperties.authPassword >> 'some-password'