diff options
Diffstat (limited to 'src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy')
-rw-r--r-- | src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy index da8ff6b8..e456d411 100644 --- a/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy +++ b/src/test/groovy/org/onap/cps/ncmp/dmi/service/DmiServiceImplSpec.groovy @@ -22,6 +22,7 @@ package org.onap.cps.ncmp.dmi.service import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.cps.ncmp.dmi.TestUtils import org.onap.cps.ncmp.dmi.config.DmiPluginConfig import org.onap.cps.ncmp.dmi.exception.CmHandleRegistrationException import org.onap.cps.ncmp.dmi.exception.DmiException @@ -29,6 +30,8 @@ import org.onap.cps.ncmp.dmi.exception.ModuleResourceNotFoundException import org.onap.cps.ncmp.dmi.exception.ModulesNotFoundException import org.onap.cps.ncmp.dmi.exception.ResourceDataNotFound import org.onap.cps.ncmp.dmi.model.ModuleReference +import org.onap.cps.ncmp.dmi.model.ModuleSchemaList +import org.onap.cps.ncmp.dmi.model.ModuleSchemas import org.onap.cps.ncmp.dmi.service.client.NcmpRestClient import org.onap.cps.ncmp.dmi.service.operation.SdncOperations import org.springframework.http.HttpStatus @@ -49,12 +52,25 @@ class DmiServiceImplSpec extends Specification { given: 'cm handle id' def cmHandle = 'node1' and: 'request operation returns OK' - def body = 'body' + def body = TestUtils.getResourceFileContent('ModuleSchema.json') mockSdncOperations.getModulesFromNode(cmHandle) >> new ResponseEntity<String>(body, HttpStatus.OK) when: 'get modules for cm-handle is called' def result = objectUnderTest.getModulesForCmHandle(cmHandle) then: 'result is equal to the response from the SDNC service' - result == body + result.toString().contains('moduleName: example-identifier') + result.toString().contains('revision: example-version') + } + + def 'Call get modules for cm-handle with invalid json.'() { + given: 'cm handle id' + def cmHandle = 'node1' + and: 'request operation returns invalid json' + def body = TestUtils.getResourceFileContent('ModuleSchema.json') + mockSdncOperations.getModulesFromNode(cmHandle) >> new ResponseEntity<String>('invalid json', HttpStatus.OK) + when: 'get modules for cm-handle is called' + def result = objectUnderTest.getModulesForCmHandle(cmHandle) + then: 'a dmi exception is thrown' + thrown(DmiException) } def 'Call get modules for cm-handle and SDNC returns "bad request" status.'() { |