aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/test/groovy/org
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2020-11-24 11:13:43 +0200
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2020-12-17 14:40:53 +0200
commit8a1e3c9f90d2111835460fc042b4a63f93b80384 (patch)
treec26fa83be590816686d239580e161cc04e298197 /cps-service/src/test/groovy/org
parent84ac94d2f3f9ebd6a3a7befa244beef851eac126 (diff)
Associate anchor to schema set
- db schema updated - db layer tests provided for ancor create and reading by dataspace - anchor model is removed from rest api as extra - api/spi updated to use string references instead of object Issue-ID: CPS-99 Change-Id: Ideeb83fa9e91ec1816308d8327a6589b999c64c5 Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-service/src/test/groovy/org')
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy43
1 files changed, 9 insertions, 34 deletions
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
index d31a2f72d2..9e13c771d3 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy
@@ -21,55 +21,30 @@
package org.onap.cps.api.impl
import org.onap.cps.spi.CpsAdminPersistenceService
-import org.onap.cps.spi.exceptions.DataspaceNotFoundException
import org.onap.cps.spi.model.Anchor
import spock.lang.Specification
class CpsAdminServiceImplSpec extends Specification {
def mockCpsAdminPersistenceService = Mock(CpsAdminPersistenceService)
def objectUnderTest = new CpsAdminServiceImpl()
- def anchor = new Anchor()
def setup() {
objectUnderTest.cpsAdminPersistenceService = mockCpsAdminPersistenceService
}
- def 'Create an anchor'() {
- given: 'that the persistence service returns the name of the anchor'
- def anchorName = 'some anchor name'
- mockCpsAdminPersistenceService.createAnchor(_) >> anchorName
- expect: 'the same anchor name is returned by CPS Admin service'
- objectUnderTest.createAnchor(anchor) == anchorName
+ def 'Create anchor method invokes persistence service'() {
+ when: 'Create anchor method is invoked'
+ objectUnderTest.createAnchor('dummyDataspace', 'dummySchemaSet', 'dummyAnchorName')
+ then: 'The persistence service method is invoked with same parameters'
+ 1 * mockCpsAdminPersistenceService.createAnchor('dummyDataspace', 'dummySchemaSet', 'dummyAnchorName')
}
- def 'Create an anchor with some exception in the persistence layer'() {
- given: 'that the persistence service throws some exception'
- def exceptionThrownInPersistenceLayer = new RuntimeException()
- mockCpsAdminPersistenceService.createAnchor(_) >> { throw exceptionThrownInPersistenceLayer }
- when: 'we try to create an anchor'
- objectUnderTest.createAnchor(anchor)
- then: 'the same exception is thrown by the CPS Admin Service'
- def exceptionThrownInServiceLayer = thrown(Exception)
- exceptionThrownInServiceLayer == exceptionThrownInPersistenceLayer
- }
-
- def 'Retrieve all anchors for an existing dataspace'() {
- given: 'that the dataspace exist and an anchor is associated with the dataspace'
- Collection<Anchor> anchorCollection = Arrays.asList(anchor)
+ def 'Retrieve all anchors for dataspace'() {
+ given: 'that anchor is associated with the dataspace'
+ Collection<Anchor> anchorCollection = Arrays.asList(new Anchor())
mockCpsAdminPersistenceService.getAnchors('dummyDataspace') >> { anchorCollection }
- expect: 'we try to retrieve an anchor, a collection of anchor is returned by the service'
+ expect: 'the collection provided by persistence service is returned as result'
objectUnderTest.getAnchors('dummyDataspace') == anchorCollection
}
- def 'Retrieve all anchors for a non existing dataspace'() {
- given: 'that the dataspace does not exist, service throws an exception'
- def exceptionThrownInPersistenceLayer = new DataspaceNotFoundException(_ as String)
- mockCpsAdminPersistenceService.getAnchors('dummyDataspace') >>
- { throw exceptionThrownInPersistenceLayer }
- when: 'we try to retrieve a anchor with a non-existant dataspace'
- objectUnderTest.getAnchors('dummyDataspace')
- then: 'the same exception is thrown by CPS'
- def exceptionThrownInServiceLayer = thrown(Exception)
- exceptionThrownInServiceLayer == exceptionThrownInPersistenceLayer
- }
}