NCMBRoleService extends NCMBService { public void removeUserRelationsInBackground(String roleId, List<NCMBUser> users, ExecuteServiceCallback callback) throws NCMBException { RequestParams reqParams = userRelationsParams(roleId, users, false); sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { ExecuteServiceCallback doneCallback = (ExecuteServiceCallback) mCallback; doneCallback.done(response.responseData, null); } @Override public void handleError(NCMBException e) { ExecuteServiceCallback doneCallback = (ExecuteServiceCallback) mCallback; doneCallback.done(null, e); } }); } NCMBRoleService(NCMBContext context); JSONObject createRole(String roleName); void createRoleInBackground(String roleName, ExecuteServiceCallback callback); void deleteRole(String roleId); void deleteRoleInBackground(String roleId, DoneCallback callback); RequestParams getRoleParams(String roleId); NCMBRole fetchRole(String roleId); void fetchRoleInBackground(String objectId, final FetchCallback callback); ArrayList<NCMBRole> searchRole(JSONObject conditions); void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback); ArrayList<String> findBelongUser(String roleId); JSONObject addUserRelations(String roleId, List<NCMBUser> users); void addUserRelationsInBackground(String roleId, List<NCMBUser> users,
                                             ExecuteServiceCallback callback); JSONObject removeUserRelations(String roleId, List<NCMBUser> users); void removeUserRelationsInBackground(String roleId, List<NCMBUser> users,
                                                ExecuteServiceCallback callback); JSONObject addRoleRelations(String roleId, List<NCMBRole> roles); void addRoleRelationsInBackground(String roleId, List<NCMBRole> roles,
                                             ExecuteServiceCallback callback); JSONObject removeRoleRelations(String roleId, List<NCMBRole> roles); void removeRoleRelationsInBackground(String roleId, List<NCMBRole> roles,
                                                ExecuteServiceCallback callback); void updateAcl(String roleId, NCMBAcl acl); void updateAclInBackground(String roleId, NCMBAcl acl, DoneCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_ROLE_CREATED; static final int HTTP_STATUS_ROLE_UPDATED; static final int HTTP_STATUS_ROLE_DELETED; }
@Test public void removeUserRelationsInBackground() throws Exception { NCMBRoleService roleService = getRoleService(); String roleId = "dummyRoleId"; int numUsers = 2; ArrayList<NCMBUser> users = generateUsers(numUsers); roleService.removeUserRelationsInBackground(roleId, users, new ExecuteServiceCallback() { @Override public void done(JSONObject json, NCMBException e) { if (e != null) { Assert.fail(e.getMessage()); } try { Assert.assertEquals("2014-06-04T11:28:30.348Z", json.getString("updateDate")); } catch (JSONException error) { Assert.fail(error.getMessage()); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }