@Test public void searchRoleInBackground() throws Exception { NCMBQuery<NCMBRole> query = new NCMBQuery<>("role"); query.whereEqualTo("roleName", "testRole"); NCMBRoleService roleService = getRoleService(); roleService.searchRoleInBackground(query.getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> result, NCMBException e) { Assert.assertEquals(e, null); Assert.assertEquals(result.size(), 1); NCMBRole role = result.get(0); Assert.assertEquals(role.getObjectId(), "oc8bJVuEWmKgNydn"); Assert.assertEquals(role.getRoleName(), "testRole"); callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback) { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; RequestParams reqParams = new RequestParams(); reqParams.url = url; reqParams.type = type; reqParams.query = conditions; try { sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { SearchRoleCallback callback = (SearchRoleCallback) mCallback; if (callback != null) { try { callback.done(createSearchResults(response.responseData), null); } catch (NCMBException callbackException) { callback.done(null, callbackException); } } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException e) { if (callback != null) { callback.done(null, e); } } }
NCMBRoleService extends NCMBService { public void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback) { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; RequestParams reqParams = new RequestParams(); reqParams.url = url; reqParams.type = type; reqParams.query = conditions; try { sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { SearchRoleCallback callback = (SearchRoleCallback) mCallback; if (callback != null) { try { callback.done(createSearchResults(response.responseData), null); } catch (NCMBException callbackException) { callback.done(null, callbackException); } } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException e) { if (callback != null) { callback.done(null, e); } } } }
NCMBRoleService extends NCMBService { public void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback) { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; RequestParams reqParams = new RequestParams(); reqParams.url = url; reqParams.type = type; reqParams.query = conditions; try { sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { SearchRoleCallback callback = (SearchRoleCallback) mCallback; if (callback != null) { try { callback.done(createSearchResults(response.responseData), null); } catch (NCMBException callbackException) { callback.done(null, callbackException); } } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException e) { if (callback != null) { callback.done(null, e); } } } NCMBRoleService(NCMBContext context); }
NCMBRoleService extends NCMBService { public void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback) { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; RequestParams reqParams = new RequestParams(); reqParams.url = url; reqParams.type = type; reqParams.query = conditions; try { sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { SearchRoleCallback callback = (SearchRoleCallback) mCallback; if (callback != null) { try { callback.done(createSearchResults(response.responseData), null); } catch (NCMBException callbackException) { callback.done(null, callbackException); } } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException e) { if (callback != null) { callback.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); }
NCMBRoleService extends NCMBService { public void searchRoleInBackground(JSONObject conditions, SearchRoleCallback callback) { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; RequestParams reqParams = new RequestParams(); reqParams.url = url; reqParams.type = type; reqParams.query = conditions; try { sendRequestAsync(reqParams, new RoleServiceCallback(this, callback) { @Override public void handleResponse(NCMBResponse response) { SearchRoleCallback callback = (SearchRoleCallback) mCallback; if (callback != null) { try { callback.done(createSearchResults(response.responseData), null); } catch (NCMBException callbackException) { callback.done(null, callbackException); } } } @Override public void handleError(NCMBException e) { ExecuteServiceCallback callback = (ExecuteServiceCallback) mCallback; if (callback != null) { callback.done(null, e); } } }); } catch (NCMBException e) { if (callback != null) { callback.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; }