@Test public void testCreateUser() throws RemoteApiException { Map<String, String> headerParams = new HashMap<>(); headerParams.put("sessionToken", MOCK_SESSION); UserAttributes userAttributes = mockUserAttributes(); UserCreate userInfo = new UserCreate(); userInfo.setUserAttributes(userAttributes); UserPassword userPassword = new UserPassword(); userPassword.sethPassword("hPassword"); userPassword.sethSalt("hSalt"); userPassword.setKhPassword("khPassword"); userPassword.setKhSalt("khSalt"); userInfo.setPassword(userPassword); userInfo.setRoles(Collections.<String>emptyList()); UserDetail expected = new UserDetail(); expected.setUserAttributes(userAttributes); expected.setApps(Collections.<Long>emptyList()); Avatar avatar = new Avatar(); avatar.setSize("size"); avatar.setUrl("url"); expected.setAvatar(avatar); expected.setDisclaimers(Collections.<Long>emptyList()); expected.setFeatures(Collections.<Long>emptyList()); expected.setGroups(Collections.<Long>emptyList()); expected.setRoles(Collections.<String>emptyList()); UserSystemInfo userSystemInfo = new UserSystemInfo(); userSystemInfo.setCreatedBy("createdBy"); userSystemInfo.setCreatedDate(0l); userSystemInfo.setId(0l); userSystemInfo.setLastLoginDate(0l); userSystemInfo.setLastPasswordReset(0l); userSystemInfo.setLastUpdatedDate(0l); userSystemInfo.setStatus(UserSystemInfo.StatusEnum.ENABLED); expected.setUserSystemInfo(userSystemInfo); doReturn(expected).when(httpClient) .doPost("/v1/admin/user/create", headerParams, Collections.<String, String>emptyMap(), userInfo, UserDetail.class); UserDetail result = apiClient.createUser(MOCK_SESSION, userInfo); assertTrue(equalsUserAttributes(expected.getUserAttributes(), result.getUserAttributes())); assertEquals(expected, result); }
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);  }