@Test public void getUserFromAccessTokenReturnsEmptyWhenAccessTokenIsInvalid() throws Exception { given(loggedInUsers.userFor("invalidAccessToken")).willReturn( null ); BasicUserValidator basicUserValidator2 = new BasicUserValidator(userStore, loggedInUsers); Optional<User> user = basicUserValidator2.getUserFromAccessToken("validAccessToken"); assertThat(user, is(Optional.empty())); }
@Override public Optional<User> getUserFromAccessToken(String accessToken) throws UserValidationException { if (accessToken != null) { try { Optional<User> user = loggedInUsers.userFor(accessToken); return user; } catch (Exception e) { throw new UserValidationException(e); } } return Optional.empty(); }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromAccessToken(String accessToken) throws UserValidationException { if (accessToken != null) { try { Optional<User> user = loggedInUsers.userFor(accessToken); return user; } catch (Exception e) { throw new UserValidationException(e); } } return Optional.empty(); } }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromAccessToken(String accessToken) throws UserValidationException { if (accessToken != null) { try { Optional<User> user = loggedInUsers.userFor(accessToken); return user; } catch (Exception e) { throw new UserValidationException(e); } } return Optional.empty(); } BasicUserValidator(UserStore userStore, LoggedInUsers loggedInUsers); }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromAccessToken(String accessToken) throws UserValidationException { if (accessToken != null) { try { Optional<User> user = loggedInUsers.userFor(accessToken); return user; } catch (Exception e) { throw new UserValidationException(e); } } return Optional.empty(); } BasicUserValidator(UserStore userStore, LoggedInUsers loggedInUsers); @Override Optional<User> getUserFromAccessToken(String accessToken); @Override Optional<User> getUserFromUserId(String userId); @Override Optional<User> getUserFromPersistentId(String persistentId); }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromAccessToken(String accessToken) throws UserValidationException { if (accessToken != null) { try { Optional<User> user = loggedInUsers.userFor(accessToken); return user; } catch (Exception e) { throw new UserValidationException(e); } } return Optional.empty(); } BasicUserValidator(UserStore userStore, LoggedInUsers loggedInUsers); @Override Optional<User> getUserFromAccessToken(String accessToken); @Override Optional<User> getUserFromUserId(String userId); @Override Optional<User> getUserFromPersistentId(String persistentId);  }