### Question:
PropertiesBasedAccessController implements AccessController, OrganizationResolver, SubjectResolver, LifecycleAspect { @Override public SessionDescriptor validate(Credentials credentials) throws InvalidCredentialsException { if (!(credentials instanceof SubjectCredentials)) { throw new InvalidCredentialsException("Cannot handle the type of provided credentials."); } PropertiesSubject subject = state.get().getSubject(SubjectCredentials.class.cast(credentials).getSubjectID()); if (subject == null || subject.isGroup()) { throw new InvalidCredentialsException("The presented credentials are not valid."); } return SubjectDescriptor.builder() .setIdentifier(SubjectIdentifier.builder().setInternalID(subject.getInternalID()).build()) .build(); } 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 testValidateWithValidCredentials() throws Exception { setup("subject.1.name = subject"); SessionDescriptor descriptor = accessController.validate(createCredentials(1)); assertTrue(descriptor instanceof SubjectDescriptor); assertEquals(1, ((SubjectDescriptor) descriptor).getIdentifier().getInternalID()); }
@Test(expected = InvalidCredentialsException.class) public void testValidateWithNullCredentials() throws Exception { setup("subject.1.name = subject"); accessController.validate(null); }
@Test(expected = InvalidCredentialsException.class) public void testValidateWithCredentialsOfWrongType() throws Exception { setup("subject.1.name = subject"); accessController.validate(new Credentials() {}); }
@Test(expected = InvalidCredentialsException.class) public void testValidateWithCredentialsForUnknownSubject() throws Exception { setup("subject.1.name = subject"); accessController.validate(createCredentials(42)); }
@Test(expected = InvalidCredentialsException.class) public void testValidateWithCredentialsForSubjectGroup() throws Exception { setup("subject.1.name = subject\n" + "subject.1.type = group"); accessController.validate(createCredentials(1)); }