diff options
author | 2021-09-01 17:12:28 +0100 | |
---|---|---|
committer | 2021-09-06 14:06:16 +0000 | |
commit | d0422226b45f752086c9920bdead753c644d9289 (patch) | |
tree | 219118e284927589ad69dc4ded6d520e76e77530 /cps-ri/src/test/groovy | |
parent | c27465347d10b573e7a211c0b11b7c8a6fd792c0 (diff) |
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 <niamh.core@est.tech>
Change-Id: I0d0da7742ceef3a68e83a5dd4852091e6adf138b
Diffstat (limited to 'cps-ri/src/test/groovy')
-rw-r--r-- | cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy | 45 | ||||
-rw-r--r-- | cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistenceSpecBase.groovy | 1 |
2 files changed, 31 insertions, 15 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy index 7a16a97d4..a139830a2 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy @@ -20,22 +20,23 @@ */ package org.onap.cps.spi.impl -import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED -import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED - import org.onap.cps.spi.CpsAdminPersistenceService import org.onap.cps.spi.CpsModulePersistenceService import org.onap.cps.spi.entities.YangResourceEntity -import org.onap.cps.spi.exceptions.DataspaceNotFoundException import org.onap.cps.spi.exceptions.AlreadyDefinedException +import org.onap.cps.spi.exceptions.DataspaceNotFoundException import org.onap.cps.spi.exceptions.SchemaSetInUseException import org.onap.cps.spi.exceptions.SchemaSetNotFoundException import org.onap.cps.spi.model.ModuleReference +import org.onap.cps.spi.model.ExtendedModuleReference import org.onap.cps.spi.repository.AnchorRepository import org.onap.cps.spi.repository.SchemaSetRepository import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.jdbc.Sql +import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_ALLOWED +import static org.onap.cps.spi.CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED + class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase { @Autowired @@ -71,13 +72,13 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase static final String NEW_RESOURCE_CHECKSUM = 'b13faef573ed1374139d02c40d8ce09c80ea1dc70e63e464c1ed61568d48d539' static final String NEW_RESOURCE_MODULE_NAME = 'stores' static final String NEW_RESOURCE_REVISION = '2020-09-15' - static final ModuleReference newModuleReference = ModuleReference.builder().name(NEW_RESOURCE_MODULE_NAME) + static final ExtendedModuleReference newModuleReference = ExtendedModuleReference.builder().name(NEW_RESOURCE_MODULE_NAME) .revision(NEW_RESOURCE_REVISION).build() def newYangResourcesNameToContentMap = [(NEW_RESOURCE_NAME):NEW_RESOURCE_CONTENT] - def allYangResourcesModuleAndRevisionList = [ModuleReference.builder().build(),ModuleReference.builder().build(), - ModuleReference.builder().build(),ModuleReference.builder().build(), - ModuleReference.builder().build(), newModuleReference] + def allYangResourcesModuleAndRevisionList = [new ExtendedModuleReference(name: 'MODULE-NAME-002',namespace:null, revision: 'REVISION-002'), new ExtendedModuleReference(name: 'MODULE-NAME-003',namespace:null, revision: 'REVISION-003'), + new ExtendedModuleReference(name: 'MODULE-NAME-004',namespace:null, revision: 'REVISION-004'), ExtendedModuleReference.builder().build(), + ExtendedModuleReference.builder().build(), newModuleReference] def dataspaceEntity def setup() { @@ -109,7 +110,7 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase def 'Store and retrieve new schema set from new modules and existing modules.'() { given: 'map of new modules, a list of existing modules, module reference' def mapOfNewModules = [newModule1: 'module newmodule { yang-version 1.1; revision "2021-10-12" { } }'] - def moduleReferenceForExistingModule = new ModuleReference("test","test.org","2021-10-12") + def moduleReferenceForExistingModule = new ModuleReference("test","2021-10-12") def listOfExistingModulesModuleReference = [moduleReferenceForExistingModule] def mapOfExistingModule = [test: 'module test { yang-version 1.1; revision "2021-10-12" { } }'] objectUnderTest.storeSchemaSet(DATASPACE_NAME, "someSchemaSetName", mapOfExistingModule) @@ -135,13 +136,27 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase } @Sql([CLEAR_DATA, SET_DATA]) - def 'Retrieving all yang resources module references.'() { - given: 'a new schema set is stored' - objectUnderTest.storeSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, newYangResourcesNameToContentMap) - when: 'all yang resources module references are retrieved' - def result = objectUnderTest.getAllYangResourcesModuleReferences() + def 'Retrieving all yang resources module references for the given dataspace.'() { + given: 'a dataspace name' + def dataspaceName = 'DATASPACE-002' + when: 'all yang resources module references are retrieved for the given dataspace name' + def result = objectUnderTest.getAllYangResourceModuleReferences(dataspaceName) then: 'the correct resources are returned' - result.sort() == allYangResourcesModuleAndRevisionList.sort() + result.sort() == [new ModuleReference(moduleName: 'MODULE-NAME-005', revision: 'REVISION-002'), + new ModuleReference(moduleName: 'MODULE-NAME-006', revision: 'REVISION-006')] + } + + @Sql([CLEAR_DATA, SET_DATA]) + def 'Retrieving module names and revisions for the given anchor.'() { + given: 'a dataspace name and anchor name' + def dataspaceName = 'DATASPACE-001' + def anchorName = 'ANCHOR1' + when: 'all yang resources module references are retrieved for the given anchor' + def result = objectUnderTest.getAllYangResourceModuleReferences(dataspaceName, anchorName) + then: 'the correct module names and revisions are returned' + result.sort() == [new ModuleReference(moduleName: null, revision: null), new ModuleReference(moduleName: 'MODULE-NAME-002', revision: 'REVISION-002'), + new ModuleReference(moduleName: 'MODULE-NAME-003', revision: 'REVISION-002'), + new ModuleReference(moduleName: 'MODULE-NAME-004', revision: 'REVISION-004')] } @Sql([CLEAR_DATA, SET_DATA]) diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistenceSpecBase.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistenceSpecBase.groovy index 513263245..8ec5c90e9 100644 --- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistenceSpecBase.groovy +++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsPersistenceSpecBase.groovy @@ -55,6 +55,7 @@ class CpsPersistenceSpecBase extends Specification { static final String CLEAR_DATA = '/data/clear-all.sql' static final String DATASPACE_NAME = 'DATASPACE-001' + static final String DATASPACE_NAME2 = 'DATASPACE-002' static final String SCHEMA_SET_NAME1 = 'SCHEMA-SET-001' static final String SCHEMA_SET_NAME2 = 'SCHEMA-SET-002' static final String ANCHOR_NAME1 = 'ANCHOR-001' |