- and: 'any orphaned (not used by any schema set anymore) yang resources are deleted'
- def orphanedResourceId = 3100L
- yangResourceRepository.findById(orphanedResourceId).isPresent() == false
- and: 'any shared (still in use by other schema set) yang resources still persists'
- def sharedResourceId = 3003L
- yangResourceRepository.findById(sharedResourceId).isPresent()
- }
-
- @Sql([CLEAR_DATA, SET_DATA])
- def 'Delete schema set with cascade allowed.'() {
- when: 'a schema set is deleted with cascade-allowed option'
- objectUnderTest.deleteSchemaSet(DATASPACE_NAME, SCHEMA_SET_NAME_WITH_ANCHORS_AND_DATA,
- CASCADE_DELETE_ALLOWED)
- then: 'the schema set has been deleted'
- schemaSetRepository
- .findByDataspaceAndName(dataspaceEntity, SCHEMA_SET_NAME_WITH_ANCHORS_AND_DATA).isPresent() == false
- and: 'the associated anchors are removed'
- def associatedAnchorsIds = [ 6001, 6002 ]
- associatedAnchorsIds.each {anchorRepository.findById(it).isPresent() == false }
- and: 'the fragment(s) under those anchors are removed'
- def fragmentUnderAnchor1Id = 7001L
- fragmentRepository.findById(fragmentUnderAnchor1Id).isPresent() == false
- and: 'the shared resources still persist'
- def sharedResourceIds = [ 3003L, 3004L ]
- sharedResourceIds.each {yangResourceRepository.findById(it).isPresent() }