@Test public void find_in_background_push_class() throws Exception { Assert.assertFalse(callbackFlag); NCMBQuery<NCMBPush> query = NCMBPush.getQuery(); query.findInBackground(new FindCallback<NCMBPush>() { @Override public void done(List<NCMBPush> results, NCMBException e) { if (e != null) { Assert.fail("this callback should not raise exception"); } else { Assert.assertEquals("message1", results.get(0).getMessage()); } callbackFlag = true; } }); Robolectric.flushBackgroundThreadScheduler(); ShadowLooper.runUiThreadTasks(); Assert.assertTrue(callbackFlag); }
public void findInBackground (final FindCallback<T> callback) { if (mClassName.equals("user")) { NCMBUserService userServ = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); userServ.searchUserInBackground(getConditions(), new SearchUserCallback() { @Override public void done(ArrayList<NCMBUser> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("role")) { NCMBRoleService roleServ = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); roleServ.searchRoleInBackground(getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("push")) { NCMBPushService pushServ = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushServ.searchPushInBackground(getConditions(), new SearchPushCallback() { @Override public void done(ArrayList<NCMBPush> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("installation")) { NCMBInstallationService installationServ = (NCMBInstallationService)NCMB.factory(NCMB.ServiceType.INSTALLATION); installationServ.searchInstallationInBackground(getConditions(), new SearchInstallationCallback () { @Override public void done(ArrayList<NCMBInstallation> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("file")) { NCMBFileService fileServ = (NCMBFileService)NCMB.factory(NCMB.ServiceType.FILE); fileServ.searchFileInBackground(getConditions(), new SearchFileCallback() { @Override public void done(List<NCMBFile> files, NCMBException e) { callback.done((List<T>) files, e); } }); }else { NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); objServ.searchObjectInBackground(mClassName, getConditions(), new SearchObjectCallback() { @Override public void done(List<NCMBObject> objects, NCMBException e) { callback.done((List<T>) objects, e); } }); } }
NCMBQuery { public void findInBackground (final FindCallback<T> callback) { if (mClassName.equals("user")) { NCMBUserService userServ = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); userServ.searchUserInBackground(getConditions(), new SearchUserCallback() { @Override public void done(ArrayList<NCMBUser> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("role")) { NCMBRoleService roleServ = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); roleServ.searchRoleInBackground(getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("push")) { NCMBPushService pushServ = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushServ.searchPushInBackground(getConditions(), new SearchPushCallback() { @Override public void done(ArrayList<NCMBPush> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("installation")) { NCMBInstallationService installationServ = (NCMBInstallationService)NCMB.factory(NCMB.ServiceType.INSTALLATION); installationServ.searchInstallationInBackground(getConditions(), new SearchInstallationCallback () { @Override public void done(ArrayList<NCMBInstallation> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("file")) { NCMBFileService fileServ = (NCMBFileService)NCMB.factory(NCMB.ServiceType.FILE); fileServ.searchFileInBackground(getConditions(), new SearchFileCallback() { @Override public void done(List<NCMBFile> files, NCMBException e) { callback.done((List<T>) files, e); } }); }else { NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); objServ.searchObjectInBackground(mClassName, getConditions(), new SearchObjectCallback() { @Override public void done(List<NCMBObject> objects, NCMBException e) { callback.done((List<T>) objects, e); } }); } } }
NCMBQuery { public void findInBackground (final FindCallback<T> callback) { if (mClassName.equals("user")) { NCMBUserService userServ = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); userServ.searchUserInBackground(getConditions(), new SearchUserCallback() { @Override public void done(ArrayList<NCMBUser> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("role")) { NCMBRoleService roleServ = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); roleServ.searchRoleInBackground(getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("push")) { NCMBPushService pushServ = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushServ.searchPushInBackground(getConditions(), new SearchPushCallback() { @Override public void done(ArrayList<NCMBPush> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("installation")) { NCMBInstallationService installationServ = (NCMBInstallationService)NCMB.factory(NCMB.ServiceType.INSTALLATION); installationServ.searchInstallationInBackground(getConditions(), new SearchInstallationCallback () { @Override public void done(ArrayList<NCMBInstallation> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("file")) { NCMBFileService fileServ = (NCMBFileService)NCMB.factory(NCMB.ServiceType.FILE); fileServ.searchFileInBackground(getConditions(), new SearchFileCallback() { @Override public void done(List<NCMBFile> files, NCMBException e) { callback.done((List<T>) files, e); } }); }else { NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); objServ.searchObjectInBackground(mClassName, getConditions(), new SearchObjectCallback() { @Override public void done(List<NCMBObject> objects, NCMBException e) { callback.done((List<T>) objects, e); } }); } } NCMBQuery(String className); }
NCMBQuery { public void findInBackground (final FindCallback<T> callback) { if (mClassName.equals("user")) { NCMBUserService userServ = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); userServ.searchUserInBackground(getConditions(), new SearchUserCallback() { @Override public void done(ArrayList<NCMBUser> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("role")) { NCMBRoleService roleServ = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); roleServ.searchRoleInBackground(getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("push")) { NCMBPushService pushServ = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushServ.searchPushInBackground(getConditions(), new SearchPushCallback() { @Override public void done(ArrayList<NCMBPush> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("installation")) { NCMBInstallationService installationServ = (NCMBInstallationService)NCMB.factory(NCMB.ServiceType.INSTALLATION); installationServ.searchInstallationInBackground(getConditions(), new SearchInstallationCallback () { @Override public void done(ArrayList<NCMBInstallation> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("file")) { NCMBFileService fileServ = (NCMBFileService)NCMB.factory(NCMB.ServiceType.FILE); fileServ.searchFileInBackground(getConditions(), new SearchFileCallback() { @Override public void done(List<NCMBFile> files, NCMBException e) { callback.done((List<T>) files, e); } }); }else { NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); objServ.searchObjectInBackground(mClassName, getConditions(), new SearchObjectCallback() { @Override public void done(List<NCMBObject> objects, NCMBException e) { callback.done((List<T>) objects, e); } }); } } NCMBQuery(String className); List<T> find(); void findInBackground(final FindCallback<T> callback); JSONObject getConditions(); void whereEqualTo(String key, Object value); void whereNotEqualTo(String key, Object value); void whereLessThan(String key, Object value); void whereGreaterThan(String key, Object value); void whereLessThanOrEqualTo(String key, Object value); void whereGreaterThanOrEqualTo(String key, Object value); void whereContainedIn(String key, Collection<? extends Object> objects); void whereNotContainedIn(String key, Collection<? extends Object> objects); void whereExists(String key); void whereDoesNotExists(String key); void whereContainedInArray(String key, Collection<? extends Object> elements); void whereNotContainedInArray(String key, Collection<? extends Object> elements); void whereContainsAll(String key, Collection<? extends Object> elements); void or(Collection<NCMBQuery> queries); void whereMatchesKeyInQuery(String key, String inQueryKey, NCMBQuery inQuery); void whereMatchesQuery(String key, NCMBQuery inQuery); void whereRelatedTo(NCMBObject parent, String key); void whereWithinGeoBox(String key, Location southwest, Location northeast); void whereWithinKilometers(String key, Location center, double distance); void whereWithinMiles(String key, Location center, int distance); void whereWithinRadians(String key, Location center, int distance); void setLimit(int number); void setSkip(int number); void setIncludeKey(String key); void addOrderByAscending(String key); void addOrderByDescending(String key); void deleteOrder(String key); int count(); void countInBackground(CountCallback callback); }
NCMBQuery { public void findInBackground (final FindCallback<T> callback) { if (mClassName.equals("user")) { NCMBUserService userServ = (NCMBUserService) NCMB.factory(NCMB.ServiceType.USER); userServ.searchUserInBackground(getConditions(), new SearchUserCallback() { @Override public void done(ArrayList<NCMBUser> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("role")) { NCMBRoleService roleServ = (NCMBRoleService) NCMB.factory(NCMB.ServiceType.ROLE); roleServ.searchRoleInBackground(getConditions(), new SearchRoleCallback() { @Override public void done(ArrayList<NCMBRole> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("push")) { NCMBPushService pushServ = (NCMBPushService) NCMB.factory(NCMB.ServiceType.PUSH); pushServ.searchPushInBackground(getConditions(), new SearchPushCallback() { @Override public void done(ArrayList<NCMBPush> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("installation")) { NCMBInstallationService installationServ = (NCMBInstallationService)NCMB.factory(NCMB.ServiceType.INSTALLATION); installationServ.searchInstallationInBackground(getConditions(), new SearchInstallationCallback () { @Override public void done(ArrayList<NCMBInstallation> users, NCMBException e) { callback.done((List<T>) users, e); } }); } else if (mClassName.equals("file")) { NCMBFileService fileServ = (NCMBFileService)NCMB.factory(NCMB.ServiceType.FILE); fileServ.searchFileInBackground(getConditions(), new SearchFileCallback() { @Override public void done(List<NCMBFile> files, NCMBException e) { callback.done((List<T>) files, e); } }); }else { NCMBObjectService objServ = (NCMBObjectService)NCMB.factory(NCMB.ServiceType.OBJECT); objServ.searchObjectInBackground(mClassName, getConditions(), new SearchObjectCallback() { @Override public void done(List<NCMBObject> objects, NCMBException e) { callback.done((List<T>) objects, e); } }); } } NCMBQuery(String className); List<T> find(); void findInBackground(final FindCallback<T> callback); JSONObject getConditions(); void whereEqualTo(String key, Object value); void whereNotEqualTo(String key, Object value); void whereLessThan(String key, Object value); void whereGreaterThan(String key, Object value); void whereLessThanOrEqualTo(String key, Object value); void whereGreaterThanOrEqualTo(String key, Object value); void whereContainedIn(String key, Collection<? extends Object> objects); void whereNotContainedIn(String key, Collection<? extends Object> objects); void whereExists(String key); void whereDoesNotExists(String key); void whereContainedInArray(String key, Collection<? extends Object> elements); void whereNotContainedInArray(String key, Collection<? extends Object> elements); void whereContainsAll(String key, Collection<? extends Object> elements); void or(Collection<NCMBQuery> queries); void whereMatchesKeyInQuery(String key, String inQueryKey, NCMBQuery inQuery); void whereMatchesQuery(String key, NCMBQuery inQuery); void whereRelatedTo(NCMBObject parent, String key); void whereWithinGeoBox(String key, Location southwest, Location northeast); void whereWithinKilometers(String key, Location center, double distance); void whereWithinMiles(String key, Location center, int distance); void whereWithinRadians(String key, Location center, int distance); void setLimit(int number); void setSkip(int number); void setIncludeKey(String key); void addOrderByAscending(String key); void addOrderByDescending(String key); void deleteOrder(String key); int count(); void countInBackground(CountCallback callback);  }