@Test public void testCreateUserNullData() { String expectedMessage = String.format("Missing the required body payload when calling %s", CREATE_USER); String expectedSolution = String.format("Please check if the required body payload when calling %s exists", CREATE_USER); when(logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER)).thenReturn( expectedMessage); when(logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER)).thenReturn( expectedSolution); try { apiClient.createUser(MOCK_SESSION, null); fail(); } catch (RemoteApiException e) { assertEquals(400, e.getCode()); assertEquals(ExceptionMessageFormatter.format("Commons", expectedMessage, expectedSolution), e.getMessage()); } }
public UserDetail createUser(String sessionToken, UserCreate userInfo) throws RemoteApiException { checkAuthToken(sessionToken); if (userInfo == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/create"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); }
UserApiClient extends BasePodApiClient { public UserDetail createUser(String sessionToken, UserCreate userInfo) throws RemoteApiException { checkAuthToken(sessionToken); if (userInfo == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/create"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); } }
UserApiClient extends BasePodApiClient { public UserDetail createUser(String sessionToken, UserCreate userInfo) throws RemoteApiException { checkAuthToken(sessionToken); if (userInfo == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/create"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); }
UserApiClient extends BasePodApiClient { public UserDetail createUser(String sessionToken, UserCreate userInfo) throws RemoteApiException { checkAuthToken(sessionToken); if (userInfo == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/create"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); User getUserByEmail(String sessionToken, String email); User getUserByUsername(String sessionToken, String username); User getUserById(String sessionToken, Long userId); UserDetail createUser(String sessionToken, UserCreate userInfo); UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes); void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate); }
UserApiClient extends BasePodApiClient { public UserDetail createUser(String sessionToken, UserCreate userInfo) throws RemoteApiException { checkAuthToken(sessionToken); if (userInfo == null) { String reason = logMessage.getMessage(INSTANCE_EMPTY, CREATE_USER); String solution = logMessage.getMessage(INSTANCE_EMPTY_SOLUTION, CREATE_USER); throw new RemoteApiException(HTTP_BAD_REQUEST_ERROR, reason, solution); } String path = "/v1/admin/user/create"; Map<String, String> headerParams = new HashMap<>(); headerParams.put(SESSION_TOKEN_HEADER_PARAM, sessionToken); return apiClient.doPost(path, headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); } UserApiClient(HttpApiClient apiClient, LogMessageSource logMessage); User getUserByEmail(String sessionToken, String email); User getUserByUsername(String sessionToken, String username); User getUserById(String sessionToken, Long userId); UserDetail createUser(String sessionToken, UserCreate userInfo); UserDetail updateUser(String sessionToken, Long uid, UserAttributes attributes); void updateUserAvatar(String sessionToken, Long uid, AvatarUpdate avatarUpdate);  }