summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
diff options
context:
space:
mode:
authorDylanB95EST <dylan.byrne@est.tech>2021-11-09 13:54:35 +0000
committerDylanB95EST <dylan.byrne@est.tech>2021-11-12 15:24:27 +0000
commit5fe0daebb1360bd5d4c525125cdb0d6250583ff4 (patch)
tree3c0e08b48627b9c7c4c20c0291c6290673f061fb /src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
parent306cadd63b69274afbb3073d35a15381a12d6389 (diff)
Support Update and Delete operations for DS Passtrough-Running in DMI Plugin
-Add Update operation for Passthrough Running -Use POST operatiosn for all methods as agrred -refactor to simplify and beter reuse of common methods -add delete operation for passthrough running Issue-ID: CPS-637 Issue-ID: CPS-638 Change-Id: I441181f977dee2bc0be944662465d868595ea452 Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
index 2184c7e7..8a3170b4 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
@@ -28,6 +28,11 @@ import org.springframework.http.ResponseEntity
import org.springframework.web.client.RestTemplate
import spock.lang.Specification
+import static org.springframework.http.HttpMethod.GET
+import static org.springframework.http.HttpMethod.POST
+import static org.springframework.http.HttpMethod.DELETE
+import static org.springframework.http.HttpMethod.PUT
+
class SdncRestconfClientSpec extends Specification {
def mockSdncProperties = Mock(DmiConfiguration.SdncProperties)
@@ -49,7 +54,7 @@ class SdncRestconfClientSpec extends Specification {
result == mockResponseEntity
}
- def 'SDNC POST operation called.'() {
+ def 'SDNC #scenario operation called.'() {
given: 'json data'
def jsonData = 'some-json'
and: 'a url for get module resources'
@@ -59,12 +64,18 @@ class SdncRestconfClientSpec extends Specification {
and: 'the rest template returns a valid response entity'
def mockResponseEntity = Mock(ResponseEntity)
when: 'get module resources is invoked'
- def result = objectUnderTest.postOperationWithJsonData(getModuleResourceUrl, jsonData, new HttpHeaders())
+ def result = objectUnderTest.httpOperationWithJsonData(expectedHttpMethod, getModuleResourceUrl, jsonData, new HttpHeaders())
then: 'the rest template is called with the correct uri and json in the body'
1 * mockRestTemplate.exchange({ it.toString() == 'http://some-uri/getModuleResourceUrl' },
- HttpMethod.POST, { it.body.contains(jsonData) }, String.class) >> mockResponseEntity
+ expectedHttpMethod, { it.body.contains(jsonData) }, String.class) >> mockResponseEntity
and: 'the output of the method is the same as the output from the test template'
result == mockResponseEntity
+ where: 'the following values are used'
+ scenario || expectedHttpMethod
+ 'POST' || POST
+ 'PUT' || PUT
+ 'GET' || GET
+ 'DELETE' || DELETE
}
def 'SDNC GET operation with header.'() {