diff options
author | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2020-12-10 16:49:53 +0000 |
---|---|---|
committer | puthuparambil.aditya <aditya.puthuparambil@bell.ca> | 2020-12-10 16:55:54 +0000 |
commit | e182a6b6cb4a87b4f461adf83fe60a65948fc230 (patch) | |
tree | 1a8dbc71794cf742e5f9dd2ce6346c308cc1afc4 /cps-service/src/test | |
parent | a66dd4e82e8ef5b2cfe956a9a88a90154889635a (diff) |
Retrieve All anchors for a given Dataspace
Issue-ID: CPS-8
Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca>
Change-Id: Idb2e4f83d390f078345e556d89781e0bf4a9a41f
Diffstat (limited to 'cps-service/src/test')
-rw-r--r-- | cps-service/src/test/groovy/org/onap/cps/api/impl/CpsAdminServiceImplSpec.groovy | 22 |
1 files changed, 21 insertions, 1 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 65a8e71bca..d31a2f72d2 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 @@ -20,8 +20,8 @@ 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 @@ -52,4 +52,24 @@ class CpsAdminServiceImplSpec extends Specification { 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) + mockCpsAdminPersistenceService.getAnchors('dummyDataspace') >> { anchorCollection } + expect: 'we try to retrieve an anchor, a collection of anchor is returned by the service' + 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 + } } |