### Question:
PropertiesBasedAccessController implements AccessController, OrganizationResolver, SubjectResolver, LifecycleAspect { @Override public Subject resolveSubject(UUID id) { PropertiesSubject subject = state.get().getSubject(IdMapper.toInternalID(id)); return ObjectUtils.ifNotNull(subject, s -> createSubject(id, s.getName(), state.get().getOrganization(s.getAffiliation()))); } 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 public void testResolveSubjectNotExistingSubject() throws Exception { setup("subject.1.name = subject"); assertNull(accessController.resolveSubject(UUID.fromString("00000000-0000-0000-0000-000000000002"))); }
@Test public void testResolveSubjectExistingSubjectWithoutAffiliation() throws Exception { setup("subject.1.name = subject"); UUID id = UUID.fromString("00000000-0000-0000-0000-000000000001"); Subject subject = accessController.resolveSubject(id); assertEquals(id, subject.getId()); assertEquals("subject", subject.getName()); assertNull(subject.getOrganization()); }
@Test public void testResolveSubjectExistingSubjectWithAffiliation() throws Exception { String content = "" + "subject.1.name = subject\n" + "subject.1.affiliation = 1\n" + "organization.1.name = organization\n" + ""; setup(content); UUID id = UUID.fromString("00000000-0000-0000-0000-000000000001"); Subject subject = accessController.resolveSubject(id); assertEquals(id, subject.getId()); assertEquals("subject", subject.getName()); assertNotNull(subject.getOrganization()); assertEquals(id, subject.getOrganization().getId()); assertEquals("organization", subject.getOrganization().getName()); }
@Test public void testResolveSubjectByNameNotExistingSubject() throws Exception { setup("subject.1.name = subject"); assertNull(accessController.resolveSubject("something")); }
@Test public void testResolveSubjectByNameExistingSubjectWithoutAffiliation() throws Exception { setup("subject.1.name = subject"); Subject subject = accessController.resolveSubject("subject"); assertEquals(UUID.fromString("00000000-0000-0000-0000-000000000001"), subject.getId()); assertEquals("subject", subject.getName()); assertNull(subject.getOrganization()); }
@Test public void testResolveSubjectByNameExistingSubjectWithAffiliation() throws Exception { String content = "" + "subject.1.name = subject\n" + "subject.1.affiliation = 1\n" + "organization.1.name = organization\n" + ""; setup(content); UUID id = UUID.fromString("00000000-0000-0000-0000-000000000001"); Subject subject = accessController.resolveSubject("subject"); assertEquals(id, subject.getId()); assertEquals("subject", subject.getName()); assertNotNull(subject.getOrganization()); assertEquals(id, subject.getOrganization().getId()); assertEquals("organization", subject.getOrganization().getName()); }