aboutsummaryrefslogtreecommitdiffstats
path: root/cps-ri/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-04-05 12:59:57 +0300
committerRishi Chail <rishi.chail@est.tech>2021-04-07 11:45:24 +0000
commit4b8ae57149d157cfe8619f99dd8fb82e067f26ce (patch)
tree261d5e399b4532d82d2f47847ccee3e0551dd443 /cps-ri/src/test/groovy/org/onap
parent26effb23f559df0256327b8d37c865e023a41292 (diff)
Delete anchor part 1: service and persistence layers
Issue-ID: CPS-312 Change-Id: I10ab5a2d115ffdf8179a99b6ec712f3eccfb5f13 Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-ri/src/test/groovy/org/onap')
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsAdminPersistenceServiceSpec.groovy39
1 files changed, 32 insertions, 7 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 7ab099dd4..0d75d3fed 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
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
+ * Modifications Copyright (C) 2021 Pantheon.tech
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +37,8 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
static final String SET_DATA = '/data/anchor.sql'
static final String EMPTY_DATASPACE_NAME = 'DATASPACE-002'
+ static final Integer DELETED_ANCHOR_ID = 3001
+ static final Long DELETED_FRAGMENT_ID = 4001
@Sql(CLEAR_DATA)
def 'Create and retrieve a new dataspace.'() {
@@ -77,10 +80,10 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
then: 'an #expectedException is thrown'
thrown(expectedException)
where: 'the following data is used'
- scenario | dataspaceName | schemaSetName | anchorName || expectedException
- 'dataspace does not exist' | 'unknown' | 'not-relevant' | 'not-relevant' || DataspaceNotFoundException
- 'schema set does not exist' | DATASPACE_NAME | 'unknown' | 'not-relevant' || SchemaSetNotFoundException
- 'anchor already exists' | DATASPACE_NAME | SCHEMA_SET_NAME1 | ANCHOR_NAME1 || AlreadyDefinedException
+ scenario | dataspaceName | schemaSetName | anchorName || expectedException
+ 'dataspace does not exist' | 'unknown' | 'not-relevant' | 'not-relevant' || DataspaceNotFoundException
+ 'schema set does not exist' | DATASPACE_NAME | 'unknown' | 'not-relevant' || SchemaSetNotFoundException
+ 'anchor already exists' | DATASPACE_NAME | SCHEMA_SET_NAME1 | ANCHOR_NAME1 || AlreadyDefinedException
}
@Unroll
@@ -91,9 +94,9 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
then: 'an #expectedException is thrown'
thrown(expectedException)
where: 'the following data is used'
- scenario | dataspaceName | anchorName || expectedException
- 'dataspace does not exist' | 'unknown' | 'not-relevant' || DataspaceNotFoundException
- 'anchor does not exists' | DATASPACE_NAME | 'unknown' || AnchorNotFoundException
+ scenario | dataspaceName | anchorName || expectedException
+ 'dataspace does not exist' | 'unknown' | 'not-relevant' || DataspaceNotFoundException
+ 'anchor does not exists' | DATASPACE_NAME | 'unknown' || AnchorNotFoundException
}
@Unroll
@@ -118,4 +121,26 @@ class CpsAdminPersistenceServiceSpec extends CpsPersistenceSpecBase {
then: 'an DataspaceNotFoundException is thrown'
thrown(DataspaceNotFoundException)
}
+
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'Delete anchor'() {
+ when: 'delete anchor action is invoked'
+ objectUnderTest.deleteAnchor(DATASPACE_NAME, ANCHOR_NAME1)
+ then: 'anchor and associated data fragment are deleted'
+ assert anchorRepository.findById(DELETED_ANCHOR_ID).isEmpty()
+ assert fragmentRepository.findById(DELETED_FRAGMENT_ID).isEmpty()
+ }
+
+ @Unroll
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'delete anchor error scenario: #scenario'(){
+ when: 'delete anchor attempt is performed'
+ objectUnderTest.deleteAnchor(dataspaceName, anchorName)
+ then: 'an #expectedException is thrown'
+ thrown(expectedException)
+ where: 'the following data is used'
+ scenario | dataspaceName | anchorName || expectedException
+ 'dataspace does not exist' | 'unknown' | 'not-relevant' || DataspaceNotFoundException
+ 'anchor does not exists' | DATASPACE_NAME | 'unknown' || AnchorNotFoundException
+ }
}