@Test public void getUserFromUserIdReturnsUserWhenIdIsValid() throws Exception { given(userStore.userForId("testUserId")).willReturn(Optional.of(anyUser())); Optional<User> user = basicUserValidator.getUserFromUserId("testUserId"); assertThat(user, is(OptionalPresentMatcher.present())); }
@Override public Optional<User> getUserFromUserId(String userId) throws UserValidationException { if (userId != null) { try { return userStore.userForId(userId); } catch (AuthenticationUnavailableException e) { throw new UserValidationException(e); } } return Optional.empty(); }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromUserId(String userId) throws UserValidationException { if (userId != null) { try { return userStore.userForId(userId); } catch (AuthenticationUnavailableException e) { throw new UserValidationException(e); } } return Optional.empty(); } }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromUserId(String userId) throws UserValidationException { if (userId != null) { try { return userStore.userForId(userId); } catch (AuthenticationUnavailableException e) { throw new UserValidationException(e); } } return Optional.empty(); } BasicUserValidator(UserStore userStore, LoggedInUsers loggedInUsers); }
BasicUserValidator implements UserValidator { @Override public Optional<User> getUserFromUserId(String userId) throws UserValidationException { if (userId != null) { try { return userStore.userForId(userId); } catch (AuthenticationUnavailableException 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> getUserFromUserId(String userId) throws UserValidationException { if (userId != null) { try { return userStore.userForId(userId); } catch (AuthenticationUnavailableException 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);  }