InMemoryResourceOwnerRepository implements ResourceOwnerStore, ResourceOwnerAuthentication, SessionSecurity { @Override public Optional<Session> auth(String username, String password, String remoteAddress) { if (resourceOwners.containsKey(username)) { if (password.equals(resourceOwners.get(username).password)) { Session session = new Session(tokenGenerator.generate()); sessions.add(session); return Optional.of(session); } } return Optional.absent(); } @Inject  InMemoryResourceOwnerRepository(TokenGenerator tokenGenerator); @Override void save(ResourceOwner resourceOwner); @Override Optional<Session> auth(String username, String password, String remoteAddress); @Override Boolean exists(Session session);  }
@Test public void notExistingUser() throws Exception { Optional<Session> session = repository.auth("joro", "123456", remoteAddress); assertFalse(session.isPresent()); }