diff options
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/service/client')
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy | 16 | ||||
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy | 38 |
2 files changed, 27 insertions, 27 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy index 32df97b6..4d7e27e2 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/NcmpRestClientSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation + * Copyright (C) 2021-2022 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,8 +37,8 @@ class NcmpRestClientSpec extends Specification { } def 'Register a cm handle.'() { - given: 'json data' - def jsonData = 'some json' + given: 'some request data' + def someRequestData = 'some request data' and: 'configuration data' mockCpsProperties.baseUrl >> 'http://some-uri' mockCpsProperties.dmiRegistrationUrl >> 'some-url' @@ -46,12 +46,12 @@ class NcmpRestClientSpec extends Specification { mockCpsProperties.authPassword >> 'some-password' and: 'the rest template returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) - when: 'register cm-handle with ncmp is invoked' - def result = objectUnderTest.registerCmHandlesWithNcmp(jsonData) - then: 'the rest template is called with the correct uri and json in the body' + when: 'registering a cm handle' + def result = objectUnderTest.registerCmHandlesWithNcmp(someRequestData) + then: 'the rest template is called with the correct uri and original request data in the body' 1 * mockRestTemplate.exchange({ it.toString() == 'http://some-uri/some-url' }, - HttpMethod.POST, { it.body.contains(jsonData) }, String.class) >> mockResponseEntity - and: 'the output of the method is equal to the output from the test template' + HttpMethod.POST, { it.body.contains(someRequestData) }, String.class) >> mockResponseEntity + and: 'the output of the method is equal to the output from the rest template service' result == mockResponseEntity } }
\ No newline at end of file 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 8a3170b4..f334f780 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 @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation + * Copyright (C) 2021-2022 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,35 +40,35 @@ class SdncRestconfClientSpec extends Specification { def objectUnderTest = new SdncRestconfClient(mockSdncProperties, mockRestTemplate) def 'SDNC GET operation.'() { - given: 'a get url' + given: 'a get resource url' def getResourceUrl = '/getResourceUrl' - and: 'sdnc properties' + and: 'test configuration data' setupTestConfigurationData() - and: 'the rest template returns a valid response entity' + and: 'the process returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) mockRestTemplate.exchange({ it.toString() == 'http://some-uri/getResourceUrl' }, HttpMethod.GET, _ as HttpEntity, String.class) >> mockResponseEntity - when: 'GET operation is invoked' + when: 'the resource is fetched' def result = objectUnderTest.getOperation(getResourceUrl) - then: 'the output of the method is equal to the output from the test template' + then: 'the output of the method is equal to the output from the rest template service' result == mockResponseEntity } def 'SDNC #scenario operation called.'() { - given: 'json data' - def jsonData = 'some-json' + given: 'some request data' + def someRequestData = 'some request data' and: 'a url for get module resources' def getModuleResourceUrl = '/getModuleResourceUrl' - and: 'configuration data' + and: 'test configuration data' setupTestConfigurationData() - and: 'the rest template returns a valid response entity' + and: 'the process returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) - when: 'get module resources is invoked' - def result = objectUnderTest.httpOperationWithJsonData(expectedHttpMethod, getModuleResourceUrl, jsonData, new HttpHeaders()) + when: 'the resource is fetched' + def result = objectUnderTest.httpOperationWithJsonData(expectedHttpMethod, getModuleResourceUrl, someRequestData, 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' }, - expectedHttpMethod, { it.body.contains(jsonData) }, String.class) >> mockResponseEntity - and: 'the output of the method is the same as the output from the test template' + expectedHttpMethod, { it.body.contains(someRequestData) }, String.class) >> mockResponseEntity + and: 'the output of the method is the same as the output from the rest template service' result == mockResponseEntity where: 'the following values are used' scenario || expectedHttpMethod @@ -78,18 +78,18 @@ class SdncRestconfClientSpec extends Specification { 'DELETE' || DELETE } - def 'SDNC GET operation with header.'() { + def 'SDNC GET operation with headers.'() { given: 'a get url' def getResourceUrl = '/getResourceUrl' - and: 'sdnc properties' + and: 'test configuration data' setupTestConfigurationData() - and: 'the rest template returns a valid response entity' + and: 'the process returns a valid response entity' def mockResponseEntity = Mock(ResponseEntity) mockRestTemplate.exchange({ it.toString() == 'http://some-uri/getResourceUrl' }, HttpMethod.GET, _ as HttpEntity, String.class) >> mockResponseEntity - when: 'GET operation is invoked' + when: 'the resource is fetched with headers' def result = objectUnderTest.getOperation(getResourceUrl, new HttpHeaders()) - then: 'the output of the method is equal to the output from the test template' + then: 'the output of the method is equal to the output from the rest template service' result == mockResponseEntity } |