+
+ def 'Delete anchor.'() {
+ when: 'delete anchor is invoked'
+ objectUnderTest.deleteAnchor('someDataspace','someAnchor')
+ then: 'delete data nodes is invoked on the data service with expected parameters'
+ 1 * mockCpsDataService.deleteDataNodes('someDataspace','someAnchor', _ as OffsetDateTime )
+ and: 'the persistence service method is invoked with same parameters to delete anchor'
+ 1 * mockCpsAdminPersistenceService.deleteAnchor('someDataspace','someAnchor')
+ }
+
+ def 'Delete anchor with invalid #scenario.'() {
+ when: 'delete anchor is invoked'
+ objectUnderTest.deleteAnchor(dataspaceName, anchorName)
+ then: 'a data validation exception is thrown'
+ thrown(DataValidationException)
+ and: 'delete data nodes is invoked on the data service with expected parameters'
+ 0 * mockCpsDataService.deleteDataNodes(_,_, _ as OffsetDateTime )
+ and: 'the persistence service method is invoked with same parameters to delete anchor'
+ 0 * mockCpsAdminPersistenceService.deleteAnchor(_,_)
+ where: 'the following parameters are used'
+ scenario | dataspaceName | anchorName
+ 'dataspace name' | 'dataspace names with spaces' | 'anchorName'
+ 'anchor name' | 'dataspaceName' | 'anchor name with spaces'
+ 'dataspace and anchor name' | 'dataspace name with spaces' | 'anchor name with spaces'
+ }
+
+ def 'Query all anchor identifiers for a dataspace and module names.'() {
+ given: 'the persistence service is invoked with the expected parameters and returns a list of anchors'
+ mockCpsAdminPersistenceService.queryAnchors('some-dataspace-name', ['some-module-name']) >> [new Anchor(name:'some-anchor-identifier')]
+ expect: 'get anchor identifiers returns the same anchor identifier returned by the persistence layer'
+ objectUnderTest.queryAnchorNames('some-dataspace-name', ['some-module-name']) == ['some-anchor-identifier']
+
+ }
+
+ def 'Query all anchor identifiers for a dataspace and module names with an invalid dataspace name.'() {
+ when: 'delete anchor is invoked'
+ objectUnderTest.queryAnchorNames('some dataspace name', _ as Collection<String>)
+ then: 'a data validation exception is thrown'
+ thrown(DataValidationException)
+ and: 'delete data nodes is not invoked'
+ 0 * mockCpsAdminPersistenceService.queryAnchors(_, _)
+ }
+
+ def 'Delete dataspace.'() {
+ when: 'delete dataspace is invoked'
+ objectUnderTest.deleteDataspace('someDataspace')
+ then: 'associated persistence service method is invoked with correct parameter'
+ 1 * mockCpsAdminPersistenceService.deleteDataspace('someDataspace')
+ }
+
+ def 'Query CM Handles.'() {
+ given: 'a cm handle query'
+ def cmHandleQueryParameters = new CmHandleQueryParameters()
+ when: 'query cm handles is invoked'
+ objectUnderTest.queryCmHandles(cmHandleQueryParameters)
+ then: 'associated persistence service method is invoked with correct parameter'
+ 1 * mockCpsAdminPersistenceService.queryCmHandles(cmHandleQueryParameters)
+ }
+
+ def 'Delete dataspace with invalid dataspace id.'() {
+ when: 'delete dataspace is invoked'
+ objectUnderTest.deleteDataspace('some dataspace name')
+ then: 'a data validation exception is thrown'
+ thrown(DataValidationException)
+ and: 'associated persistence service method is not invoked'
+ 0 * mockCpsAdminPersistenceService.deleteDataspace(_)
+ }
+