### Question:
LocalUserCreator { public void create(Map<String, String> userInfo) throws UserCreationException { String userPid = userInfo.get(USER_PID); String userName = userInfo.get(USER_NAME); String password = userInfo.get(PASSWORD); String givenName = userInfo.get(GIVEN_NAME); String surname = userInfo.get(SURNAME); String emailAddress = userInfo.get(EMAIL_ADDRESS); String organization = userInfo.get(ORGANIZATION); String vreId = userInfo.get(VRE_ID); String vreRole = userInfo.get(VRE_ROLE); try { loginCreator.createLogin(userPid, userName, password, givenName, surname, emailAddress, organization); User user = userCreator.createUser(userPid, emailAddress, givenName, surname, organization); authorizationCreator.createAuthorization(vreId, user, vreRole); } catch (LoginCreationException e) { throw new UserCreationException(e); } catch (AuthorizationCreationException e) { throw new UserCreationException(e); } } LocalUserCreator(LoginCreator loginCreator, UserCreator userCreator,
                          VreAuthorizationCrud authorizationCreator); void create(Map<String, String> userInfo);  }### Answer:
@Test public void createCreatesALoginAUserAndAVreAuthorization() throws Exception { instance.create(userInfo); verify(loginCreator).createLogin(PID, USER_NAME, PWD, GIVEN_NAME, SURNAME, EMAIL, ORGANIZATION); verify(userCreator).createUser(PID, EMAIL, GIVEN_NAME, SURNAME, ORGANIZATION); verify(authorizationCreator).createAuthorization(VRE_ID, USER, VRE_ROLE); }
@Test(expected = UserCreationException.class) public void createThrowsAUserCreationExceptionWhenTheLoginCreatorThrowsALoginCreationException() throws Exception { Mockito.doThrow(new LoginCreationException("")).when(loginCreator) .createLogin(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString()); instance.create(userInfo); }
@Test(expected = UserCreationException.class) public void createThrowsAUserCreationExceptionWhenTheUserCreatorDoes() throws Exception { doThrow(new UserCreationException("")).when(userCreator) .createUser(anyString(), anyString(), anyString(), anyString(), anyString()); instance.create(userInfo); }
@Test(expected = UserCreationException.class) public void createThrowsAUserCreationExceptionWhenTheAuthorizationCreatorThrowsAnAuthorizationCreationException() throws Exception { Mockito.doThrow(new AuthorizationCreationException("")).when(authorizationCreator) .createAuthorization(anyString(), any(User.class), anyString()); instance.create(userInfo); }