summaryrefslogtreecommitdiffstats
path: root/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-10-06 09:49:12 +0100
committerniamhcore <niamh.core@est.tech>2021-10-07 11:51:40 +0100
commitacc0f8b83a320b979cb5db23906f4ef3baf5f42c (patch)
tree581a83acb0129de9f061bc0b4fce0ecef83f50c1 /src/test/groovy/org/onap
parentf0acf5b1a4dd4bb774a81a7a75c48aeb81169fde (diff)
Updating get module schema request body
Issue-ID: CPS-706 Signed-off-by: niamhcore <niamh.core@est.tech> Change-Id: I92d241c4ccde77aaaf8aa5a3903437016edf65d0
Diffstat (limited to 'src/test/groovy/org/onap')
-rw-r--r--src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
index 3bc1f3be..ac78928d 100644
--- a/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
+++ b/src/test/groovy/org/onap/cps/ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy
@@ -65,7 +65,7 @@ class DmiRestControllerSpec extends Specification {
given: 'REST endpoint for getting all modules'
def getModuleUrl = "$basePathV1/ch/node1/modules"
and: 'get modules for cm-handle returns a json'
- def json = '{"operation" : "read", "cmHandleProperties" : {}}'
+ def json = '{"cmHandleProperties" : {}}'
def moduleSetSchema = new ModuleSetSchemas(namespace:'some-namespace',
moduleName:'some-moduleName',
revision:'some-revision')
@@ -101,7 +101,7 @@ class DmiRestControllerSpec extends Specification {
given: 'REST endpoint for getting all modules'
def getModuleUrl = "$basePathV1/ch/node1/modules"
and: 'given request body and get modules for cm-handle throws #exceptionClass'
- def json = '{"operation" : "read", "cmHandleProperties" : {}}'
+ def json = '{"cmHandleProperties" : {}}'
mockDmiService.getModulesForCmHandle('node1') >> { throw Mock(exceptionClass) }
when: 'post is invoked'
def response = mvc.perform( post(getModuleUrl)
@@ -150,7 +150,7 @@ class DmiRestControllerSpec extends Specification {
def 'Retrieve module resources.'() {
given: 'an endpoint and json data'
def getModulesEndpoint = "$basePathV1/ch/some-cm-handle/moduleResources"
- String jsonData = getJsonDataForGetModules('read')
+ String jsonData = TestUtils.getResourceFileContent('GetModules.json')
and: 'the DMI service returns the yang resources'
ModuleReference moduleReference1 = new ModuleReference(name: 'ietf-yang-library', revision: '2016-06-21')
ModuleReference moduleReference2 = new ModuleReference(name: 'nc-notifications', revision: '2008-07-14')
@@ -169,22 +169,10 @@ class DmiRestControllerSpec extends Specification {
response.getContentAsString() == '[{"yangSource":"\\"some-data\\"","moduleName":"NAME","revision":"REVISION"}]'
}
- def 'Retrieve module resources with invalid operation.'() {
- given: 'an endpoint and json data with invalid operation value'
- def getModulesEndpoint = "$basePathV1/ch/some-cm-handle/moduleResources"
- def jsonData = getJsonDataForGetModules('invalid operation')
- when: 'get module resource api is invoked'
- def response = mvc.perform(post(getModulesEndpoint)
- .contentType(MediaType.APPLICATION_JSON)
- .content(jsonData)).andReturn().response
- then: 'a conflict status is returned'
- response.status == HttpStatus.CONFLICT.value()
- }
-
def 'Retrieve module resources with exception handling.'() {
given: 'an endpoint and json data'
def getModulesEndpoint = "$basePathV1/ch/some-cm-handle/moduleResources"
- String jsonData = getJsonDataForGetModules('read')
+ String jsonData = TestUtils.getResourceFileContent('GetModules.json')
and: 'the service method is invoked to get module resources and throws an exception'
mockDmiService.getModuleResources('some-cm-handle', _) >> { throw Mock(ModuleResourceNotFoundException.class) }
when: 'get module resource api is invoked'
@@ -267,10 +255,4 @@ class DmiRestControllerSpec extends Specification {
'? needs to be encoded as %3F' | 'idWith%3F'
}
-
- def getJsonDataForGetModules(operation) {
- def jsonData = TestUtils.getResourceFileContent('GetModules.json')
- return jsonData.replace('${operation-for-test}', operation)
- }
-
}