From d0422226b45f752086c9920bdead753c644d9289 Mon Sep 17 00:00:00 2001 From: niamhcore Date: Wed, 1 Sep 2021 17:12:28 +0100 Subject: P1 - Get module name and revision persistence layer Rename ModuleReference to ExtendedModuleReference Create new ModuleReference class (moduleName and revision) Update existing sync model flow to use new module reference class Create native query to get module name and revision Issue-ID: CPS-485 Signed-off-by: niamhcore Change-Id: I0d0da7742ceef3a68e83a5dd4852091e6adf138b --- .../ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy | 12 ++++++------ .../org/onap/cps/ncmp/api/models/moduleReferenceSpec.groovy | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cps-ncmp-service/src/test/groovy/org/onap') 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 b42db57233..ff3e0cd157 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 @@ -357,23 +357,23 @@ class NetworkCmProxyDataServiceImplSpec extends Specification { def 'Sync model for a (new) cm handle with #scenario'() { given: 'DMI PLug-in returns a list of module references' getModulesForCmHandle() - def knownModule1 = new ModuleReference('module1', NO_NAMESPACE, '1') - def knownOtherModule = new ModuleReference('some other module', NO_NAMESPACE, 'some revision') + def knownModule1 = new ModuleReference('module1', '1') + def knownOtherModule = new ModuleReference('some other module', 'some revision') and: 'CPS-Core returns list of known modules' - mockCpsModuleService.getAllYangResourcesModuleReferences() >> [knownModule1, knownOtherModule] + mockCpsModuleService.getAllYangResourceModuleReferences(_) >> [knownModule1, knownOtherModule] and: 'DMI-Plugin returns resource(s) for "new" module(s)' def moduleResources = new ResponseEntity(sdncReponseBody, HttpStatus.OK) mockDmiOperations.getResourceFromDmi(_, cmHandleForModelSync.getId(), 'moduleResources') >> moduleResources when: 'module Sync is triggered' objectUnderTest.createAnchorAndSyncModel(cmHandleForModelSync) then: 'the CPS module service is called once with the correct parameters' - 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceNameForModleSync, cmHandleForModelSync.getId(), expectedYangResourceToContentMap , [knownModule1]) + 1 * mockCpsModuleService.createSchemaSetFromModules(expectedDataspaceNameForModleSync, cmHandleForModelSync.getId(), expectedYangResourceToContentMap, [knownModule1]) and: 'admin service create anchor method has been called with correct parameters' 1 * mockCpsAdminService.createAnchor(expectedDataspaceNameForModleSync, cmHandleForModelSync.getId(), cmHandleForModelSync.getId()) where: 'the following responses are recieved from SDNC' - scenario | sdncReponseBody || expectedYangResourceToContentMap + scenario | sdncReponseBody || expectedYangResourceToContentMap 'one unknown module' | '[{"moduleName" : "someModule", "revision" : "1","yangSource": "someResource"}]' || [someModule: 'someResource'] - 'no unknown module' | '[]' || [:] + 'no unknown module' | '[]' || [:] } def getModulesForCmHandle() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/moduleReferenceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/moduleReferenceSpec.groovy index d6cb4635d8..9f161a9e53 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/moduleReferenceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/models/moduleReferenceSpec.groovy @@ -1,14 +1,14 @@ package org.onap.cps.ncmp.api.models -import org.onap.cps.spi.model.ModuleReference +import org.onap.cps.spi.model.ExtendedModuleReference import spock.lang.Specification class moduleReferenceSpec extends Specification { def 'lombok data annotation correctly implements toString() and hashCode() methods'() { given: 'two moduleReference objects' - def moduleReference1 = new ModuleReference('module1', "some namespace", '1') - def moduleReference2 = new ModuleReference('module1', "some namespace", '1') + def moduleReference1 = new ExtendedModuleReference('module1', "some namespace", '1') + def moduleReference2 = new ExtendedModuleReference('module1', "some namespace", '1') when: 'lombok generated methods are called' then: 'the methods exist and behaviour is accurate' assert moduleReference1.toString() == moduleReference2.toString() -- cgit 1.2.3-korg