summaryrefslogtreecommitdiffstats
path: root/cps-service/src/test
diff options
context:
space:
mode:
authorRishi Chail <rishi.chail@est.tech>2020-12-17 12:55:49 +0000
committerGerrit Code Review <gerrit@onap.org>2020-12-17 12:55:49 +0000
commit1d9845679de45007db30eee42c105edcffd972fb (patch)
tree51434e7dfb545150d31c832690b1fd4464bc06a6 /cps-service/src/test
parentb9f857d3bf6d7fa8f9d0d5fa1796113d43e6e50d (diff)
parent8a1e3c9f90d2111835460fc042b4a63f93b80384 (diff)
Merge "Associate anchor to schema set"
Diffstat (limited to 'cps-service/src/test')
-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
- }
}