@Test public void update_in_background() throws Exception { NCMBUser user = new NCMBUser(); user.setObjectId("dummyUserId"); user.put("key", "value"); user.saveInBackground(new DoneCallback() { @Override public void done(NCMBException e) { if (e != null) { Assert.fail(e.getMessage()); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); SimpleDateFormat df = NCMBDateFormat.getIso8601(); Assert.assertEquals(df.parse("2014-06-04T11:28:30.348Z"), user.getUpdateDate()); }
@Override public void saveInBackground(final DoneCallback callback) { if (getObjectId() == null) { saveInBackgroundWithoutLogin(callback); } else { NCMBUserService service = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); try { service.updateUserInBackground(getObjectId(), createUpdateJsonData(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (json != null && !json.isNull("updateDate")) { try { mFields.put("updateDate", json.getString("updateDate")); } catch (JSONException e1) { throw new IllegalArgumentException(e1.getMessage()); } if (callback != null) { callback.done(e); } } else { if (callback != null) { callback.done(e); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } catch (JSONException e) { if (callback != null) { callback.done(new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } } } }
NCMBUser extends NCMBObject { @Override public void saveInBackground(final DoneCallback callback) { if (getObjectId() == null) { saveInBackgroundWithoutLogin(callback); } else { NCMBUserService service = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); try { service.updateUserInBackground(getObjectId(), createUpdateJsonData(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (json != null && !json.isNull("updateDate")) { try { mFields.put("updateDate", json.getString("updateDate")); } catch (JSONException e1) { throw new IllegalArgumentException(e1.getMessage()); } if (callback != null) { callback.done(e); } } else { if (callback != null) { callback.done(e); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } catch (JSONException e) { if (callback != null) { callback.done(new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } } } } }
NCMBUser extends NCMBObject { @Override public void saveInBackground(final DoneCallback callback) { if (getObjectId() == null) { saveInBackgroundWithoutLogin(callback); } else { NCMBUserService service = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); try { service.updateUserInBackground(getObjectId(), createUpdateJsonData(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (json != null && !json.isNull("updateDate")) { try { mFields.put("updateDate", json.getString("updateDate")); } catch (JSONException e1) { throw new IllegalArgumentException(e1.getMessage()); } if (callback != null) { callback.done(e); } } else { if (callback != null) { callback.done(e); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } catch (JSONException e) { if (callback != null) { callback.done(new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } } } } NCMBUser();   NCMBUser(JSONObject params); }
NCMBUser extends NCMBObject { @Override public void saveInBackground(final DoneCallback callback) { if (getObjectId() == null) { saveInBackgroundWithoutLogin(callback); } else { NCMBUserService service = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); try { service.updateUserInBackground(getObjectId(), createUpdateJsonData(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (json != null && !json.isNull("updateDate")) { try { mFields.put("updateDate", json.getString("updateDate")); } catch (JSONException e1) { throw new IllegalArgumentException(e1.getMessage()); } if (callback != null) { callback.done(e); } } else { if (callback != null) { callback.done(e); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } catch (JSONException e) { if (callback != null) { callback.done(new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } } } } NCMBUser();   NCMBUser(JSONObject params); static NCMBQuery<NCMBUser> getQuery(); String getUserName(); void setUserName(String userName); void setPassword(String password); Boolean isMailAddressConfirmed(); String getMailAddress(); void setMailAddress(String mailAddress); boolean isAuthenticated(); boolean isLinkedWith(String provider); JSONObject getAuthData(); JSONObject getAuthData(String provider); void signUp(); void signUpInBackground(final DoneCallback callback); static void requestAuthenticationMail(String mailAddress); static void requestAuthenticationMailInBackground(String mailAddress, DoneCallback callback); static void requestPasswordReset(String mailAddress); static void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); static NCMBUser loginWithMailAddress(String mailAddress, String password); static void loginWithMailAddressInBackground(String mailAddress, String password,
                                                        LoginCallback callback); static NCMBUser loginWithAnonymous(); static void loginWithAnonymousInBackground(final LoginCallback callback); static NCMBUser login(String userName, String password); static void loginInBackground(String userName, String password,
                                         LoginCallback callback); static void logout(); static void logoutInBackground(DoneCallback callback); static NCMBUser loginWith(Object authData); static void loginInBackgroundWith(Object authData, LoginCallback callback); void linkWith(Object params); void linkInBackgroundWith(Object params, final DoneCallback callback); void unlink(@NonNull String provider); void unlinkInBackground(@NonNull final String provider, final DoneCallback callback); @Override void save(); @Override void saveInBackground(final DoneCallback callback); @Override void fetch(); @Override void fetchInBackground(final FetchCallback callback); @Override void deleteObject(); @Override void deleteObjectInBackground(final DoneCallback callback); static NCMBUser getCurrentUser(); static String getSessionToken(); }
NCMBUser extends NCMBObject { @Override public void saveInBackground(final DoneCallback callback) { if (getObjectId() == null) { saveInBackgroundWithoutLogin(callback); } else { NCMBUserService service = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); try { service.updateUserInBackground(getObjectId(), createUpdateJsonData(), new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (json != null && !json.isNull("updateDate")) { try { mFields.put("updateDate", json.getString("updateDate")); } catch (JSONException e1) { throw new IllegalArgumentException(e1.getMessage()); } if (callback != null) { callback.done(e); } } else { if (callback != null) { callback.done(e); } } } }); } catch (NCMBException e) { if (callback != null) { callback.done(e); } } catch (JSONException e) { if (callback != null) { callback.done(new NCMBException(NCMBException.INVALID_JSON, e.getMessage())); } } } } NCMBUser();   NCMBUser(JSONObject params); static NCMBQuery<NCMBUser> getQuery(); String getUserName(); void setUserName(String userName); void setPassword(String password); Boolean isMailAddressConfirmed(); String getMailAddress(); void setMailAddress(String mailAddress); boolean isAuthenticated(); boolean isLinkedWith(String provider); JSONObject getAuthData(); JSONObject getAuthData(String provider); void signUp(); void signUpInBackground(final DoneCallback callback); static void requestAuthenticationMail(String mailAddress); static void requestAuthenticationMailInBackground(String mailAddress, DoneCallback callback); static void requestPasswordReset(String mailAddress); static void requestPasswordResetInBackground(String mailAddress, DoneCallback callback); static NCMBUser loginWithMailAddress(String mailAddress, String password); static void loginWithMailAddressInBackground(String mailAddress, String password,
                                                        LoginCallback callback); static NCMBUser loginWithAnonymous(); static void loginWithAnonymousInBackground(final LoginCallback callback); static NCMBUser login(String userName, String password); static void loginInBackground(String userName, String password,
                                         LoginCallback callback); static void logout(); static void logoutInBackground(DoneCallback callback); static NCMBUser loginWith(Object authData); static void loginInBackgroundWith(Object authData, LoginCallback callback); void linkWith(Object params); void linkInBackgroundWith(Object params, final DoneCallback callback); void unlink(@NonNull String provider); void unlinkInBackground(@NonNull final String provider, final DoneCallback callback); @Override void save(); @Override void saveInBackground(final DoneCallback callback); @Override void fetch(); @Override void fetchInBackground(final FetchCallback callback); @Override void deleteObject(); @Override void deleteObjectInBackground(final DoneCallback callback); static NCMBUser getCurrentUser(); static String getSessionToken();  }