diff options
author | 2021-11-08 14:27:18 +0000 | |
---|---|---|
committer | 2021-11-09 10:29:18 +0000 | |
commit | 6804157f3ee5b1268e53ae86e4767ee267d48eec (patch) | |
tree | 1f7e4543257c5ff5d99f5f073dd17270c993ada8 /cps-ri/src/test | |
parent | 94a4b4575f4b5bfe53817db831cc7270dc2abae9 (diff) |
Fix for get anchor identifiers by module names
Issue-ID: CPS-762
Signed-off-by: niamhcore <niamh.core@est.tech>
Change-Id: Idf93f89f8427c5906c9f6b018633c8852b111821
Diffstat (limited to 'cps-ri/src/test')
-rw-r--r-- | cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy | 18 | ||||
-rw-r--r-- | cps-ri/src/test/resources/data/anchors-schemaset-modules.sql | 36 |
2 files changed, 28 insertions, 26 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 af199be03..a0df2b169 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 @@ -146,16 +146,15 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase { @Sql([CLEAR_DATA, SAMPLE_DATA_FOR_ANCHORS_WITH_MODULES]) def 'Query anchors that have #scenario.'() { when: 'all anchor are retrieved for the given dataspace name and module names' - def anchors = objectUnderTest.queryAnchors('DATASPACE-001', inputModuleNames) + def anchors = objectUnderTest.queryAnchors('dataspace-1', inputModuleNames) then: 'the expected anchors are returned' anchors.size() == expectedAnchors.size() anchors.containsAll(expectedAnchors) where: 'the following data is used' - scenario | inputModuleNames || expectedAnchors - 'one module' | ['MODULE-NAME-001'] || [buildAnchor('ANCHOR1', 'DATASPACE-001', 'SCHEMA-SET-001')] - 'two modules' | ['MODULE-NAME-001', 'MODULE-NAME-002'] || [buildAnchor('ANCHOR1', 'DATASPACE-001', 'SCHEMA-SET-001'), buildAnchor('ANCHOR2', 'DATASPACE-001', 'SCHEMA-SET-002'), buildAnchor('ANCHOR3', 'DATASPACE-001', 'SCHEMA-SET-004')] - 'a module attached to multiple anchors' | ['MODULE-NAME-003'] || [buildAnchor('ANCHOR1', 'DATASPACE-001', 'SCHEMA-SET-001'), buildAnchor('ANCHOR2', 'DATASPACE-001', 'SCHEMA-SET-002')] - 'same module with different revisions' | ['MODULE-NAME-002'] || [buildAnchor('ANCHOR2', 'DATASPACE-001', 'SCHEMA-SET-002'), buildAnchor('ANCHOR3', 'DATASPACE-001', 'SCHEMA-SET-004')] + scenario | inputModuleNames || expectedAnchors + 'one module' | ['module-name-1'] || [buildAnchor('anchor-2', 'dataspace-1', 'schema-set-2'), buildAnchor('anchor-1', 'dataspace-1', 'schema-set-1')] + 'two modules' | ['module-name-1', 'module-name-2'] || [buildAnchor('anchor-2', 'dataspace-1', 'schema-set-2'), buildAnchor('anchor-1', 'dataspace-1', 'schema-set-1')] + 'no anchors for all three modules' | ['module-name-1', 'module-name-2', 'module-name-3'] || [] } @Sql([CLEAR_DATA, SAMPLE_DATA_FOR_ANCHORS_WITH_MODULES]) @@ -166,10 +165,9 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase { def thrownException = thrown(expectedException) thrownException.details.contains(expectedMessageDetails) where: 'the following data is used' - scenario | dataspaceName | moduleNames || expectedException | expectedMessageDetails - 'existing module in an unknown dataspace' | 'db-does-not-exist' | ['does-not-matter'] || DataspaceNotFoundException | 'db-does-not-exist' - 'unknown module in an existing dataspace' | 'DATASPACE-001' | ['module-does-not-exist'] || ModuleNamesNotFoundException | 'module-does-not-exist' - 'unknown module and known module in an existing dataspace' | 'DATASPACE-001' | ['MODULE-NAME-001', 'module-does-not-exist'] || ModuleNamesNotFoundException | 'module-does-not-exist' + scenario | dataspaceName | moduleNames || expectedException | expectedMessageDetails | messageDoesNotContain + 'unknown dataspace' | 'db-does-not-exist' | ['does-not-matter'] || DataspaceNotFoundException | 'db-does-not-exist' | 'does-not-matter' + 'unknown module and known module' | 'dataspace-1' | ['module-name-1', 'module-does-not-exist'] || ModuleNamesNotFoundException | 'module-does-not-exist' | 'module-name-1' } def buildAnchor(def anchorName, def dataspaceName, def SchemaSetName) { diff --git a/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql b/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql index d2b67f5ae..45119dec0 100644 --- a/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql +++ b/cps-ri/src/test/resources/data/anchors-schemaset-modules.sql @@ -19,27 +19,31 @@ */ INSERT INTO DATASPACE (ID, NAME) VALUES - (1001, 'DATASPACE-001'), (1002, 'DATASPACE-002'); + (1001, 'dataspace-1'), (1002, 'dataspace-2'); INSERT INTO SCHEMA_SET (ID, NAME, DATASPACE_ID) VALUES - (2001, 'SCHEMA-SET-001', 1001), - (2002, 'SCHEMA-SET-002', 1002), - (2003, 'SCHEMA-SET-003', 1001), - (2004, 'SCHEMA-SET-004', 1001); + (2001, 'schema-set-1', 1001), + (2002, 'schema-set-2', 1001), + (2003, 'schema-set-3', 1001), + (2004, 'schema-set-4', 1002); INSERT INTO YANG_RESOURCE (ID, NAME, CONTENT, CHECKSUM, MODULE_NAME, REVISION) VALUES - (3001, 'module1@2020-02-02.yang', 'CONTENT-001', 'checksum1','MODULE-NAME-001',null), - (3002, 'module2@2020-02-02.yang', 'CONTENT-002', 'checksum2','MODULE-NAME-002','REVISION-002'), - (3003, 'module3@2020-02-02.yang', 'CONTENT-003', 'checksum3','MODULE-NAME-003','REVISION-003'), - (3004, 'module4@2020-02-02.yang', 'CONTENT-004', 'checksum4','MODULE-NAME-004','REVISION-004'), - (3005, 'module5@2020-03-02.yang', 'CONTENT-005', 'checksum5','MODULE-NAME-002','REVISION-003'); + (3001, 'module1@revA.yang', 'some-content', 'checksum1','module-name-1','revA'), + (3002, 'module2@revA.yang', 'some-content', 'checksum2','module-name-2','revA'), + (3003, 'module2@revB.yang', 'some-content', 'checksum3','module-name-2','revB'), + (3004, 'module3@revA.yang', 'some-content', 'checksum4','module-name-3','revA'); INSERT INTO SCHEMA_SET_YANG_RESOURCES (SCHEMA_SET_ID, YANG_RESOURCE_ID) VALUES - (2001, 3001), (2002, 3002), - (2001, 3003), (2002, 3003), - (2003, 3004), (2004, 3005); + (2001, 3001), --schema-set-1(anchor-1) has modules module1@revA, module2@revA + (2001, 3002), + (2002, 3001), --schema-set-2(anchor-2) has modules module1@revA, module2@revB + (2002, 3003), + (2003, 3002), --schema-set-3(anchor-3) has modules module2@revA, module2@revB + (2003, 3003), + (2004, 3001); --schema-set-4(anchor-4) has module module1@revA but in other dataspace INSERT INTO ANCHOR (ID, NAME, DATASPACE_ID, SCHEMA_SET_ID) VALUES - (6001, 'ANCHOR1', 1001, 2001), - (6002, 'ANCHOR2', 1001, 2002), - (6003, 'ANCHOR3', 1001, 2004); + (6001, 'anchor-1', 1001, 2001), + (6002, 'anchor-2', 1001, 2002), + (6003, 'anchor-3', 1001, 2003), + (6005, 'anchor-4', 1002, 2004); |