diff options
Diffstat (limited to 'cps-ncmp-service/src/test')
3 files changed, 44 insertions, 33 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy index b5d4713959..1bad8ce0ba 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy @@ -371,7 +371,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { 'testResourceId', '{"operation":"create","dataType":"application/json","data":"{some-json}","cmHandleProperties":' + expectedJsonForCmhandleProperties+ '}') - >> { new ResponseEntity<>(HttpStatus.OK) } + >> { new ResponseEntity<>(HttpStatus.CREATED) } where: scenario | includeCmHandleProperties || expectedJsonForCmhandleProperties 'with' | true || '{"testName":"testValue"}' @@ -398,10 +398,7 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { } def 'Sync model for a (new) cm handle with #scenario'() { - given: 'DMI Plug-in returns a list of module references' - def knownModule1 = new ModuleReference('module1', '1') - def knownOtherModule = new ModuleReference('some other module', 'some revision') - and: 'persistence cm handle is given' + given: 'persistence cm handle is given' def cmHandleForModelSync = new PersistenceCmHandle(id:'some cm handle', dmiServiceName: 'some service name') and: 'additional properties are set as required' if (additionalProperties!=null) { @@ -415,23 +412,23 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { def moduleReferencesFromCmHandleAsJson = new ResponseEntity<String>(jsonData, HttpStatus.OK) mockDmiOperations.getResourceFromDmiWithJsonData('some service name', expectedJsonBody, 'some cm handle', 'modules') >> moduleReferencesFromCmHandleAsJson and: 'CPS-Core returns list of known modules' - mockCpsModuleService.getYangResourceModuleReferences(_) >> [knownModule1, knownOtherModule] + mockCpsModuleService.getYangResourceModuleReferences(_) >> existingModuleResourcesInCps and: 'DMI-Plugin returns resource(s) for "new" module(s)' def moduleResources = new ResponseEntity<String>(sdncReponseBody, HttpStatus.OK) - def jsonDataToFetchYangResource = '{"data":{"modules":[{"name":"module2","revision":"1"}]},"cmHandleProperties":' + expectedJsonForAdditionalProperties + '}' + def jsonDataToFetchYangResource = '{"data":{"modules":[{"name":"module1","revision":"1"}]},"cmHandleProperties":' + expectedJsonForAdditionalProperties + '}' mockDmiOperations.getResourceFromDmiWithJsonData('some service name', jsonDataToFetchYangResource, 'some cm handle', 'moduleResources') >> moduleResources when: 'module Sync is triggered' objectUnderTest.syncModulesAndCreateAnchor(cmHandleForModelSync) then: 'the CPS module service is called once with the correct parameters' - 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceName, cmHandleForModelSync.getId(), expectedYangResourceToContentMap, [knownModule1]) + 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceName, cmHandleForModelSync.getId(), expectedYangResourceToContentMap, expectedKnownModules) and: 'admin service create anchor method has been called with correct parameters' 1 * mockCpsAdminService.createAnchor(expectedDataspaceName, cmHandleForModelSync.getId(), cmHandleForModelSync.getId()) where: 'the following responses are received from SDNC' - scenario | additionalProperties | sdncReponseBody || expectedYangResourceToContentMap | expectedJsonForAdditionalProperties - 'one unknown module' | ['name1':'value1'] | '[{"moduleName" : "someModule", "revision" : "1","yangSource": "[some yang source]"}]' || [someModule: 'some yang source'] | '{"name1":"value1"}' - 'no add. properties' | [:] | '[{"moduleName" : "someModule", "revision" : "1","yangSource": "[some yang source]"}]' || [someModule: 'some yang source'] | '{}' - 'additional properties is null' | null | '[{"moduleName" : "someModule", "revision" : "1","yangSource": "[some yang source]"}]' || [someModule: 'some yang source'] | '{}' - 'no unknown module' | [:] | '[]' || [:] | '{}' + scenario | additionalProperties | existingModuleResourcesInCps | sdncReponseBody || expectedYangResourceToContentMap | expectedKnownModules | expectedJsonForAdditionalProperties + 'one unknown module' | ['name1':'value1'] | [new ModuleReference('module2', '2'), new ModuleReference('module3', '3')] | '[{"moduleName" : "module1", "revision" : "1","yangSource": "[some yang source]"}]' || [module1: 'some yang source'] | [new ModuleReference('module2', '2')] |'{"name1":"value1"}' + 'no add. properties' | [:] | [new ModuleReference('module2', '2'), new ModuleReference('module3', '3')] | '[{"moduleName" : "module1", "revision" : "1","yangSource": "[some yang source]"}]' || [module1: 'some yang source'] | [new ModuleReference('module2', '2')] |'{}' + 'additional properties is null' | null | [new ModuleReference('module2', '2'), new ModuleReference('module3', '3')] | '[{"moduleName" : "module1", "revision" : "1","yangSource": "[some yang source]"}]' || [module1: 'some yang source'] | [new ModuleReference('module2', '2')] |'{}' + 'no unknown module' | [:] | [new ModuleReference('module1', '1'), new ModuleReference('module2', '2')] | '[]' || [:] | [new ModuleReference('module1', '1'), new ModuleReference('module2', '2')] |'{}' } def 'Getting Yang Resources.'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy index 8e0fb76a56..9405b66325 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operation/DmiOperationsSpec.groovy @@ -41,27 +41,41 @@ class DmiOperationsSpec extends Specification { def 'call get resource data for pass-through:operational datastore from DMI.'() { given: 'expected url' - def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + - '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child&options=(a=1,b=2)' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child&options=(a=1,b=2)' when: 'get resource data is called to DMI' - objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath', - 'testCmhandle', - 'parent/child', - '(a=1,b=2)', - 'testAcceptJson', - 'testJsonbody') + objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + '(a=1,b=2)', + 'testAcceptJson', + 'testJsonbody') then: 'the put operation is executed with the correct URL' - 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) } def 'call get resource data for pass-through:running datastore from DMI.'() { given: 'expected url' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child&options=(a=1,b=2)' + when: 'get resource data is called to DMI' + objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + '(a=1,b=2)', + 'testAcceptJson', + 'testJsonbody') + then: 'the put operation is executed with the correct URL' + 1 * mockDmiRestClient.putOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + } + def 'call get resource data for pass-through:operational datastore from DMI when options is null.'() { + given: 'expected url' def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + - '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child&options=(a=1,b=2)' + '/ncmp-datastore:passthrough-operational?resourceIdentifier=parent/child' when: 'get resource data is called to DMI' - objectUnderTest.getResourceDataPassThroughRunningFromDmi('testDmiBasePath', + objectUnderTest.getResourceDataOperationalFromDmi('testDmiBasePath', 'testCmhandle', 'parent/child', - '(a=1,b=2)', + null, 'testAcceptJson', 'testJsonbody') then: 'the put operation is executed with the correct URL' @@ -69,15 +83,15 @@ class DmiOperationsSpec extends Specification { } def 'call create resource data for pass-through:running datastore from DMI.'() { given: 'expected url' - def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + - '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child' + def expectedUrl = 'testDmiBasePath/dmi/v1/ch/testCmhandle/data/ds' + + '/ncmp-datastore:passthrough-running?resourceIdentifier=parent/child' when: 'get resource data is called to DMI' - objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath', - 'testCmhandle', - 'parent/child', - 'testJsonbody') + objectUnderTest.createResourceDataPassThroughRunningFromDmi('testDmiBasePath', + 'testCmhandle', + 'parent/child', + 'testJsonbody') then: 'the put operation is executed with the correct URL' - 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) + 1 * mockDmiRestClient.postOperationWithJsonData(expectedUrl, 'testJsonbody', _ as HttpHeaders) } def 'Call get resource from dmi.'() { diff --git a/cps-ncmp-service/src/test/resources/cmHandleModules.json b/cps-ncmp-service/src/test/resources/cmHandleModules.json index d1665bee7d..43e8175ca0 100644 --- a/cps-ncmp-service/src/test/resources/cmHandleModules.json +++ b/cps-ncmp-service/src/test/resources/cmHandleModules.json @@ -6,7 +6,7 @@ }, { "moduleName": "module2", - "revision": "1", + "revision": "2", "namespace": "some namespace" }] }
\ No newline at end of file |