@Test public void updateUserInBackground() throws Exception { String userId = "dummyUserId"; JSONObject params = new JSONObject(); params.put("userName", "NCMB Tarou"); params.put("mailAddress", "mobilebackend@example.com"); NCMBUserService userService = getUserService(); userService.updateUserInBackground(userId, params, new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (e != null) { Assert.fail(e.getMessage()); } try { JSONAssert.assertEquals("{\"updateDate\":\"2014-06-04T11:28:30.348Z\"}", json.toString(), true); } catch (JSONException e1) { Assert.fail(e.getMessage()); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { try { params.put("objectId", userId); writeCurrentUser(params, response.responseData); } catch (NCMBException e) { callback.done(null, e); } catch (JSONException e) { callback.done(null, new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(null, e); } }); }
NCMBUserService extends NCMBService { public void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { try { params.put("objectId", userId); writeCurrentUser(params, response.responseData); } catch (NCMBException e) { callback.done(null, e); } catch (JSONException e) { callback.done(null, new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(null, e); } }); } }
NCMBUserService extends NCMBService { public void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { try { params.put("objectId", userId); writeCurrentUser(params, response.responseData); } catch (NCMBException e) { callback.done(null, e); } catch (JSONException e) { callback.done(null, new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(null, e); } }); } NCMBUserService(NCMBContext context); }
NCMBUserService extends NCMBService { public void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { try { params.put("objectId", userId); writeCurrentUser(params, response.responseData); } catch (NCMBException e) { callback.done(null, e); } catch (JSONException e) { callback.done(null, new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(null, e); } }); } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); }
NCMBUserService extends NCMBService { public void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = updateUserParams(userId, params); sendRequestAsync(reqParams, new UserServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { try { params.put("objectId", userId); writeCurrentUser(params, response.responseData); } catch (NCMBException e) { callback.done(null, e); } catch (JSONException e) { callback.done(null, new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; callback.done(null, e); } }); } NCMBUserService(NCMBContext context); NCMBUser registerByName(String userName, String password); NCMBUser registerByName(String userName, String password,JSONObject otherFields); void saveByName(String userName, String password); void saveByName(String userName, String password,JSONObject otherFields); void registerByNameInBackground(String userName, String password, LoginCallback callback); void registerByNameInBackground(String userName, String password, JSONObject otherFields, LoginCallback callback); NCMBUser registerByOauth(JSONObject oauthOptions); void registerByOauthInBackground(JSONObject oauthOptions, LoginCallback callback); void inviteByMail(String mailAddress); void inviteByMailInBackground(String mailAddress, DoneCallback callback); void requestPasswordReset(String mailAddress); void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); NCMBUser fetchUser(String userId); void fetchUserInBackground(String userId, final FetchCallback callback); JSONObject updateUser(String userId, JSONObject params); void updateUserInBackground(final String userId, final JSONObject params, final ExecuteServiceCallback callback); NCMBUser loginByName(String userName, String password); void loginByNameInBackground(String userName, String password,
                                        LoginCallback callback); NCMBUser loginByMail(String mailAddress, String password); void loginByMailInBackground(String mailAddress, String password,
                                        LoginCallback callback); void deleteUser(String userId); void deleteUserInBackground(final String userId, ExecuteServiceCallback callback); void logout(); void logoutInBackground(DoneCallback callback); ArrayList<NCMBUser> searchUser(JSONObject conditions); void searchUserInBackground(JSONObject conditions, final SearchUserCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_REGISTERED; static final int HTTP_STATUS_AUTHORIZED; static final int HTTP_STATUS_REQUEST_ACCEPTED; }