@Test() public void testCreateUser() throws RemoteApiException { doReturn(null).when(userApiClient).getUserByUsername(MOCK_SESSION_ID, MOCK_USERNAME); Application application = mockApplication(); doReturn(mockUser()).when(userApiClient).createUser(eq(MOCK_SESSION_ID), any(UserCreate.class)); userService.setupBotUser(application); Assert.assertEquals(MOCK_USERNAME, userService.getUsername(application)); }
private void createUser(String sessionToken, String userName, String avatar, String emailAddress) { UserDetail user = null; try { UserAttributes userAttributes = createUserAttributes(userName, userName, emailAddress); UserCreate userCreate = buildUserCreate(userAttributes); user = userApiClient.createUser(sessionToken, userCreate); } catch (RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_ATTRIBUTES); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UpdateUserException(message, e, solution); } updateUserAvatar(sessionToken, user.getUserSystemInfo().getId(), avatar); }
UserService { private void createUser(String sessionToken, String userName, String avatar, String emailAddress) { UserDetail user = null; try { UserAttributes userAttributes = createUserAttributes(userName, userName, emailAddress); UserCreate userCreate = buildUserCreate(userAttributes); user = userApiClient.createUser(sessionToken, userCreate); } catch (RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_ATTRIBUTES); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UpdateUserException(message, e, solution); } updateUserAvatar(sessionToken, user.getUserSystemInfo().getId(), avatar); } }
UserService { private void createUser(String sessionToken, String userName, String avatar, String emailAddress) { UserDetail user = null; try { UserAttributes userAttributes = createUserAttributes(userName, userName, emailAddress); UserCreate userCreate = buildUserCreate(userAttributes); user = userApiClient.createUser(sessionToken, userCreate); } catch (RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_ATTRIBUTES); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UpdateUserException(message, e, solution); } updateUserAvatar(sessionToken, user.getUserSystemInfo().getId(), avatar); }  }
UserService { private void createUser(String sessionToken, String userName, String avatar, String emailAddress) { UserDetail user = null; try { UserAttributes userAttributes = createUserAttributes(userName, userName, emailAddress); UserCreate userCreate = buildUserCreate(userAttributes); user = userApiClient.createUser(sessionToken, userCreate); } catch (RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_ATTRIBUTES); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UpdateUserException(message, e, solution); } updateUserAvatar(sessionToken, user.getUserSystemInfo().getId(), avatar); }  @PostConstruct void init(); void setupBotUser(Application application); User getUser(String username); User getUser(Long userId); String getUsername(Application application); }
UserService { private void createUser(String sessionToken, String userName, String avatar, String emailAddress) { UserDetail user = null; try { UserAttributes userAttributes = createUserAttributes(userName, userName, emailAddress); UserCreate userCreate = buildUserCreate(userAttributes); user = userApiClient.createUser(sessionToken, userCreate); } catch (RemoteApiException e) { String message = logMessage.getMessage(FAIL_UPDATE_ATTRIBUTES); String solution = logMessage.getMessage(FAIL_POD_API_SOLUTION); throw new UpdateUserException(message, e, solution); } updateUserAvatar(sessionToken, user.getUserSystemInfo().getId(), avatar); }  @PostConstruct void init(); void setupBotUser(Application application); User getUser(String username); User getUser(Long userId); String getUsername(Application application);  }