summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/test/groovy/org
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ri/src/test/groovy/org')
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy1
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsModulePersistenceServiceIntegrationSpec.groovy32
2 files changed, 22 insertions, 11 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
index e41c71be7b..cff8d56321 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy
@@ -35,6 +35,7 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
@Autowired
CpsAdminPersistenceService objectUnderTest
+
static final String SET_DATA = '/data/anchor.sql'
static final String EMPTY_DATASPACE_NAME = 'DATASPACE-002'
static final Integer DELETED_ANCHOR_ID = 3001
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 f5d5fc6456..7a16a97d4b 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
@@ -56,7 +56,6 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
static final String SCHEMA_SET_NAME_WITH_ANCHORS_AND_DATA = 'SCHEMA-SET-101'
static final String SCHEMA_SET_NAME_NEW = 'SCHEMA-SET-NEW'
- static final Long NEW_RESOURCE_ABSTRACT_ID = 0L
static final String NEW_RESOURCE_NAME = 'some new resource'
static final String NEW_RESOURCE_CONTENT = 'module stores {\n' +
' yang-version 1.1;\n' +
@@ -102,11 +101,28 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
when: 'a new schemaset is stored'
objectUnderTest.storeSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, newYangResourcesNameToContentMap)
then: 'the schema set is persisted correctly'
- assertSchemaSetPersisted(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, NEW_RESOURCE_ABSTRACT_ID, NEW_RESOURCE_NAME,
+ assertSchemaSetPersisted(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, NEW_RESOURCE_NAME,
NEW_RESOURCE_CONTENT, NEW_RESOURCE_CHECKSUM, NEW_RESOURCE_MODULE_NAME, NEW_RESOURCE_REVISION)
}
@Sql([CLEAR_DATA, SET_DATA])
+ 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 listOfExistingModulesModuleReference = [moduleReferenceForExistingModule]
+ def mapOfExistingModule = [test: 'module test { yang-version 1.1; revision "2021-10-12" { } }']
+ objectUnderTest.storeSchemaSet(DATASPACE_NAME, "someSchemaSetName", mapOfExistingModule)
+ when: 'a new schema set is created from these new modules and existing modules'
+ objectUnderTest.storeSchemaSetFromModules(DATASPACE_NAME, "newSchemaSetName" , mapOfNewModules, listOfExistingModulesModuleReference)
+ then: 'the schema set can be retrieved'
+ def expectedYangResourcesMapAfterSchemaSetHasBeenCreated = mapOfNewModules + mapOfExistingModule
+ def actualYangResourcesMapAfterSchemaSetHasBeenCreated =
+ objectUnderTest.getYangSchemaResources(DATASPACE_NAME, "newSchemaSetName")
+ actualYangResourcesMapAfterSchemaSetHasBeenCreated == expectedYangResourcesMapAfterSchemaSetHasBeenCreated
+ }
+
+ @Sql([CLEAR_DATA, SET_DATA])
def 'Retrieving schema set (resources) by anchor.'() {
given: 'a new schema set is stored'
objectUnderTest.storeSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, newYangResourcesNameToContentMap)
@@ -135,14 +151,13 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
def newYangResourcesNameToContentMap = [(NEW_RESOURCE_NAME):existingResourceContent]
when: 'the schema set with duplicate resource is stored'
objectUnderTest.storeSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, newYangResourcesNameToContentMap)
- then: 'the schema persisted (re)uses the existing id, name and has the same checksum'
- def existingResourceId = 9L
+ then: 'the schema persisted (re)uses the existing name and has the same checksum'
def existingResourceName = 'module1@2020-02-02.yang'
def existingResourceChecksum = 'bea1afcc3d1517e7bf8cae151b3b6bfbd46db77a81754acdcb776a50368efa0a'
def existingResourceModelName = 'test'
def existingResourceRevision = '2020-09-15'
- assertSchemaSetPersisted(DATASPACE_NAME, SCHEMA_SET_NAME_NEW,
- existingResourceId, existingResourceName, existingResourceContent, existingResourceChecksum,
+ assertSchemaSetPersisted(DATASPACE_NAME, SCHEMA_SET_NAME_NEW, existingResourceName,
+ existingResourceContent, existingResourceChecksum,
existingResourceModelName, existingResourceRevision)
}
@@ -195,7 +210,6 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
def assertSchemaSetPersisted(expectedDataspaceName,
expectedSchemaSetName,
- expectedYangResourceId,
expectedYangResourceName,
expectedYangResourceContent,
expectedYangResourceChecksum,
@@ -214,10 +228,6 @@ class CpsModulePersistenceServiceIntegrationSpec extends CpsPersistenceSpecBase
// assert the attached yang resource content
YangResourceEntity yangResourceEntity = yangResourceEntities.iterator().next()
assert yangResourceEntity.id != null
- if (expectedYangResourceId != NEW_RESOURCE_ABSTRACT_ID) {
- // existing resource with known id
- assert yangResourceEntity.id == expectedYangResourceId
- }
yangResourceEntity.name == expectedYangResourceName
yangResourceEntity.content == expectedYangResourceContent
yangResourceEntity.checksum == expectedYangResourceChecksum