PrivilegeManagementServiceImpl implements PrivilegeManagementService { @Override @Transactional public boolean deleteSubject(final String subjectIdentifier) { ZoneEntity zone = this.zoneResolver.getZoneEntityOrFail(); boolean deleted = false; SubjectEntity subjectEntity = this.subjectRepository.getByZoneAndSubjectIdentifier(zone, subjectIdentifier); if (subjectEntity != null) { this.cache.resetForSubjectsByIds(zone.getName(), this.subjectRepository.getSubjectEntityAndDescendantsIds(subjectEntity)); this.subjectRepository.delete(subjectEntity.getId()); deleted = true; LOGGER.info("Deleted subject with subjectIdentifier={}, zone = {}.", subjectIdentifier, 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 testDeleteSubject() { String subjectIdentifier = "/asset/santarita"; BaseSubject subject = createSubject(subjectIdentifier, this.fixedAttributes); this.service.upsertSubject(subject); boolean deleted = this.service.deleteSubject(subjectIdentifier); Assert.assertTrue(deleted); Assert.assertNull(this.service.getBySubjectIdentifier(subjectIdentifier)); }
@Test public void testDeleteInvalidSubject() { Assert.assertFalse(this.service.deleteSubject("invalid_id")); }