diff options
author | JosephKeenan <joseph.keenan@est.tech> | 2022-02-15 18:23:05 +0000 |
---|---|---|
committer | JosephKeenan <joseph.keenan@est.tech> | 2022-02-28 15:25:58 +0000 |
commit | e0643ab5130dde375c229989e216341e623a9c55 (patch) | |
tree | ae0d551c6f904950a1263dd73b2ada099d636b34 /cps-ncmp-service/src/test/groovy | |
parent | 87de1fc8454fb1d93dfda7c5193783f16974cdaf (diff) |
CPS-887 Decreasing performance of cmHandle registration
- Creating temporary table module references from the
node
- Query returning new moduleReferences for node to be added to CPS
- Modified registration for node to use new implementation (incl. tests)
- Refactored some interface to use collection instead of list
- Modified SQL statements to use String.format()
- Fixed tests
Issue-ID: CPS-887
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Change-Id: I58b17d29e8b9d6f7a644d33bf6cf8bf46f892580
Diffstat (limited to 'cps-ncmp-service/src/test/groovy')
-rw-r--r-- | cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplModelSyncSpec.groovy | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplModelSyncSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplModelSyncSpec.groovy index 3af4fc00e9..3f82f5e0b7 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplModelSyncSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplModelSyncSpec.groovy @@ -50,26 +50,36 @@ class NetworkCmProxyDataServiceImplModelSyncSpec extends Specification { def cmHandle = new CmHandle() def dmiServiceName = 'some service name' cmHandle.cmHandleID = 'cm handle id 1' - cmHandle.dmiProperties = dmiProperties def persistenceCmHandle = PersistenceCmHandle.toPersistenceCmHandle(dmiServiceName, '' , '', cmHandle) and: 'DMI operations returns some module references' def moduleReferences = [ new ModuleReference(moduleName:'module1',revision:'1'), new ModuleReference(moduleName:'module2',revision:'2') ] mockDmiModelOperations.getModuleReferences(persistenceCmHandle) >> moduleReferences and: 'CPS-Core returns list of existing module resources' - mockCpsModuleService.getYangResourceModuleReferences(expectedDataspaceName) >> existingModuleResourcesInCps + mockCpsModuleService.getYangResourceModuleReferences(expectedDataspaceName) >> toModuleReference(existingModuleResourcesInCps) and: 'DMI-Plugin returns resource(s) for "new" module(s)' mockDmiModelOperations.getNewYangResourcesFromDmi(persistenceCmHandle, [new ModuleReference('module1', '1')]) >> yangResourceToContentMap when: 'module sync is triggered' + mockCpsModuleService.identifyNewModuleReferences(moduleReferences) >> toModuleReference(identifiedNewModuleReferences) objectUnderTest.syncModulesAndCreateAnchor(persistenceCmHandle) then: 'the CPS module service is called once with the correct parameters' - 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceName, persistenceCmHandle.getId(), yangResourceToContentMap, expectedKnownModules) + 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceName, persistenceCmHandle.getId(), yangResourceToContentMap, toModuleReference(expectedKnownModules)) and: 'admin service create anchor method has been called with correct parameters' 1 * mockCpsAdminService.createAnchor(expectedDataspaceName, persistenceCmHandle.getId(), persistenceCmHandle.getId()) where: 'the following parameters are used' - scenario | dmiProperties | existingModuleResourcesInCps | yangResourceToContentMap || expectedKnownModules - 'one unknown module' | ['name1': 'value1'] | [new ModuleReference('module2', '2'), new ModuleReference('module3', '3')] | [module1: 'some yang source'] || [new ModuleReference('module2', '2')] - 'no add. properties' | [:] | [new ModuleReference('module2', '2'), new ModuleReference('module3', '3')] | [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')] + scenario | existingModuleResourcesInCps | identifiedNewModuleReferences | yangResourceToContentMap || expectedKnownModules + 'one new module' | [['module2' : '2'], ['module3' : '3']] | [['module1' : '1']] | [module1: 'some yang source'] || [['module2' : '2']] + 'no add. properties' | [['module2' : '2'], ['module3' : '3']] | [['module1' : '1']] | [module1: 'some yang source'] || [['module2' : '2']] + 'no new module' | [['module1' : '1'], ['module2' : '2']] | [] | [:] || [['module1' : '1'], ['module2' : '2']] } + + def toModuleReference(moduleReferenceAsMap) { + def moduleReferences = [].withDefault { [:] } + moduleReferenceAsMap.forEach(property -> + property.forEach((moduleName, revision) -> { + moduleReferences.add(new ModuleReference('moduleName' : moduleName, 'revision' : revision)) + })) + return moduleReferences + } + } |