@Test public void searchObject_valid_class() throws Exception { NCMBObjectService objServ = (NCMBObjectService) NCMB.factory(NCMB.ServiceType.OBJECT); JSONObject conditions = new JSONObject("{\"where\":{\"key\":\"value\"},\"limit\":1}"); ArrayList<NCMBObject> result = (ArrayList<NCMBObject>) objServ.searchObject("TestClass", conditions); Assert.assertEquals("8FgKqFlH8dZRDrBJ", result.get(0).getObjectId()); }
public List searchObject (String className, JSONObject conditions) throws NCMBException { if (!validateClassName(className)){ throw new NCMBException(NCMBException.REQUIRED, "className / objectId is must not be null or empty"); } String url = mContext.baseUrl + mServicePath + className; 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(className, response.responseData); }
NCMBObjectService extends NCMBService { public List searchObject (String className, JSONObject conditions) throws NCMBException { if (!validateClassName(className)){ throw new NCMBException(NCMBException.REQUIRED, "className / objectId is must not be null or empty"); } String url = mContext.baseUrl + mServicePath + className; 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(className, response.responseData); } }
NCMBObjectService extends NCMBService { public List searchObject (String className, JSONObject conditions) throws NCMBException { if (!validateClassName(className)){ throw new NCMBException(NCMBException.REQUIRED, "className / objectId is must not be null or empty"); } String url = mContext.baseUrl + mServicePath + className; 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(className, response.responseData); } NCMBObjectService(NCMBContext context); }
NCMBObjectService extends NCMBService { public List searchObject (String className, JSONObject conditions) throws NCMBException { if (!validateClassName(className)){ throw new NCMBException(NCMBException.REQUIRED, "className / objectId is must not be null or empty"); } String url = mContext.baseUrl + mServicePath + className; 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(className, response.responseData); } NCMBObjectService(NCMBContext context); JSONObject saveObject(String className, JSONObject params); void saveObjectInBackground(String className, JSONObject params, ExecuteServiceCallback callback); NCMBObject fetchObject(String className,String objectId); void fetchObjectInBackground(final String className, String objectId, final FetchCallback callback); JSONObject updateObject(String className, String objectId, JSONObject params); void updateObjectInBackground(String className, String objectId, JSONObject params, ExecuteServiceCallback callback); JSONObject deleteObject(String className,String objectId); void deleteObjectInBackground(String className, String objectId, ExecuteServiceCallback callback); List searchObject(String className, JSONObject conditions); void searchObjectInBackground(final String className, JSONObject conditions, SearchObjectCallback callback); int countObject(String className, JSONObject conditions); void countObjectInBackground(final String className, JSONObject conditions, CountCallback callback); }
NCMBObjectService extends NCMBService { public List searchObject (String className, JSONObject conditions) throws NCMBException { if (!validateClassName(className)){ throw new NCMBException(NCMBException.REQUIRED, "className / objectId is must not be null or empty"); } String url = mContext.baseUrl + mServicePath + className; 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(className, response.responseData); } NCMBObjectService(NCMBContext context); JSONObject saveObject(String className, JSONObject params); void saveObjectInBackground(String className, JSONObject params, ExecuteServiceCallback callback); NCMBObject fetchObject(String className,String objectId); void fetchObjectInBackground(final String className, String objectId, final FetchCallback callback); JSONObject updateObject(String className, String objectId, JSONObject params); void updateObjectInBackground(String className, String objectId, JSONObject params, ExecuteServiceCallback callback); JSONObject deleteObject(String className,String objectId); void deleteObjectInBackground(String className, String objectId, ExecuteServiceCallback callback); List searchObject(String className, JSONObject conditions); void searchObjectInBackground(final String className, JSONObject conditions, SearchObjectCallback callback); int countObject(String className, JSONObject conditions); void countObjectInBackground(final String className, JSONObject conditions, CountCallback callback); static final String SERVICE_PATH; }