PrivilegeManagementServiceImpl implements PrivilegeManagementService { @Override public void appendSubjects(final List<BaseSubject> subjects) { ZoneEntity zone = this.zoneResolver.getZoneEntityOrFail(); if (CollectionUtils.isEmpty(subjects)) { throw new PrivilegeManagementException("Null Or Empty list of subjects."); } validSubjectUrisOrFail(subjects); List<SubjectEntity> subjectEntities = new ArrayList<>(); appendSubjectsInTransaction(subjects, zone, subjectEntities); }  @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 testAppendSubjects() { try { BaseSubject s1 = createSubject("dave", this.fixedAttributes); BaseSubject s2 = createSubject("sanjeev", this.fixedAttributes); this.service.appendSubjects(asList(s1, s2)); Assert.assertNotNull(this.service.getBySubjectIdentifier(s1.getSubjectIdentifier())); Assert.assertNotNull(this.service.getBySubjectIdentifier(s2.getSubjectIdentifier())); } finally { this.service.deleteSubject("dave"); this.service.deleteSubject("sanjeev"); } }
@Test(expectedExceptions = PrivilegeManagementException.class) public void testAppendNullSubjects() { this.service.appendSubjects(null); }
@SuppressWarnings("unchecked") @Test(expectedExceptions = PrivilegeManagementException.class) public void testAppendEmptySubjects() { this.service.appendSubjects(Collections.EMPTY_LIST); }