summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
diff options
context:
space:
mode:
authoremaclee <lee.anjella.macabuhay@est.tech>2022-07-15 12:31:46 +0100
committeremaclee <lee.anjella.macabuhay@est.tech>2022-07-26 10:18:46 +0100
commitf5f5e6be4e7d222a7530b96d2d77ed611934822f (patch)
treee329f206b51163aa70d853bed82010bc820f77bf /src/test/groovy/org/onap/cps/ncmp/dmi/service/client/SdncRestconfClientSpec.groovy
parentaf8d434068e6f0d2b88c152b069afdcaf162f6c2 (diff)
Groovy clean tests clean-up
- test labels are modified to set standards for writing tests - labels are not expected to be technical - labels need to be in simple language that ANYONE can understand - labels should not have exact method names except for some mocking - variables are modified to give highlight to ONLY important parameter of test - wild cards are preferred when possible i.e. for exception cases Issue-ID: CPS-588 Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech> Change-Id: I3d42471e7aa4bc61f962ad19cc1f237f6985a9a2
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.groovy38
1 files changed, 19 insertions, 19 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 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
}