### Question:
PropertiesBasedAccessController implements AccessController, OrganizationResolver, SubjectResolver, LifecycleAspect { @Override public Set<SubjectIdentity> getSubjectIdentities(Credentials credentials) throws InvalidCredentialsException { SessionDescriptor descriptor = validate(credentials); PropertiesSubject subject = getSubject(descriptor); Set<PropertiesSubject> parents = state.get().getParentSubjects(subject.getInternalID()); return SetUtils.addToSet(parents, subject) .stream() .map(s -> SubjectIdentifier.builder().setInternalID(s.getInternalID()).build()) .collect(Collectors.toSet()); } private  PropertiesBasedAccessController(String propertiesFile, long readingInterval); @Override SessionDescriptor validate(Credentials credentials); @Override boolean hasPermission(Credentials credentials, FunctionIdentity function); @Override boolean hasPermission(Credentials credentials, NamedFunction function); @Override boolean hasPermission(Credentials credentials, FunctionIdentity function, OrganizationIdentity organization); @Override boolean hasPermission(Credentials credentials, NamedFunction function, OrganizationIdentity organization); @Override Set<SubjectIdentity> getSubjectIdentities(Credentials credentials); @Override Set<OrganizationIdentity> getAvailableOrganizations(Credentials credentials); @Override Set<OrganizationIdentity> getDescendingOrganizations(Credentials credentials, OrganizationIdentity topLevelOrg); @Override Organization resolveOrganization(UUID id); @Override Organization resolveOrganization(String name); @Override Organization resolveCurrentUserAffiliation(Credentials credentials); @Override Subject resolveSubject(UUID id); @Override Subject resolveSubject(String name); @Override Subject resolveCurrentUser(Credentials credentials); @Override void startComponent(); @Override void stopComponent(); static Builder builder();  }### Answer:
@Test(expected = InvalidCredentialsException.class) public void testGetSubjectIdentitiesWithInvalidCredentials() throws Exception { setup("subject.1.name = subject"); accessController.getSubjectIdentities(createCredentials(42)); }
@Test public void testGetSubjectIdentitiesReturnsOnlySubject() throws Exception { setup("subject.1.name = subject"); Set<SubjectIdentity> subjects = accessController.getSubjectIdentities(createCredentials(1)); assertEquals(1, subjects.size()); assertSubjectID(subjects, 1); }
@Test public void testGetSubjectIdentitiesReturnsParents() throws Exception { String content = "" + "subject.1.name = subject1\n" + "subject.2.name = subject2\n" + "subject.2.type = group\n" + "subject.2.members = 1\n" + "subject.3.name = subject3\n" + "subject.3.type = group\n" + "subject.3.members = 2" + ""; setup(content); Set<SubjectIdentity> subjects = accessController.getSubjectIdentities(createCredentials(1)); assertEquals(3, subjects.size()); assertSubjectID(subjects, 1); assertSubjectID(subjects, 2); assertSubjectID(subjects, 3); }
@Test public void testGetSubjectIdentitiesOmitsOtherSubjects() throws Exception { String content = "" + "subject.1.name = subject1\n" + "subject.2.name = subject2\n" + "subject.3.name = subject3\n" + "subject.3.type = group\n" + "subject.3.members = 1,2\n" + "subject.4.name = subject4\n" + "subject.4.type = group\n" + "subject.4.members = 2" + ""; setup(content); Set<SubjectIdentity> subjects = accessController.getSubjectIdentities(createCredentials(1)); assertEquals(2, subjects.size()); assertSubjectID(subjects, 1); assertSubjectID(subjects, 3); }