NCMBRoleService extends NCMBService { public ArrayList<NCMBRole> searchRole(JSONObject conditions) throws NCMBException { String url = mContext.baseUrl + mServicePath; String type = NCMBRequest.HTTP_METHOD_GET; NCMBResponse response = sendRequest(url, type, null, conditions); if (response.statusCode != NCMBResponse.HTTP_STATUS_OK) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Invalid status code"); } return createSearchResults(response.responseData); } 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 searchRole() throws Exception { NCMBQuery<NCMBRole> query = new NCMBQuery<>("role"); query.whereEqualTo("roleName", "testRole"); NCMBRoleService roleService = getRoleService(); ArrayList<NCMBRole> result = roleService.searchRole(query.getConditions()); Assert.assertEquals(result.size(), 1); NCMBRole role = result.get(0); Assert.assertEquals(role.getObjectId(), "oc8bJVuEWmKgNydn"); Assert.assertEquals(role.getRoleName(), "testRole"); }