+
+ 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
+ }