-
- def 'Create an anchor with a non-existant dataspace'(){
- given: 'that the dataspace does not exist service throws an exception'
- AnchorDetails anchorDetails = new AnchorDetails()
- anchorDetails.setDataspace('dummyDataspace')
- mockFragmentPersistenceService.createAnchor(anchorDetails) >> {throw new CpsValidationException(_ as String, _ as String)}
- when: 'we try to create a anchor with a non-existant dataspace'
- objectUnderTest.createAnchor(anchorDetails)
- then: 'the same exception is thrown by CPS'
- thrown(CpsValidationException)
- }
-
- def 'Create an anchor with invalid dataspace, namespace and revision'(){
- given: 'that the dataspace, namespace and revison combination does not exist service throws an exception'
- AnchorDetails anchorDetails = new AnchorDetails()
- anchorDetails.setDataspace('dummyDataspace')
- anchorDetails.setNamespace('dummyNamespace')
- anchorDetails.setRevision('dummyRevision')
- mockFragmentPersistenceService.createAnchor(anchorDetails) >> {throw new CpsValidationException(_ as String, _ as String)}
- when: 'we try to create a anchor with a non-existant dataspace, namespace and revison combination'
- objectUnderTest.createAnchor(anchorDetails)
- then: 'the same exception is thrown by CPS'
- thrown(CpsValidationException)
- }
-
- def 'Create a duplicate anchor'(){
- given: 'that the anchor already exist service throws an exception'
- AnchorDetails anchorDetails = new AnchorDetails()
- anchorDetails.setDataspace('dummyDataspace')
- anchorDetails.setNamespace('dummyNamespace')
- anchorDetails.setRevision('dummyRevision')
- anchorDetails.setRevision('dummyAnchorName')
- mockFragmentPersistenceService.createAnchor(anchorDetails) >> {throw new CpsValidationException(_ as String, _ as String)}
- when: 'we try to create a duplicate anchor'
- objectUnderTest.createAnchor(anchorDetails)
- then: 'the same exception is thrown by CPS'
- thrown(CpsValidationException)
- }
-
- def 'Create an anchor with supplied anchor name, dataspace, namespace and revision'(){
- given: 'that the anchor does not pre-exist service creates an anchor'
- AnchorDetails anchorDetails = new AnchorDetails()
- anchorDetails.setDataspace('dummyDataspace')
- anchorDetails.setNamespace('dummyNamespace')
- anchorDetails.setRevision('dummyRevision')
- anchorDetails.setRevision('dummyAnchorName')
- mockFragmentPersistenceService.createAnchor(anchorDetails) >> 'dummyAnchorName'
- expect: 'anchor name is returned by service'
- objectUnderTest.createAnchor(anchorDetails) == 'dummyAnchorName'
- }