PrivilegeManagementServiceImpl implements PrivilegeManagementService { @Override @Transactional public boolean deleteResource(final String resourceIdentifier) { ZoneEntity zone = this.zoneResolver.getZoneEntityOrFail(); boolean deleted = false; ResourceEntity resourceEntity = this.resourceRepository .getByZoneAndResourceIdentifier(zone, resourceIdentifier); if (resourceEntity != null) { this.cache.resetForResourcesByIds(zone.getName(), this.resourceRepository.getResourceEntityAndDescendantsIds(resourceEntity)); this.resourceRepository.delete(resourceEntity.getId()); deleted = true; LOGGER.info("Deleted resource with resourceId = {}, zone = {}.", resourceIdentifier, zone); } return deleted; }  @Override void appendResources(final List<BaseResource> resources); @Override @Transactional(readOnly = true) List<BaseResource> getResources(); @Override @Transactional(readOnly = true) BaseResource getByResourceIdentifier(final String resourceIdentifier); @Override @Transactional(readOnly = true) BaseResource getByResourceIdentifierWithInheritedAttributes(final String resourceIdentifier); @Override boolean upsertResource(final BaseResource resource); @Override @Transactional boolean deleteResource(final String resourceIdentifier); @Override void appendSubjects(final List<BaseSubject> subjects); @Override @Transactional(readOnly = true) List<BaseSubject> getSubjects(); @Override @Transactional(readOnly = true) BaseSubject getBySubjectIdentifier(final String subjectIdentifier); @Override @Transactional(readOnly = true) BaseSubject getBySubjectIdentifierWithInheritedAttributes(final String subjectIdentifier); @Override @Transactional(readOnly = true) BaseSubject getBySubjectIdentifierAndScopes(final String subjectIdentifier, final Set<Attribute> scopes); @Override boolean upsertSubject(final BaseSubject subject); @Override @Transactional boolean deleteSubject(final String subjectIdentifier); void setCache(final PolicyEvaluationCache cache);  }
@Test public void testDeleteResource() { String resourceIdentifier = "/asset/santarita"; BaseResource resource = doCreateResourceAndAssert(resourceIdentifier); String id = resource.getResourceIdentifier(); boolean deleted = this.service.deleteResource(id); Assert.assertTrue(deleted); Assert.assertNull(this.service.getByResourceIdentifier(id)); }
@Test public void testDeleteInvalidResource() { Assert.assertFalse(this.service.deleteResource("invalid_id")); }