@Test public void createUserThrowsAUserCreationExceptionWhenTheUsersFileCannotBeRead() throws Exception { Path nonExistingUsersFile = Paths.get("src", "test", "resources", "users1.json"); JsonBasedUserStore instance = forFile(nonExistingUsersFile); expectedException.expect(UserCreationException.class); instance.createUser("pid", "email", "givenName", "surname", "organization"); }
@Override public User createUser(String pid, String email, String givenName, String surname, String organization) throws UserCreationException { User user = User.create(String.format("%s %s", givenName, surname), pid); try { Optional<User> userForPid = userAccess.getUserForPid(pid); if (userForPid.isPresent()) { return userForPid.get(); } else { userAccess.addUser(user); return user; } } catch (AuthenticationUnavailableException e) { throw new UserCreationException(e); } }
JsonBasedUserStore implements UserStore, UserCreator { @Override public User createUser(String pid, String email, String givenName, String surname, String organization) throws UserCreationException { User user = User.create(String.format("%s %s", givenName, surname), pid); try { Optional<User> userForPid = userAccess.getUserForPid(pid); if (userForPid.isPresent()) { return userForPid.get(); } else { userAccess.addUser(user); return user; } } catch (AuthenticationUnavailableException e) { throw new UserCreationException(e); } } }
JsonBasedUserStore implements UserStore, UserCreator { @Override public User createUser(String pid, String email, String givenName, String surname, String organization) throws UserCreationException { User user = User.create(String.format("%s %s", givenName, surname), pid); try { Optional<User> userForPid = userAccess.getUserForPid(pid); if (userForPid.isPresent()) { return userForPid.get(); } else { userAccess.addUser(user); return user; } } catch (AuthenticationUnavailableException e) { throw new UserCreationException(e); } } JsonBasedUserStore(UserAccess userAccess); }
JsonBasedUserStore implements UserStore, UserCreator { @Override public User createUser(String pid, String email, String givenName, String surname, String organization) throws UserCreationException { User user = User.create(String.format("%s %s", givenName, surname), pid); try { Optional<User> userForPid = userAccess.getUserForPid(pid); if (userForPid.isPresent()) { return userForPid.get(); } else { userAccess.addUser(user); return user; } } catch (AuthenticationUnavailableException e) { throw new UserCreationException(e); } } JsonBasedUserStore(UserAccess userAccess); @Override Optional<User> userFor(String pid); @Override Optional<User> userForId(String userId); @Override User saveNew(String displayName, String persistentId); @Override User createUser(String pid, String email, String givenName, String surname, String organization); }
JsonBasedUserStore implements UserStore, UserCreator { @Override public User createUser(String pid, String email, String givenName, String surname, String organization) throws UserCreationException { User user = User.create(String.format("%s %s", givenName, surname), pid); try { Optional<User> userForPid = userAccess.getUserForPid(pid); if (userForPid.isPresent()) { return userForPid.get(); } else { userAccess.addUser(user); return user; } } catch (AuthenticationUnavailableException e) { throw new UserCreationException(e); } } JsonBasedUserStore(UserAccess userAccess); @Override Optional<User> userFor(String pid); @Override Optional<User> userForId(String userId); @Override User saveNew(String displayName, String persistentId); @Override User createUser(String pid, String email, String givenName, String surname, String organization); static final Logger LOG; }