From 400b6c7a610e18e2c648a0680fe04b93792664cd Mon Sep 17 00:00:00 2001 From: tragait Date: Wed, 22 Sep 2021 10:50:15 +0100 Subject: fix fetch modules request body Issue-ID: CPS-653 Signed-off-by: tragait Change-Id: I6b5f0fc74ea4e70e65b05ed353e25311ed36135e --- .../ncmp/dmi/rest/controller/DmiRestControllerSpec.groovy | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/test') 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 dd5e79da..9c27dc1b 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 @@ -66,17 +66,17 @@ 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 moduleSetSchema = new ModuleSetSchemas() - moduleSetSchema.namespace('some-namespace') - moduleSetSchema.moduleName('some-moduleName') - moduleSetSchema.revision('some-revision') + def json = '{"operation" : "read", "cmHandleProperties" : {}}' + def moduleSetSchema = new ModuleSetSchemas(namespace:'some-namespace', + moduleName:'some-moduleName', + revision:'some-revision') def moduleSetSchemasList = [moduleSetSchema] as List def moduleSet = new ModuleSet() moduleSet.schemas(moduleSetSchemasList) mockDmiService.getModulesForCmHandle('node1') >> moduleSet when: 'post is being called' def response = mvc.perform(post(getModuleUrl) - .contentType(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON).content(json)) .andReturn().response then: 'status is OK' response.status == HttpStatus.OK.value() @@ -101,11 +101,12 @@ class DmiRestControllerSpec extends Specification { def 'Get all modules for given cm handle with exception handling of #scenario.'() { given: 'REST endpoint for getting all modules' def getModuleUrl = "$basePathV1/ch/node1/modules" - and: 'get modules for cm-handle throws #exceptionClass' + and: 'given request body and get modules for cm-handle throws #exceptionClass' + def json = '{"operation" : "read", "cmHandleProperties" : {}}' mockDmiService.getModulesForCmHandle('node1') >> { throw Mock(exceptionClass) } when: 'post is invoked' def response = mvc.perform( post(getModuleUrl) - .contentType(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON).content(json)) .andReturn().response then: 'response status is #expectedResponse' response.status == expectedResponse -- cgit 1.2.3-korg