diff options
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.groovy | 17 |
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.'() { |