From 0cfc67e9a3bcedc714f0041ee60cafb40ed93520 Mon Sep 17 00:00:00 2001 From: John Carlson Date: Wed, 25 Jul 2018 16:31:05 -0500 Subject: [PATCH] Cleanup (#861) * Remove unneeded throws calls and remove some deprecated methods * Fix lint warnings, including javadocs, redundant initializers, and more * Remove some outdated things from the contributing doc * Fix potential null pointer exception within the push broadcast receiver * Add findAll to ktx and make extension functions inline * Remove more unused methods and inspection warnings * Update dependencies and remove unused class --- CONTRIBUTING.md | 23 +--- fcm/build.gradle | 2 +- .../com/parse/gcm/ParseGCMJobService.java | 2 +- .../main/java/com/parse/ktx/ParseObject.kt | 18 +-- ktx/src/main/java/com/parse/ktx/ParseQuery.kt | 35 +++++ parse/build.gradle | 2 +- .../java/com/parse/CacheQueryController.java | 4 +- .../CachedCurrentInstallationController.java | 16 +-- .../parse/CachedCurrentUserController.java | 32 ++--- .../main/java/com/parse/EventuallyPin.java | 6 +- .../main/java/com/parse/FileObjectStore.java | 8 +- .../main/java/com/parse/InstallationId.java | 2 +- parse/src/main/java/com/parse/Lists.java | 3 +- .../src/main/java/com/parse/ManifestInfo.java | 8 -- .../com/parse/NetworkObjectController.java | 6 +- .../com/parse/NetworkQueryController.java | 4 +- .../com/parse/NetworkSessionController.java | 4 +- .../java/com/parse/NetworkUserController.java | 10 +- .../main/java/com/parse/NoObjectsEncoder.java | 2 +- .../java/com/parse/OfflineObjectStore.java | 14 +- .../java/com/parse/OfflineQueryLogic.java | 38 ++---- .../src/main/java/com/parse/OfflineStore.java | 120 +++++++++--------- parse/src/main/java/com/parse/Parse.java | 5 +- .../main/java/com/parse/ParseAnalytics.java | 28 +--- .../java/com/parse/ParseAnonymousUtils.java | 1 + .../com/parse/ParseAuthenticationManager.java | 6 +- .../main/java/com/parse/ParseClassName.java | 2 + parse/src/main/java/com/parse/ParseCloud.java | 4 +- .../com/parse/ParseCloudCodeController.java | 2 +- .../java/com/parse/ParseCommandCache.java | 6 +- .../src/main/java/com/parse/ParseConfig.java | 6 +- .../java/com/parse/ParseConfigController.java | 4 +- .../parse/ParseCurrentConfigController.java | 4 +- .../com/parse/ParseCurrentUserController.java | 12 +- .../src/main/java/com/parse/ParseDecoder.java | 2 +- .../main/java/com/parse/ParseException.java | 1 + .../java/com/parse/ParseFieldOperations.java | 23 ++-- parse/src/main/java/com/parse/ParseFile.java | 28 ++-- .../java/com/parse/ParseFileController.java | 4 +- .../main/java/com/parse/ParseFileUtils.java | 10 +- .../main/java/com/parse/ParseGeoPoint.java | 4 +- .../main/java/com/parse/ParseHttpClient.java | 8 +- .../src/main/java/com/parse/ParseIOUtils.java | 2 +- .../java/com/parse/ParseInstallation.java | 10 +- .../main/java/com/parse/ParseJSONUtils.java | 5 +- .../com/parse/ParseNotificationManager.java | 40 ++---- .../src/main/java/com/parse/ParseObject.java | 2 +- .../parse/ParseObjectCurrentController.java | 10 +- .../ParseObjectSubclassingController.java | 6 +- .../parse/ParsePinningEventuallyQueue.java | 60 ++++----- .../src/main/java/com/parse/ParsePlugins.java | 3 + .../src/main/java/com/parse/ParsePolygon.java | 1 - parse/src/main/java/com/parse/ParsePush.java | 66 +--------- .../com/parse/ParsePushBroadcastReceiver.java | 23 ++-- .../parse/ParsePushChannelsController.java | 4 +- .../java/com/parse/ParsePushController.java | 22 +--- parse/src/main/java/com/parse/ParseQuery.java | 45 +++---- .../main/java/com/parse/ParseRESTCommand.java | 2 +- .../java/com/parse/ParseRESTFileCommand.java | 7 +- .../parse/ParseRESTObjectBatchCommand.java | 2 +- .../java/com/parse/ParseRESTPushCommand.java | 6 +- .../com/parse/ParseRelationOperation.java | 3 +- .../src/main/java/com/parse/ParseRequest.java | 6 +- .../java/com/parse/ParseSQLiteCursor.java | 2 +- .../java/com/parse/ParseSQLiteDatabase.java | 56 ++++---- .../src/main/java/com/parse/ParseSession.java | 6 +- .../java/com/parse/ParseSetOperation.java | 5 +- .../main/java/com/parse/ParseTaskUtils.java | 2 +- parse/src/main/java/com/parse/ParseUser.java | 69 +++++----- .../main/java/com/parse/ParseWakeLock.java | 66 ---------- .../src/main/java/com/parse/PushHistory.java | 4 +- .../main/java/com/parse/RefreshCallback.java | 45 ------- parse/src/main/java/com/parse/TaskQueue.java | 6 +- ...chedCurrentInstallationControllerTest.java | 6 +- .../CachedCurrentUserControllerTest.java | 8 +- .../java/com/parse/EventuallyPinTest.java | 4 +- parse/src/test/java/com/parse/ListsTest.java | 2 +- .../java/com/parse/OfflineQueryLogicTest.java | 10 +- .../src/test/java/com/parse/ParseACLTest.java | 96 +++++++------- .../java/com/parse/ParseAnalyticsTest.java | 8 +- .../parse/ParseCloudCodeControllerTest.java | 6 +- .../test/java/com/parse/ParseCloudTest.java | 2 +- .../test/java/com/parse/ParseCoderTest.java | 2 +- .../com/parse/ParseConfigControllerTest.java | 2 +- .../test/java/com/parse/ParseConfigTest.java | 90 ++++++------- .../ParseCurrentConfigControllerTest.java | 2 +- .../test/java/com/parse/ParseDecoderTest.java | 2 +- .../parse/ParseDefaultACLControllerTest.java | 3 +- .../test/java/com/parse/ParseEncoderTest.java | 10 +- .../com/parse/ParseFileControllerTest.java | 4 +- .../java/com/parse/ParseFileHttpBodyTest.java | 2 +- .../java/com/parse/ParseFileUtilsTest.java | 4 +- .../java/com/parse/ParseHttpResponseTest.java | 4 +- .../java/com/parse/ParseInstallationTest.java | 14 +- .../com/parse/ParseKeyValueCacheTest.java | 6 +- .../parse/ParseObjectCurrentCoderTest.java | 2 +- .../test/java/com/parse/ParseObjectTest.java | 60 ++++----- .../test/java/com/parse/ParsePolygonTest.java | 10 +- .../com/parse/ParsePushControllerTest.java | 62 --------- .../java/com/parse/ParsePushStateTest.java | 105 +-------------- .../test/java/com/parse/ParsePushTest.java | 56 +------- .../java/com/parse/ParseQueryStateTest.java | 9 +- .../test/java/com/parse/ParseQueryTest.java | 112 ++++++++-------- .../java/com/parse/ParseRESTCommandTest.java | 11 +- .../com/parse/ParseRESTQueryCommandTest.java | 5 +- .../com/parse/ParseRESTUserCommandTest.java | 4 +- .../java/com/parse/ParseRelationTest.java | 16 +-- .../test/java/com/parse/ParseSessionTest.java | 4 +- .../com/parse/ParseUserCurrentCoderTest.java | 6 +- .../test/java/com/parse/ParseUserTest.java | 36 +++--- .../src/test/java/com/parse/SubclassTest.java | 10 +- .../java/com/parse/TaskQueueTestHelper.java | 2 +- 112 files changed, 728 insertions(+), 1174 deletions(-) create mode 100644 ktx/src/main/java/com/parse/ktx/ParseQuery.kt delete mode 100644 parse/src/main/java/com/parse/ParseWakeLock.java delete mode 100644 parse/src/main/java/com/parse/RefreshCallback.java diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c46b12b5..758be5713 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,6 @@ # Contributing to Parse SDK for Android We want to make contributing to this project as easy and transparent as possible. -## Code of Conduct -Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read [the full text](https://code.facebook.com/codeofconduct) so that you can understand what actions will and will not be tolerated. - ## Our Development Process Most of our work will be done in public directly on GitHub. There may be changes done through our internal source control, but it will be rare and only as needed. @@ -18,12 +15,6 @@ We actively welcome your pull requests. When we get one, we'll run some Parse-sp 3. If you've changed APIs, update the documentation. 4. Ensure the test suite passes. 5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). - -### Contributor License Agreement ("CLA") -In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects. - -Complete your CLA here: ## Bugs Although we try to keep developing on Parse easy, you still may run into some issues. Technical questions should be asked on [Stack Overflow][stack-overflow], and for everything else we'll be using GitHub issues. @@ -44,14 +35,8 @@ Details are key. The more information you provide us the easier it'll be for us * [Stacktrace or GTFO][stacktrace-or-gtfo]. In all honesty, full stacktraces with line numbers make a happy developer. * Anything else you find relevant. -### Security Bugs -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue. - -## Style Guide -We're still working on providing a code style for your IDE and getting a linter on GitHub, but for now try to keep the following: - -* Most importantly, match the existing code style as much as possible. -* Try to keep lines under 100 characters, if possible. +## Code of Conduct +This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/parse-community/parse-server/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to honor this code. ## License By contributing to Parse Android SDK, you agree that your contributions will be licensed under its license. @@ -60,6 +45,6 @@ By contributing to Parse Android SDK, you agree that your contributions will be [bug-reports]: https://github.com/parse-community/parse-server [rest-api]: http://docs.parseplatform.org/rest/guide/ [network-debugging-tool]: https://github.com/square/okhttp/wiki/Interceptors - [parse-api-console]: http://blog.parse.com/announcements/introducing-the-parse-api-console/ + [parse-api-console]: http://blog.parseplatform.org/announcements/introducing-the-parse-api-console/ [stacktrace-or-gtfo]: http://i.imgur.com/jacoj.jpg - [tests-dir]: /Parse/src/test/java/com/parse + [tests-dir]: /parse/src/test/java/com/parse diff --git a/fcm/build.gradle b/fcm/build.gradle index b177a2c1d..01e744c73 100644 --- a/fcm/build.gradle +++ b/fcm/build.gradle @@ -31,7 +31,7 @@ android { } dependencies { - api "com.google.firebase:firebase-messaging:15.0.2" + api "com.google.firebase:firebase-messaging:17.1.0" api "com.firebase:firebase-jobdispatcher:$firebaseJobdispatcherVersion" implementation project(':parse') } diff --git a/gcm/src/main/java/com/parse/gcm/ParseGCMJobService.java b/gcm/src/main/java/com/parse/gcm/ParseGCMJobService.java index 11fe91f67..fc00887e5 100644 --- a/gcm/src/main/java/com/parse/gcm/ParseGCMJobService.java +++ b/gcm/src/main/java/com/parse/gcm/ParseGCMJobService.java @@ -58,7 +58,7 @@ public boolean onStartJob(final JobParameters job) { Task.callInBackground(new Callable() { @Override - public Void call() throws Exception { + public Void call() { try { InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); String senderId = job.getExtras().getString(KEY_GCM_SENDER_ID); diff --git a/ktx/src/main/java/com/parse/ktx/ParseObject.kt b/ktx/src/main/java/com/parse/ktx/ParseObject.kt index 255814036..61fba1b63 100644 --- a/ktx/src/main/java/com/parse/ktx/ParseObject.kt +++ b/ktx/src/main/java/com/parse/ktx/ParseObject.kt @@ -1,4 +1,4 @@ -@file:Suppress("unused") +@file:Suppress("unused", "NOTHING_TO_INLINE") package com.parse.ktx @@ -11,7 +11,7 @@ import com.parse.ParseObject * @return the value */ @Suppress("UNCHECKED_CAST") -fun ParseObject.getAs(key: String): T = get(key) as T +inline fun ParseObject.getAs(key: String): T = get(key) as T /** * Get the object optionally as null. This has a chance of throwing an exception if the object @@ -20,7 +20,7 @@ fun ParseObject.getAs(key: String): T = get(key) as T * @return the value, or null if nothing is there */ @Suppress("UNCHECKED_CAST") -fun ParseObject.getAsOrNull(key: String): T? { +inline fun ParseObject.getAsOrNull(key: String): T? { if (containsKey(key)) { return get(key) as T? } @@ -30,7 +30,7 @@ fun ParseObject.getAsOrNull(key: String): T? { /** * [ParseObject.put] the value, doing nothing if the value is null */ -fun ParseObject.putOrIgnore(key: String, value: Any?) { +inline fun ParseObject.putOrIgnore(key: String, value: Any?) { if (value != null) { put(key, value) } @@ -39,7 +39,7 @@ fun ParseObject.putOrIgnore(key: String, value: Any?) { /** * [ParseObject.put] the value, or [ParseObject.remove] it if the value is null */ -fun ParseObject.putOrRemove(key: String, value: Any?) { +inline fun ParseObject.putOrRemove(key: String, value: Any?) { if (value == null) { remove(key) } else { @@ -52,7 +52,7 @@ fun ParseObject.putOrRemove(key: String, value: Any?) { * @param key the key * @return the value, or null if nothing is there */ -fun ParseObject.getBooleanOrNull(key: String): Boolean? { +inline fun ParseObject.getBooleanOrNull(key: String): Boolean? { if (containsKey(key)) { return getBoolean(key) } @@ -64,7 +64,7 @@ fun ParseObject.getBooleanOrNull(key: String): Boolean? { * @param key the key * @return the value, or null if nothing is there */ -fun ParseObject.getIntOrNull(key: String): Int? { +inline fun ParseObject.getIntOrNull(key: String): Int? { return getNumber(key)?.toInt() } @@ -73,7 +73,7 @@ fun ParseObject.getIntOrNull(key: String): Int? { * @param key the key * @return the value, or null if nothing is there */ -fun ParseObject.getLongOrNull(key: String): Long? { +inline fun ParseObject.getLongOrNull(key: String): Long? { return getNumber(key)?.toLong() } @@ -82,6 +82,6 @@ fun ParseObject.getLongOrNull(key: String): Long? { * @param key the key * @return the value, or null if nothing is there */ -fun ParseObject.getDoubleOrNull(key: String): Double? { +inline fun ParseObject.getDoubleOrNull(key: String): Double? { return getNumber(key)?.toDouble() } diff --git a/ktx/src/main/java/com/parse/ktx/ParseQuery.kt b/ktx/src/main/java/com/parse/ktx/ParseQuery.kt new file mode 100644 index 000000000..89fefc7ad --- /dev/null +++ b/ktx/src/main/java/com/parse/ktx/ParseQuery.kt @@ -0,0 +1,35 @@ +@file:Suppress("NOTHING_TO_INLINE", "unused") + +package com.parse.ktx + +import com.parse.ParseException +import com.parse.ParseObject +import com.parse.ParseQuery + +/** + * Parse hard limits [ParseQuery.find] to [ParseQuery.MAX_LIMIT] objects. This will fetch absolutely all the + * objects. Use with caution, since you could potentially run out of memory if your query is too large. + * Note that this will modify the current limit of the query + */ +@Throws(ParseException::class) +inline fun ParseQuery.findAll(): List { + limit = ParseQuery.MAX_LIMIT + val list = mutableListOf() + try { + while (true) { + val result = find() + list.addAll(result) + if (result.size < ParseQuery.MAX_LIMIT) { + break + } else { + setSkip(skip + ParseQuery.MAX_LIMIT) + } + } + return list + } catch (ex : ParseException) { + if (ex.code == ParseException.OBJECT_NOT_FOUND) { + return list + } + throw ex + } +} \ No newline at end of file diff --git a/parse/build.gradle b/parse/build.gradle index c5b648711..835b0f3f3 100644 --- a/parse/build.gradle +++ b/parse/build.gradle @@ -37,7 +37,7 @@ dependencies { api 'com.parse.bolts:bolts-tasks:1.4.0' api "com.squareup.okhttp3:okhttp:$okhttpVersion" - testImplementation 'org.robolectric:robolectric:3.3.2' + testImplementation 'org.robolectric:robolectric:3.8' testImplementation 'org.skyscreamer:jsonassert:1.5.0' testImplementation 'org.mockito:mockito-core:1.10.19' testImplementation "com.squareup.okhttp3:mockwebserver:$okhttpVersion" diff --git a/parse/src/main/java/com/parse/CacheQueryController.java b/parse/src/main/java/com/parse/CacheQueryController.java index a83c23d22..c3b36ce9a 100644 --- a/parse/src/main/java/com/parse/CacheQueryController.java +++ b/parse/src/main/java/com/parse/CacheQueryController.java @@ -131,7 +131,7 @@ private Task runCommandWithPolicyAsync(final CommandDelegate< return c.runFromCacheAsync().continueWithTask(new Continuation>() { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.getError() instanceof ParseException) { return c.runOnNetworkAsync(); } @@ -142,7 +142,7 @@ public Task then(Task task) throws Exception { return c.runOnNetworkAsync().continueWithTask(new Continuation>() { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { Exception error = task.getError(); if (error instanceof ParseException && ((ParseException) error).getCode() == ParseException.CONNECTION_FAILED) { diff --git a/parse/src/main/java/com/parse/CachedCurrentInstallationController.java b/parse/src/main/java/com/parse/CachedCurrentInstallationController.java index 2c88203bb..b62173ddf 100644 --- a/parse/src/main/java/com/parse/CachedCurrentInstallationController.java +++ b/parse/src/main/java/com/parse/CachedCurrentInstallationController.java @@ -50,15 +50,15 @@ public Task setAsync(final ParseInstallation installation) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return store.setAsync(installation); } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { installationId.set(installation.getInstallationId()); return task; } @@ -77,10 +77,10 @@ public Task getAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (mutex) { if (currentInstallation != null) { return Task.forResult(currentInstallation); @@ -89,7 +89,7 @@ public Task then(Task task) throws Exception { return store.getAsync().continueWith(new Continuation() { @Override - public ParseInstallation then(Task task) throws Exception { + public ParseInstallation then(Task task) { ParseInstallation current = task.getResult(); if (current == null) { current = ParseObject.create(ParseInstallation.class); @@ -121,10 +121,10 @@ public Task existsAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return store.existsAsync(); } }); diff --git a/parse/src/main/java/com/parse/CachedCurrentUserController.java b/parse/src/main/java/com/parse/CachedCurrentUserController.java index 6a9620385..762972ec4 100644 --- a/parse/src/main/java/com/parse/CachedCurrentUserController.java +++ b/parse/src/main/java/com/parse/CachedCurrentUserController.java @@ -42,10 +42,10 @@ public CachedCurrentUserController(ParseObjectStore store) { public Task setAsync(final ParseUser user) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser oldCurrentUser; synchronized (mutex) { oldCurrentUser = currentUser; @@ -56,7 +56,7 @@ public Task then(Task task) throws Exception { // We don't need to remove persisted files since we're overwriting them return oldCurrentUser.logOutAsync(false).continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { return null; // ignore errors } }); @@ -65,16 +65,16 @@ public Void then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { user.setIsCurrentUser(true); return user.synchronizeAllAuthDataAsync(); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return store.setAsync(user).continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { synchronized (mutex) { currentUserMatchesDisk = !task.isFaulted(); currentUser = user; @@ -114,10 +114,10 @@ public Task existsAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return store.existsAsync(); } }); @@ -157,7 +157,7 @@ public void clearFromDisk() { public Task getCurrentSessionTokenAsync() { return getAsync(false).onSuccess(new Continuation() { @Override - public String then(Task task) throws Exception { + public String then(Task task) { ParseUser user = task.getResult(); return user != null ? user.getSessionToken() : null; } @@ -168,16 +168,16 @@ public String then(Task task) throws Exception { public Task logOutAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { // We can parallelize disk and network work, but only after we restore the current user from // disk. final Task userTask = getAsync(false); return Task.whenAll(Arrays.asList(userTask, toAwait)).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { Task logOutTask = userTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser user = task.getResult(); if (user == null) { return task.cast(); @@ -188,7 +188,7 @@ public Task then(Task task) throws Exception { Task diskTask = store.deleteAsync().continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { boolean deleted = !task.isFaulted(); synchronized (mutex) { currentUserMatchesDisk = deleted; @@ -214,10 +214,10 @@ public Task getAsync(final boolean shouldAutoCreateUser) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task ignored) throws Exception { + public Task then(Task ignored) { ParseUser current; boolean matchesDisk; synchronized (mutex) { @@ -238,7 +238,7 @@ public Task then(Task ignored) throws Exception { return store.getAsync().continueWith(new Continuation() { @Override - public ParseUser then(Task task) throws Exception { + public ParseUser then(Task task) { ParseUser current = task.getResult(); boolean matchesDisk = !task.isFaulted(); diff --git a/parse/src/main/java/com/parse/EventuallyPin.java b/parse/src/main/java/com/parse/EventuallyPin.java index 23ee000fb..aabd88954 100644 --- a/parse/src/main/java/com/parse/EventuallyPin.java +++ b/parse/src/main/java/com/parse/EventuallyPin.java @@ -100,7 +100,7 @@ private static Task pinEventuallyCommand(int type, ParseObject ob } return pin.pinInBackground(PIN_NAME).continueWith(new Continuation() { @Override - public EventuallyPin then(Task task) throws Exception { + public EventuallyPin then(Task task) { return pin; } }); @@ -124,7 +124,7 @@ public static Task> findAllPinned(Collection exclude // from LDS. return query.findInBackground().onSuccessTask(new Continuation, Task>>() { @Override - public Task> then(Task> task) throws Exception { + public Task> then(Task> task) { final List pins = task.getResult(); List> tasks = new ArrayList<>(); @@ -137,7 +137,7 @@ public Task> then(Task> task) throws Exc return Task.whenAll(tasks).continueWithTask(new Continuation>>() { @Override - public Task> then(Task task) throws Exception { + public Task> then(Task task) { return Task.forResult(pins); } }); diff --git a/parse/src/main/java/com/parse/FileObjectStore.java b/parse/src/main/java/com/parse/FileObjectStore.java index 2d4b51354..55bf7d415 100644 --- a/parse/src/main/java/com/parse/FileObjectStore.java +++ b/parse/src/main/java/com/parse/FileObjectStore.java @@ -83,7 +83,7 @@ private static T getFromDisk( public Task setAsync(final T object) { return Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { saveToDisk(coder, object, file); //TODO (grantland): check to see if this failed? We currently don't for legacy reasons. return null; @@ -95,7 +95,7 @@ public Void call() throws Exception { public Task getAsync() { return Task.call(new Callable() { @Override - public T call() throws Exception { + public T call() { if (!file.exists()) { return null; } @@ -108,7 +108,7 @@ public T call() throws Exception { public Task existsAsync() { return Task.call(new Callable() { @Override - public Boolean call() throws Exception { + public Boolean call() { return file.exists(); } }, ParseExecutors.io()); @@ -118,7 +118,7 @@ public Boolean call() throws Exception { public Task deleteAsync() { return Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { if (file.exists() && !ParseFileUtils.deleteQuietly(file)) { throw new RuntimeException("Unable to delete"); } diff --git a/parse/src/main/java/com/parse/InstallationId.java b/parse/src/main/java/com/parse/InstallationId.java index 09235d343..a82d6e001 100644 --- a/parse/src/main/java/com/parse/InstallationId.java +++ b/parse/src/main/java/com/parse/InstallationId.java @@ -16,7 +16,7 @@ /** * Since we cannot save dirty ParseObjects to disk and we must be able to persist UUIDs across * restarts even if the ParseInstallation is not saved, we use this legacy file still as a - * boostrapping environment as well until the full ParseInstallation is cached to disk. + * bootstrapping environment as well until the full ParseInstallation is cached to disk. *

* TODO: Allow dirty objects to be saved to disk. */ diff --git a/parse/src/main/java/com/parse/Lists.java b/parse/src/main/java/com/parse/Lists.java index cf55e892b..3e70becec 100644 --- a/parse/src/main/java/com/parse/Lists.java +++ b/parse/src/main/java/com/parse/Lists.java @@ -19,8 +19,7 @@ import java.util.List; /** - * Static utility methods pertaining to {@link List} instances. Also see this - * class's counterparts {@link Sets}, {@link Maps} and {@link Queues}. + * Static utility methods pertaining to {@link List} instances. *

*

See the Guava User Guide article on diff --git a/parse/src/main/java/com/parse/ManifestInfo.java b/parse/src/main/java/com/parse/ManifestInfo.java index 58dd45ca0..e589f4c5d 100644 --- a/parse/src/main/java/com/parse/ManifestInfo.java +++ b/parse/src/main/java/com/parse/ManifestInfo.java @@ -96,14 +96,6 @@ public static int getIconId() { return iconId; } - /** - * Returns whether the given action has an associated receiver defined in the manifest. - */ - /* package */ - static boolean hasIntentReceiver(String action) { - return !getIntentReceivers(action).isEmpty(); - } - /** * Returns a list of ResolveInfo objects corresponding to the BroadcastReceivers with Intent Filters * specifying the given action within the app's package. diff --git a/parse/src/main/java/com/parse/NetworkObjectController.java b/parse/src/main/java/com/parse/NetworkObjectController.java index d4ac7dc9d..d05b776fa 100644 --- a/parse/src/main/java/com/parse/NetworkObjectController.java +++ b/parse/src/main/java/com/parse/NetworkObjectController.java @@ -36,7 +36,7 @@ public Task fetchAsync( return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseObject.State then(Task task) throws Exception { + public ParseObject.State then(Task task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init builder = state.newBuilder().clear(); @@ -65,7 +65,7 @@ public Task saveAsync( sessionToken); return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseObject.State then(Task task) throws Exception { + public ParseObject.State then(Task task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init builder = state.newBuilder().clear(); @@ -105,7 +105,7 @@ public List> saveAllAsync( final ParseDecoder decoder = decoders.get(i); tasks.add(batchTasks.get(i).onSuccess(new Continuation() { @Override - public ParseObject.State then(Task task) throws Exception { + public ParseObject.State then(Task task) { JSONObject result = task.getResult(); // Copy and clear to create an new empty instance of the same type as `state` ParseObject.State.Init builder = state.newBuilder().clear(); diff --git a/parse/src/main/java/com/parse/NetworkQueryController.java b/parse/src/main/java/com/parse/NetworkQueryController.java index 447990942..925d5ce1d 100644 --- a/parse/src/main/java/com/parse/NetworkQueryController.java +++ b/parse/src/main/java/com/parse/NetworkQueryController.java @@ -95,7 +95,7 @@ public List then(Task task) throws Exception { return command.executeAsync(restClient, ct).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // Cache the results, unless we are ignoring the cache ParseQuery.CachePolicy policy = state.cachePolicy(); if (policy != null && policy != ParseQuery.CachePolicy.IGNORE_CACHE) { @@ -106,7 +106,7 @@ public Task then(Task task) throws Exception { } }, Task.BACKGROUND_EXECUTOR).onSuccess(new Continuation() { @Override - public Integer then(Task task) throws Exception { + public Integer then(Task task) { // Convert response return task.getResult().optInt("count"); } diff --git a/parse/src/main/java/com/parse/NetworkSessionController.java b/parse/src/main/java/com/parse/NetworkSessionController.java index cf1d942d7..68fddeb2d 100644 --- a/parse/src/main/java/com/parse/NetworkSessionController.java +++ b/parse/src/main/java/com/parse/NetworkSessionController.java @@ -30,7 +30,7 @@ public Task getSessionAsync(String sessionToken) { return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseObject.State then(Task task) throws Exception { + public ParseObject.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseObject.State.Builder("_Session"), result, ParseDecoder.get()) .isComplete(true) @@ -52,7 +52,7 @@ public Task upgradeToRevocable(String sessionToken) { ParseRESTSessionCommand.upgradeToRevocableSessionCommand(sessionToken); return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseObject.State then(Task task) throws Exception { + public ParseObject.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseObject.State.Builder("_Session"), result, ParseDecoder.get()) .isComplete(true) diff --git a/parse/src/main/java/com/parse/NetworkUserController.java b/parse/src/main/java/com/parse/NetworkUserController.java index 605118644..300a1763f 100644 --- a/parse/src/main/java/com/parse/NetworkUserController.java +++ b/parse/src/main/java/com/parse/NetworkUserController.java @@ -44,7 +44,7 @@ public Task signUpAsync( return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get()) .isComplete(false) @@ -63,7 +63,7 @@ public Task logInAsync( username, password, revocableSession); return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get()) @@ -82,7 +82,7 @@ public Task logInAsync( return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { JSONObject result = task.getResult(); // TODO(grantland): Does the server really respond back with complete object data if the @@ -105,7 +105,7 @@ public Task logInAsync( authType, authData, revocableSession); return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get()) @@ -124,7 +124,7 @@ public Task getUserAsync(String sessionToken) { ParseRESTCommand command = ParseRESTUserCommand.getCurrentUserCommand(sessionToken); return command.executeAsync(client).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { JSONObject result = task.getResult(); return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get()) diff --git a/parse/src/main/java/com/parse/NoObjectsEncoder.java b/parse/src/main/java/com/parse/NoObjectsEncoder.java index 3c2ccd296..e5c4005ac 100644 --- a/parse/src/main/java/com/parse/NoObjectsEncoder.java +++ b/parse/src/main/java/com/parse/NoObjectsEncoder.java @@ -11,7 +11,7 @@ import org.json.JSONObject; /** - * Throws an exception if someone attemps to encode a {@code ParseObject}. + * Throws an exception if someone attempts to encode a {@code ParseObject}. */ class NoObjectsEncoder extends ParseEncoder { diff --git a/parse/src/main/java/com/parse/OfflineObjectStore.java b/parse/src/main/java/com/parse/OfflineObjectStore.java index 3d684a417..fc825d143 100644 --- a/parse/src/main/java/com/parse/OfflineObjectStore.java +++ b/parse/src/main/java/com/parse/OfflineObjectStore.java @@ -36,7 +36,7 @@ private static Task migrate( final ParseObjectStore from, final ParseObjectStore to) { return from.getAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final T object = task.getResult(); if (object == null) { return task; @@ -47,7 +47,7 @@ public Task then(Task task) throws Exception { to.setAsync(object) )).continueWith(new Continuation() { @Override - public T then(Task task) throws Exception { + public T then(Task task) { return object; } }); @@ -59,7 +59,7 @@ public T then(Task task) throws Exception { public Task setAsync(final T object) { return ParseObject.unpinAllInBackground(pinName).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return object.pinInBackground(pinName, false); } }); @@ -73,7 +73,7 @@ public Task getAsync() { .ignoreACLs(); return query.findInBackground().onSuccessTask(new Continuation, Task>() { @Override - public Task then(Task> task) throws Exception { + public Task then(Task> task) { List results = task.getResult(); if (results != null) { if (results.size() == 1) { @@ -86,7 +86,7 @@ public Task then(Task> task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { T ldsObject = task.getResult(); if (ldsObject != null) { return task; @@ -105,7 +105,7 @@ public Task existsAsync() { .ignoreACLs(); return query.countInBackground().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { boolean exists = task.getResult() == 1; if (exists) { return Task.forResult(true); @@ -123,7 +123,7 @@ public Task deleteAsync() { ldsTask )).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We only really care about the result of unpinning. return ldsTask; } diff --git a/parse/src/main/java/com/parse/OfflineQueryLogic.java b/parse/src/main/java/com/parse/OfflineQueryLogic.java index db61ba87d..6f6909e54 100644 --- a/parse/src/main/java/com/parse/OfflineQueryLogic.java +++ b/parse/src/main/java/com/parse/OfflineQueryLogic.java @@ -362,7 +362,6 @@ private static boolean isAnyValueRegexStartsWith(Collection constraints) { return true; } } - ; return false; } @@ -534,8 +533,7 @@ private static boolean matchesWithinConstraint(Object constraint, Object value) /** * Matches $geoIntersects constraints. */ - private static boolean matchesGeoIntersectsConstraint(Object constraint, Object value) - throws ParseException { + private static boolean matchesGeoIntersectsConstraint(Object constraint, Object value) { if (value == null || value == JSONObject.NULL) { return false; } @@ -551,8 +549,7 @@ private static boolean matchesGeoIntersectsConstraint(Object constraint, Object /** * Matches $geoWithin constraints. */ - private static boolean matchesGeoWithinConstraint(Object constraint, Object value) - throws ParseException { + private static boolean matchesGeoWithinConstraint(Object constraint, Object value) { if (value == null || value == JSONObject.NULL) { return false; } @@ -648,11 +645,8 @@ static boolean hasReadAccess(ParseUser user, T object) { if (acl.getPublicReadAccess()) { return true; } - if (user != null && acl.getReadAccess(user)) { - return true; - } + return user != null && acl.getReadAccess(user); // TODO: Implement roles. - return false; } /** @@ -671,11 +665,8 @@ static boolean hasWriteAccess(ParseUser user, T object) if (acl.getPublicWriteAccess()) { return true; } - if (user != null && acl.getWriteAccess(user)) { - return true; - } + return user != null && acl.getWriteAccess(user); // TODO: Implement roles. - return false; } /** @@ -779,8 +770,7 @@ private static Task fetchIncludeAsync( final OfflineStore store, final Object container, final String path, - final ParseSQLiteDatabase db) - throws ParseException { + final ParseSQLiteDatabase db) { // If there's no object to include, that's fine. if (container == null) { return Task.forResult(null); @@ -794,7 +784,7 @@ private static Task fetchIncludeAsync( for (final Object item : collection) { task = task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return fetchIncludeAsync(store, item, path, db); } }); @@ -840,12 +830,12 @@ public Task then(Task task) throws Exception { // Make sure the container is fetched. return Task.forResult(null).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (container instanceof ParseObject) { // Make sure this object is fetched before descending into it. return fetchIncludeAsync(store, container, null, db).onSuccess(new Continuation() { @Override - public Object then(Task task) throws Exception { + public Object then(Task task) { return ((ParseObject) container).get(key); } }); @@ -863,7 +853,7 @@ public Object then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return fetchIncludeAsync(store, task.getResult(), rest, db); } }); @@ -884,7 +874,7 @@ static Task fetchIncludesAsync( for (final String include : includes) { task = task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return fetchIncludeAsync(store, object, include, db); } }); @@ -920,7 +910,7 @@ private ConstraintMatcher createNotInQueryMatcher(Par public Task matchesAsync(T object, ParseSQLiteDatabase db) { return inQueryMatcher.matchesAsync(object, db).onSuccess(new Continuation() { @Override - public Boolean then(Task task) throws Exception { + public Boolean then(Task task) { return !task.getResult(); } }); @@ -964,7 +954,7 @@ private ConstraintMatcher createDontSelectMatcher(Par public Task matchesAsync(T object, ParseSQLiteDatabase db) { return selectMatcher.matchesAsync(object, db).onSuccess(new Continuation() { @Override - public Boolean then(Task task) throws Exception { + public Boolean then(Task task) { return !task.getResult(); } }); @@ -1031,7 +1021,7 @@ public Task matchesAsync(final T object, final ParseSQLiteDatabase db) for (final ConstraintMatcher matcher : matchers) { task = task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.getResult()) { return task; } @@ -1119,7 +1109,7 @@ public Task matchesAsync(final T object, final ParseSQLiteDatabase db) for (final ConstraintMatcher matcher : matchers) { task = task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (!task.getResult()) { return task; } diff --git a/parse/src/main/java/com/parse/OfflineStore.java b/parse/src/main/java/com/parse/OfflineStore.java index fc0a5feb0..0c19af80a 100644 --- a/parse/src/main/java/com/parse/OfflineStore.java +++ b/parse/src/main/java/com/parse/OfflineStore.java @@ -99,7 +99,7 @@ private Task getOrCreateUUIDAsync(final ParseObject object, ParseSQLiteD uuidToObjectMap.put(newUUID, object); fetchedObjects.put(object, tcs.getTask().onSuccess(new Continuation() { @Override - public ParseObject then(Task task) throws Exception { + public ParseObject then(Task task) { return object; } })); @@ -116,7 +116,7 @@ public ParseObject then(Task task) throws Exception { db.insertOrThrowAsync(OfflineSQLiteOpenHelper.TABLE_OBJECTS, values).continueWith( new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { // This will signal that the UUID does represent a row in the database. tcs.setResult(newUUID); return null; @@ -157,7 +157,7 @@ private Task getPointerAsync(final String uuid, return db.queryAsync(OfflineSQLiteOpenHelper.TABLE_OBJECTS, select, where, args).onSuccess( new Continuation() { @Override - public T then(Task task) throws Exception { + public T then(Task task) { Cursor cursor = task.getResult(); cursor.moveToFirst(); if (cursor.isAfterLast()) { @@ -257,7 +257,7 @@ private Task> findAsync( queryTask = uuidTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String uuid = task.getResult(); String table = OfflineSQLiteOpenHelper.TABLE_OBJECTS + " A " + @@ -278,7 +278,7 @@ public Task then(Task task) throws Exception { return queryTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { Cursor cursor = task.getResult(); List uuids = new ArrayList<>(); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { @@ -295,18 +295,18 @@ public Task then(Task task) throws Exception { checkedAllObjects = checkedAllObjects.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getPointerAsync(uuid, db); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { object.set(task.getResult()); return fetchLocallyAsync(object.get(), db); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (!object.get().isDataAvailable()) { return Task.forResult(false); } @@ -350,7 +350,7 @@ public Task> then(Task task) throws Exception { for (final T object : trimmedResults) { fetchedIncludesTask = fetchedIncludesTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return OfflineQueryLogic.fetchIncludesAsync(OfflineStore.this, object, query, db); } }); @@ -359,7 +359,7 @@ public Task then(Task task) throws Exception { final List finalTrimmedResults = trimmedResults; return fetchedIncludesTask.onSuccess(new Continuation>() { @Override - public List then(Task task) throws Exception { + public List then(Task task) { return finalTrimmedResults; } }); @@ -431,14 +431,14 @@ public List then(Task task) throws Exception { final Capture uuid = new Capture<>(); jsonStringTask = uuidTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { uuid.set(task.getResult()); String[] args = {uuid.get()}; return db.queryAsync(OfflineSQLiteOpenHelper.TABLE_OBJECTS, select, where, args); } }).onSuccess(new Continuation() { @Override - public String then(Task task) throws Exception { + public String then(Task task) { Cursor cursor = task.getResult(); cursor.moveToFirst(); if (cursor.isAfterLast()) { @@ -518,7 +518,7 @@ public String then(Task task) throws Exception { return jsonStringTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String jsonString = task.getResult(); if (jsonString == null) { /* @@ -558,7 +558,7 @@ protected boolean visit(Object object) { return Task.whenAll(offlineObjects.values()).onSuccess(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { object.mergeREST(object.getState(), json, new OfflineDecoder(offlineObjects)); return null; } @@ -566,7 +566,7 @@ public Void then(Task task) throws Exception { } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isCancelled()) { tcs.setCancelled(); } else if (task.isFaulted()) { @@ -615,14 +615,14 @@ private Task saveLocallyAsync( // Make sure we have a UUID for the object to be saved. return getOrCreateUUIDAsync(object, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String uuid = task.getResult(); uuidCapture.set(uuid); return updateDataForObjectAsync(uuid, object, db); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ContentValues values = new ContentValues(); values.put(OfflineSQLiteOpenHelper.KEY_KEY, key); values.put(OfflineSQLiteOpenHelper.KEY_UUID, uuidCapture.get()); @@ -686,12 +686,12 @@ private Task saveLocallyAsync( return Task.whenAll(tasks).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return objectToUuidMap.get(object); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String uuid = task.getResult(); if (uuid == null) { // The root object was never stored in the offline store, so nothing to unpin. @@ -704,12 +704,12 @@ public Task then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getOrCreateUUIDAsync(object, db); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String uuid = task.getResult(); // Call saveLocallyAsync for each of them individually. @@ -731,7 +731,7 @@ private Task unpinAsync(final ParseObject object, final ParseSQLiteDatabas } return uuidTask.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final String uuid = task.getResult(); if (uuid == null) { // The root object was never stored in the offline store, so nothing to unpin. @@ -747,7 +747,7 @@ private Task unpinAsync(final String key, final ParseSQLiteDatabase db) { // A continueWithTask that ends with "return task" is essentially a try-finally. return Task.forResult((Void) null).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // Fetch all uuids from Dependencies for key=? grouped by uuid having a count of 1 String sql = "SELECT " + OfflineSQLiteOpenHelper.KEY_UUID + " FROM " + OfflineSQLiteOpenHelper.TABLE_DEPENDENCIES + " WHERE " + OfflineSQLiteOpenHelper.KEY_KEY + "=? AND " + OfflineSQLiteOpenHelper.KEY_UUID + " IN (" + @@ -760,7 +760,7 @@ public Task then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // DELETE FROM Objects Cursor cursor = task.getResult(); @@ -773,7 +773,7 @@ public Task then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // DELETE FROM Dependencies String where = OfflineSQLiteOpenHelper.KEY_KEY + "=?"; String[] args = {key}; @@ -781,7 +781,7 @@ public Task then(Task task) throws Exception { } }).onSuccess(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { synchronized (lock) { // Remove uuids from memory for (String uuid : uuidsToDelete) { @@ -807,7 +807,7 @@ private Task deleteObjects(final List uuids, final ParseSQLiteData if (uuids.size() > MAX_SQL_VARIABLES) { return deleteObjects(uuids.subList(0, MAX_SQL_VARIABLES), db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return deleteObjects(uuids.subList(MAX_SQL_VARIABLES, uuids.size()), db); } }); @@ -840,7 +840,7 @@ public Task then(Task task) throws Exception { } return fetched.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isFaulted()) { // Catch CACHE_MISS //noinspection ThrowableResultOfMethodCallIgnored @@ -853,20 +853,20 @@ public Task then(Task task) throws Exception { return helper.getWritableDatabaseAsync().continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseSQLiteDatabase db = task.getResult(); return db.beginTransactionAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return updateDataForObjectAsync(object, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return db.setTransactionSuccessfulAsync(); } }).continueWithTask(new Continuation>() { // } finally { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.endTransactionAsync(); db.closeAsync(); return task; @@ -894,7 +894,7 @@ private Task updateDataForObjectAsync( } return uuidTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String uuid = task.getResult(); return updateDataForObjectAsync(uuid, object, db); } @@ -934,20 +934,20 @@ public Task then(Task task) throws Exception { /* package */ Task deleteDataForObjectAsync(final ParseObject object) { return helper.getWritableDatabaseAsync().continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseSQLiteDatabase db = task.getResult(); return db.beginTransactionAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return deleteDataForObjectAsync(object, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return db.setTransactionSuccessfulAsync(); } }).continueWithTask(new Continuation>() { // } finally { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.endTransactionAsync(); db.closeAsync(); return task; @@ -973,7 +973,7 @@ private Task deleteDataForObjectAsync(final ParseObject object, final Pars } uuidTask = uuidTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { uuid.set(task.getResult()); return task; } @@ -982,7 +982,7 @@ public Task then(Task task) throws Exception { // If the object was the root of a pin, unpin it. Task unpinTask = uuidTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // Find all the roots for this object. String[] select = {OfflineSQLiteOpenHelper.KEY_KEY}; String where = OfflineSQLiteOpenHelper.KEY_UUID + "=?"; @@ -991,7 +991,7 @@ public Task then(Task task) throws Exception { } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // Try to unpin this object from the pin label if it's a root of the ParsePin. Cursor cursor = task.getResult(); List uuids = new ArrayList<>(); @@ -1004,13 +1004,13 @@ public Task then(Task task) throws Exception { for (final String uuid : uuids) { Task unpinTask = getPointerAsync(uuid, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParsePin pin = (ParsePin) task.getResult(); return fetchLocallyAsync(pin, db); } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParsePin pin = task.getResult(); List modified = pin.getObjects(); @@ -1037,21 +1037,21 @@ public Task then(Task task) throws Exception { // Delete the object from the Local Datastore in case it wasn't the root of a pin. return unpinTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String where = OfflineSQLiteOpenHelper.KEY_UUID + "=?"; String[] args = {uuid.get()}; return db.deleteAsync(OfflineSQLiteOpenHelper.TABLE_DEPENDENCIES, where, args); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String where = OfflineSQLiteOpenHelper.KEY_UUID + "=?"; String[] args = {uuid.get()}; return db.deleteAsync(OfflineSQLiteOpenHelper.TABLE_OBJECTS, where, args); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (lock) { // Clean up //TODO (grantland): we should probably clean up uuidToObjectMap and objectToUuidMap, but @@ -1073,7 +1073,7 @@ private Task getParsePin(final String name, ParseSQLiteDatabase db) { */ return findAsync(query, null, null, db).onSuccess(new Continuation, ParsePin>() { @Override - public ParsePin then(Task> task) throws Exception { + public ParsePin then(Task> task) { ParsePin pin = null; if (task.getResult() != null && task.getResult().size() > 0) { pin = task.getResult().get(0); @@ -1115,7 +1115,7 @@ private Task pinAllObjectsAsync( return getParsePin(name, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParsePin pin = task.getResult(); //TODO (grantland): change to use relations. currently the related PO are only getting saved @@ -1165,7 +1165,7 @@ private Task unpinAllObjectsAsync( return getParsePin(name, db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParsePin pin = task.getResult(); //TODO (grantland): change to use relations. currently the related PO are only getting saved @@ -1203,7 +1203,7 @@ public Task call(ParseSQLiteDatabase db) { private Task unpinAllObjectsAsync(final String name, final ParseSQLiteDatabase db) { return getParsePin(name, db).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isFaulted()) { return task.makeVoid(); } @@ -1238,7 +1238,7 @@ private Task> findFromPinAsync( } return task.onSuccessTask(new Continuation>>() { @Override - public Task> then(Task task) throws Exception { + public Task> then(Task task) { ParsePin pin = task.getResult(); return findAsync(state, user, pin, false, db); } @@ -1270,11 +1270,11 @@ private Task countFromPinAsync( } return task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParsePin pin = task.getResult(); return findAsync(state, user, pin, true, db).onSuccess(new Continuation, Integer>() { @Override - public Integer then(Task> task) throws Exception { + public Integer then(Task> task) { return task.getResult().size(); } }); @@ -1337,7 +1337,7 @@ public Integer then(Task> task) throws Exception { if (oldObjectId.equals(newObjectId)) { return; } - /** + /* * Special case for re-saving installation if it was deleted on the server * @see ParseInstallation#saveAsync(String, Task) */ @@ -1374,11 +1374,11 @@ public Integer then(Task> task) throws Exception { private Task runWithManagedConnection(final SQLiteDatabaseCallable> callable) { return helper.getWritableDatabaseAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseSQLiteDatabase db = task.getResult(); return callable.call(db).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.closeAsync(); return task; } @@ -1393,19 +1393,19 @@ public Task then(Task task) throws Exception { private Task runWithManagedTransaction(final SQLiteDatabaseCallable> callable) { return helper.getWritableDatabaseAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseSQLiteDatabase db = task.getResult(); return db.beginTransactionAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return callable.call(db).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return db.setTransactionSuccessfulAsync(); } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.endTransactionAsync(); db.closeAsync(); return task; @@ -1502,7 +1502,7 @@ public OfflineEncoder(ParseSQLiteDatabase db) { public Task whenFinished() { return Task.whenAll(tasks).continueWithTask(new Continuation>() { @Override - public Task then(Task ignore) throws Exception { + public Task then(Task ignore) { synchronized (tasksLock) { // It might be better to return an aggregate error here. for (Task task : tasks) { diff --git a/parse/src/main/java/com/parse/Parse.java b/parse/src/main/java/com/parse/Parse.java index 44b72a4eb..9d4c3c180 100644 --- a/parse/src/main/java/com/parse/Parse.java +++ b/parse/src/main/java/com/parse/Parse.java @@ -33,6 +33,7 @@ * The {@code Parse} class contains static functions that handle global configuration for the Parse * library. */ +@SuppressWarnings("unused") public class Parse { public static final int LOG_LEVEL_VERBOSE = Log.VERBOSE; public static final int LOG_LEVEL_DEBUG = Log.DEBUG; @@ -158,7 +159,7 @@ static void initialize(Configuration configuration, ParsePlugins parsePlugins) { final Context context = configuration.context; Task.callInBackground(new Callable() { @Override - public Void call() throws Exception { + public Void call() { getEventuallyQueue(context); return null; } @@ -175,7 +176,7 @@ public Void call() throws Exception { ParseUser.getCurrentUserAsync().makeVoid().continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { // Prime config in the background ParseConfig.getCurrentConfig(); return null; diff --git a/parse/src/main/java/com/parse/ParseAnalytics.java b/parse/src/main/java/com/parse/ParseAnalytics.java index edffe0088..98b7427f8 100644 --- a/parse/src/main/java/com/parse/ParseAnalytics.java +++ b/parse/src/main/java/com/parse/ParseAnalytics.java @@ -68,21 +68,13 @@ public static Task trackAppOpenedInBackground(Intent intent) { } return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String sessionToken = task.getResult(); return getAnalyticsController().trackAppOpenedInBackground(pushHash.get(), sessionToken); } }); } - /** - * @deprecated Please use {@link #trackAppOpenedInBackground(android.content.Intent)} instead. - */ - @Deprecated - public static void trackAppOpened(Intent intent) { - trackAppOpenedInBackground(intent); - } - /** * Tracks this application being launched (and if this happened as the result of the user opening * a push notification, this method sends along information to correlate this open with that @@ -95,14 +87,6 @@ public static void trackAppOpenedInBackground(Intent intent, SaveCallback callba ParseTaskUtils.callbackOnMainThreadAsync(trackAppOpenedInBackground(intent), callback); } - /** - * @deprecated Please use {@link #trackEventInBackground(String)} instead. - */ - @Deprecated - public static void trackEvent(String name) { - trackEventInBackground(name); - } - /** * Tracks the occurrence of a custom event. Parse will store a data point at the time of * invocation with the given event name. @@ -114,14 +98,6 @@ public static void trackEventInBackground(String name, SaveCallback callback) { ParseTaskUtils.callbackOnMainThreadAsync(trackEventInBackground(name), callback); } - /** - * @deprecated Please use {@link #trackEventInBackground(String, java.util.Map)} instead. - */ - @Deprecated - public static void trackEvent(String name, Map dimensions) { - trackEventInBackground(name, dimensions); - } - /** * Tracks the occurrence of a custom event with additional dimensions. Parse will store a data * point at the time of invocation with the given event name. Dimensions will allow segmentation @@ -197,7 +173,7 @@ public static Task trackEventInBackground(final String name, return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String sessionToken = task.getResult(); return getAnalyticsController().trackEventInBackground(name, dimensionsCopy, sessionToken); } diff --git a/parse/src/main/java/com/parse/ParseAnonymousUtils.java b/parse/src/main/java/com/parse/ParseAnonymousUtils.java index c96d2c5a0..fcbc49337 100644 --- a/parse/src/main/java/com/parse/ParseAnonymousUtils.java +++ b/parse/src/main/java/com/parse/ParseAnonymousUtils.java @@ -35,6 +35,7 @@ * * */ +@SuppressWarnings("unused") public final class ParseAnonymousUtils { /* package */ static final String AUTH_TYPE = "anonymous"; diff --git a/parse/src/main/java/com/parse/ParseAuthenticationManager.java b/parse/src/main/java/com/parse/ParseAuthenticationManager.java index 2a6720eeb..814fa7ae6 100644 --- a/parse/src/main/java/com/parse/ParseAuthenticationManager.java +++ b/parse/src/main/java/com/parse/ParseAuthenticationManager.java @@ -46,7 +46,7 @@ public void register(final String authType, AuthenticationCallback callback) { // Synchronize the current user with the auth callback. controller.getAsync(false).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser user = task.getResult(); if (user != null) { return user.synchronizeAuthDataAsync(authType); @@ -66,7 +66,7 @@ public Task restoreAuthenticationAsync(String authType, final Map() { @Override - public Boolean call() throws Exception { + public Boolean call() { return callback.onRestore(authData); } }, ParseExecutors.io()); @@ -80,7 +80,7 @@ public Task deauthenticateAsync(String authType) { if (callback != null) { return Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { callback.onRestore(null); return null; } diff --git a/parse/src/main/java/com/parse/ParseClassName.java b/parse/src/main/java/com/parse/ParseClassName.java index 23c25d6c9..658cf23ca 100644 --- a/parse/src/main/java/com/parse/ParseClassName.java +++ b/parse/src/main/java/com/parse/ParseClassName.java @@ -8,6 +8,7 @@ */ package com.parse; +import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; @@ -20,6 +21,7 @@ @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Inherited +@Documented public @interface ParseClassName { /** * @return The Parse class name associated with the ParseObject subclass. diff --git a/parse/src/main/java/com/parse/ParseCloud.java b/parse/src/main/java/com/parse/ParseCloud.java index 84b7e4b79..ed6c317e1 100644 --- a/parse/src/main/java/com/parse/ParseCloud.java +++ b/parse/src/main/java/com/parse/ParseCloud.java @@ -61,7 +61,7 @@ public static Task callFunctionInBackground(final String name, final Map params) { return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String sessionToken = task.getResult(); return getCloudCodeController().callFunctionInBackground(name, params, sessionToken); } @@ -77,7 +77,7 @@ public Task then(Task task) throws Exception { * @return The result of the cloud call. Result may be a @{link Map}< {@link String}, ?>, * {@link ParseObject}, {@link List}<?>, or any type that can be set as a field in a * ParseObject. - * @throws ParseException + * @throws ParseException exception */ public static T callFunction(String name, Map params) throws ParseException { return ParseTaskUtils.wait(ParseCloud.callFunctionInBackground(name, params)); diff --git a/parse/src/main/java/com/parse/ParseCloudCodeController.java b/parse/src/main/java/com/parse/ParseCloudCodeController.java index 9195d9ab7..b46898df3 100644 --- a/parse/src/main/java/com/parse/ParseCloudCodeController.java +++ b/parse/src/main/java/com/parse/ParseCloudCodeController.java @@ -31,7 +31,7 @@ public Task callFunctionInBackground(final String name, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation() { @Override - public T then(Task task) throws Exception { + public T then(Task task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; diff --git a/parse/src/main/java/com/parse/ParseCommandCache.java b/parse/src/main/java/com/parse/ParseCommandCache.java index 7ee4d51ac..f9fb874cc 100644 --- a/parse/src/main/java/com/parse/ParseCommandCache.java +++ b/parse/src/main/java/com/parse/ParseCommandCache.java @@ -73,7 +73,7 @@ public void networkConnectivityStatusChanged(Context context, Intent intent) { */ Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { if (connectionLost) { setConnected(false); } else { @@ -427,7 +427,7 @@ private T waitForTaskWithoutLock(Task task) throws ParseException { final Capture finished = new Capture<>(false); task.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { finished.set(true); synchronized (lock) { lock.notifyAll(); @@ -520,7 +520,7 @@ private void maybeRunAllCommandsNow(int retriesRemaining) { } else { commandTask = command.executeAsync(httpClient).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String localId = command.getLocalId(); Exception error = task.getError(); if (error != null) { diff --git a/parse/src/main/java/com/parse/ParseConfig.java b/parse/src/main/java/com/parse/ParseConfig.java index 270b0b9ef..7c7b1eaf6 100644 --- a/parse/src/main/java/com/parse/ParseConfig.java +++ b/parse/src/main/java/com/parse/ParseConfig.java @@ -89,7 +89,7 @@ public static void getInBackground(ConfigCallback callback) { public static Task getInBackground() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return getAsync(toAwait); } }); @@ -98,11 +98,11 @@ public Task then(Task toAwait) throws Exception { private static Task getAsync(final Task toAwait) { return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final String sessionToken = task.getResult(); return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getConfigController().getAsync(sessionToken); } }); diff --git a/parse/src/main/java/com/parse/ParseConfigController.java b/parse/src/main/java/com/parse/ParseConfigController.java index db01d7443..c64061694 100644 --- a/parse/src/main/java/com/parse/ParseConfigController.java +++ b/parse/src/main/java/com/parse/ParseConfigController.java @@ -32,13 +32,13 @@ public Task getAsync(String sessionToken) { final ParseRESTCommand command = ParseRESTConfigCommand.fetchConfigCommand(sessionToken); return command.executeAsync(restClient).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { JSONObject result = task.getResult(); final ParseConfig config = ParseConfig.decode(result, ParseDecoder.get()); return currentConfigController.setCurrentConfigAsync(config).continueWith(new Continuation() { @Override - public ParseConfig then(Task task) throws Exception { + public ParseConfig then(Task task) { return config; } }); diff --git a/parse/src/main/java/com/parse/ParseCurrentConfigController.java b/parse/src/main/java/com/parse/ParseCurrentConfigController.java index 8278c9b65..723374a93 100644 --- a/parse/src/main/java/com/parse/ParseCurrentConfigController.java +++ b/parse/src/main/java/com/parse/ParseCurrentConfigController.java @@ -30,7 +30,7 @@ public ParseCurrentConfigController(File currentConfigFile) { public Task setCurrentConfigAsync(final ParseConfig config) { return Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { synchronized (currentConfigMutex) { currentConfig = config; saveToDisk(config); @@ -43,7 +43,7 @@ public Void call() throws Exception { public Task getCurrentConfigAsync() { return Task.call(new Callable() { @Override - public ParseConfig call() throws Exception { + public ParseConfig call() { synchronized (currentConfigMutex) { if (currentConfig == null) { ParseConfig config = getFromDisk(); diff --git a/parse/src/main/java/com/parse/ParseCurrentUserController.java b/parse/src/main/java/com/parse/ParseCurrentUserController.java index cdd131682..604510887 100644 --- a/parse/src/main/java/com/parse/ParseCurrentUserController.java +++ b/parse/src/main/java/com/parse/ParseCurrentUserController.java @@ -16,30 +16,30 @@ interface ParseCurrentUserController /** * Gets the persisted current ParseUser. * - * @param shouldAutoCreateUser - * @return + * @param shouldAutoCreateUser should auto create user + * @return task */ Task getAsync(boolean shouldAutoCreateUser); /** * Sets the persisted current ParseUser only if it's current or we're not synced with disk. * - * @param user - * @return + * @param user user + * @return task */ Task setIfNeededAsync(ParseUser user); /** * Gets the session token of the persisted current ParseUser. * - * @return + * @return task */ Task getCurrentSessionTokenAsync(); /** * Logs out the current ParseUser. * - * @return + * @return task */ Task logOutAsync(); } diff --git a/parse/src/main/java/com/parse/ParseDecoder.java b/parse/src/main/java/com/parse/ParseDecoder.java index fd1852097..2cb8a1634 100644 --- a/parse/src/main/java/com/parse/ParseDecoder.java +++ b/parse/src/main/java/com/parse/ParseDecoder.java @@ -127,7 +127,7 @@ public Object decode(Object object) { } if (typeString.equals("Polygon")) { - List coordinates = new ArrayList(); + List coordinates = new ArrayList<>(); try { JSONArray array = jsonObject.getJSONArray("coordinates"); for (int i = 0; i < array.length(); ++i) { diff --git a/parse/src/main/java/com/parse/ParseException.java b/parse/src/main/java/com/parse/ParseException.java index f6d426eea..1b2124379 100644 --- a/parse/src/main/java/com/parse/ParseException.java +++ b/parse/src/main/java/com/parse/ParseException.java @@ -13,6 +13,7 @@ * deleting or editing an object that no longer exists on the server, or when there is a network * failure preventing communication with the Parse server. */ +@SuppressWarnings("unused") public class ParseException extends Exception { public static final int OTHER_CAUSE = -1; /** diff --git a/parse/src/main/java/com/parse/ParseFieldOperations.java b/parse/src/main/java/com/parse/ParseFieldOperations.java index 28e3bed47..b78246730 100644 --- a/parse/src/main/java/com/parse/ParseFieldOperations.java +++ b/parse/src/main/java/com/parse/ParseFieldOperations.java @@ -61,8 +61,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseDeleteOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return ParseDeleteOperation.getInstance(); } @@ -74,8 +73,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseIncrementOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return new ParseIncrementOperation((Number) decoder.decode(object.opt("amount"))); } @@ -87,8 +85,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseAddOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return new ParseAddOperation((Collection) decoder.decode(object.opt("objects"))); } @@ -105,8 +102,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseAddUniqueOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return new ParseAddUniqueOperation((Collection) decoder.decode(object.opt("objects"))); } @@ -123,8 +119,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseRemoveOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return new ParseRemoveOperation((Collection) decoder.decode(object.opt("objects"))); } @@ -141,8 +136,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseRelationOperation.OP_NAME_ADD, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { JSONArray objectsArray = object.optJSONArray("objects"); List objectsList = (List) decoder.decode(objectsArray); return new ParseRelationOperation<>(new HashSet<>(objectsList), null); @@ -161,8 +155,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseRelationOperation.OP_NAME_REMOVE, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) - throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { JSONArray objectsArray = object.optJSONArray("objects"); List objectsList = (List) decoder.decode(objectsArray); return new ParseRelationOperation<>(null, new HashSet<>(objectsList)); @@ -181,7 +174,7 @@ public ParseFieldOperation decode(Parcel source, ParseParcelDecoder decoder) { registerDecoder(ParseSetOperation.OP_NAME, new ParseFieldOperationFactory() { @Override - public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) throws JSONException { + public ParseFieldOperation decode(JSONObject object, ParseDecoder decoder) { return null; // Not called. } diff --git a/parse/src/main/java/com/parse/ParseFile.java b/parse/src/main/java/com/parse/ParseFile.java index 7535f1d96..768469be4 100644 --- a/parse/src/main/java/com/parse/ParseFile.java +++ b/parse/src/main/java/com/parse/ParseFile.java @@ -191,7 +191,7 @@ private static ProgressCallback progressCallbackOnMainThread( public void done(final Integer percentDone) { Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { progressCallback.done(percentDone); return null; } @@ -261,7 +261,7 @@ private Task saveAsync(final String sessionToken, // Wait for our turn in the queue, then check state to decide whether to no-op. return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (!isDirty()) { return Task.forResult(null); } @@ -288,7 +288,7 @@ public Task then(Task task) throws Exception { return saveTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { state = task.getResult(); // Since we have successfully uploaded the file, we do not need to hold the file pointer // anymore. @@ -314,13 +314,13 @@ public Task saveInBackground(final ProgressCallback uploadProgressCallback return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final String sessionToken = task.getResult(); return saveAsync(sessionToken, uploadProgressCallback, cts.getTask()); } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { cts.trySetResult(null); // release currentTasks.remove(cts); return task; @@ -332,7 +332,7 @@ public Task then(Task task) throws Exception { final ProgressCallback uploadProgressCallback, final Task cancellationToken) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return saveAsync(sessionToken, uploadProgressCallback, toAwait, cancellationToken); } }); @@ -390,10 +390,10 @@ public Task getDataInBackground(final ProgressCallback progressCallback) return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return fetchInBackground(progressCallback, toAwait, cts.getTask()).onSuccess(new Continuation() { @Override - public byte[] then(Task task) throws Exception { + public byte[] then(Task task) { File file = task.getResult(); try { return ParseFileUtils.readFileToByteArray(file); @@ -406,7 +406,7 @@ public byte[] then(Task task) throws Exception { } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { cts.trySetResult(null); // release currentTasks.remove(cts); return task; @@ -472,12 +472,12 @@ public Task getFileInBackground(final ProgressCallback progressCallback) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return fetchInBackground(progressCallback, toAwait, cts.getTask()); } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { cts.trySetResult(null); // release currentTasks.remove(cts); return task; @@ -550,7 +550,7 @@ public Task getDataStreamInBackground(final ProgressCallback progre return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return fetchInBackground(progressCallback, toAwait, cts.getTask()).onSuccess(new Continuation() { @Override public InputStream then(Task task) throws Exception { @@ -560,7 +560,7 @@ public InputStream then(Task task) throws Exception { } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { cts.trySetResult(null); // release currentTasks.remove(cts); return task; @@ -616,7 +616,7 @@ private Task fetchInBackground( return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (cancellationToken != null && cancellationToken.isCancelled()) { return Task.cancelled(); } diff --git a/parse/src/main/java/com/parse/ParseFileController.java b/parse/src/main/java/com/parse/ParseFileController.java index 769556c42..c25d30600 100644 --- a/parse/src/main/java/com/parse/ParseFileController.java +++ b/parse/src/main/java/com/parse/ParseFileController.java @@ -182,12 +182,12 @@ public Task fetchAsync( final File cacheFile = getCacheFile(state); return Task.call(new Callable() { @Override - public Boolean call() throws Exception { + public Boolean call() { return cacheFile.exists(); } }, ParseExecutors.io()).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { boolean result = task.getResult(); if (result) { return Task.forResult(cacheFile); diff --git a/parse/src/main/java/com/parse/ParseFileUtils.java b/parse/src/main/java/com/parse/ParseFileUtils.java index 304d338f5..046f16a6e 100644 --- a/parse/src/main/java/com/parse/ParseFileUtils.java +++ b/parse/src/main/java/com/parse/ParseFileUtils.java @@ -315,7 +315,7 @@ private static void doCopyFile(final File srcFile, final File destFile, final bo output = fos.getChannel(); final long size = input.size(); // TODO See IO-386 long pos = 0; - long count = 0; + long count; while (pos < size) { final long remain = size - pos; count = remain > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : remain; @@ -490,7 +490,7 @@ public static boolean isSymlink(final File file) throws IOException { // if (FilenameUtils.isSystemWindows()) { // return false; // } - File fileInCanonicalDir = null; + File fileInCanonicalDir; if (file.getParent() == null) { fileInCanonicalDir = file; } else { @@ -498,11 +498,7 @@ public static boolean isSymlink(final File file) throws IOException { fileInCanonicalDir = new File(canonicalDir, file.getName()); } - if (fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile())) { - return false; - } else { - return true; - } + return !fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile()); } //region String diff --git a/parse/src/main/java/com/parse/ParseGeoPoint.java b/parse/src/main/java/com/parse/ParseGeoPoint.java index df5500fca..9ad3bc273 100644 --- a/parse/src/main/java/com/parse/ParseGeoPoint.java +++ b/parse/src/main/java/com/parse/ParseGeoPoint.java @@ -122,7 +122,7 @@ public static Task getCurrentLocationInBackground(long timeout) { return LocationNotifier.getCurrentLocationAsync(Parse.getApplicationContext(), timeout, criteria) .onSuccess(new Continuation() { @Override - public ParseGeoPoint then(Task task) throws Exception { + public ParseGeoPoint then(Task task) { Location location = task.getResult(); return new ParseGeoPoint(location.getLatitude(), location.getLongitude()); } @@ -169,7 +169,7 @@ public static Task getCurrentLocationInBackground(long timeout, C return LocationNotifier.getCurrentLocationAsync(Parse.getApplicationContext(), timeout, criteria) .onSuccess(new Continuation() { @Override - public ParseGeoPoint then(Task task) throws Exception { + public ParseGeoPoint then(Task task) { Location location = task.getResult(); return new ParseGeoPoint(location.getLatitude(), location.getLongitude()); } diff --git a/parse/src/main/java/com/parse/ParseHttpClient.java b/parse/src/main/java/com/parse/ParseHttpClient.java index ecfb6e84c..061fdd736 100644 --- a/parse/src/main/java/com/parse/ParseHttpClient.java +++ b/parse/src/main/java/com/parse/ParseHttpClient.java @@ -36,6 +36,7 @@ class ParseHttpClient { private OkHttpClient okHttpClient; private boolean hasExecuted; + ParseHttpClient(@Nullable OkHttpClient.Builder builder) { if (builder == null) { @@ -72,8 +73,7 @@ ParseHttpResponse executeInternal(ParseHttpRequest parseRequest) throws IOExcept return getResponse(okHttpResponse); } - ParseHttpResponse getResponse(Response okHttpResponse) - throws IOException { + ParseHttpResponse getResponse(Response okHttpResponse) { // Status code int statusCode = okHttpResponse.code(); @@ -109,7 +109,7 @@ ParseHttpResponse getResponse(Response okHttpResponse) .build(); } - Request getRequest(ParseHttpRequest parseRequest) throws IOException { + Request getRequest(ParseHttpRequest parseRequest) { Request.Builder okHttpRequestBuilder = new Request.Builder(); ParseHttpRequest.Method method = parseRequest.getMethod(); // Set method @@ -168,7 +168,7 @@ private static class ParseOkHttpRequestBody extends RequestBody { } @Override - public long contentLength() throws IOException { + public long contentLength() { return parseBody.getContentLength(); } diff --git a/parse/src/main/java/com/parse/ParseIOUtils.java b/parse/src/main/java/com/parse/ParseIOUtils.java index 9b115b884..b1f875589 100644 --- a/parse/src/main/java/com/parse/ParseIOUtils.java +++ b/parse/src/main/java/com/parse/ParseIOUtils.java @@ -141,7 +141,7 @@ public static long copyLarge(InputStream input, OutputStream output) public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; - int n = 0; + int n; while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; diff --git a/parse/src/main/java/com/parse/ParseInstallation.java b/parse/src/main/java/com/parse/ParseInstallation.java index 7ab3512a1..3842bc1ca 100644 --- a/parse/src/main/java/com/parse/ParseInstallation.java +++ b/parse/src/main/java/com/parse/ParseInstallation.java @@ -135,7 +135,7 @@ public void setObjectId(String newObjectId) { } return result.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return ParseInstallation.super.fetchAsync(sessionToken, toAwait); } }); @@ -146,7 +146,7 @@ public Task then(Task task) throws Exception { /* package */ Task saveAsync(final String sessionToken, final Task toAwait) { return super.saveAsync(sessionToken, toAwait).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // Retry the fetch as a save operation because this Installation was deleted on the server. if (task.getError() != null && task.getError() instanceof ParseException) { @@ -176,7 +176,7 @@ public Task then(Task task) throws Exception { return task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getCurrentInstallationController().setAsync(ParseInstallation.this); } }); @@ -186,7 +186,7 @@ public Task then(Task task) throws Exception { /* package */ Task handleFetchResultAsync(final ParseObject.State newState) { return super.handleFetchResultAsync(newState).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getCurrentInstallationController().setAsync(ParseInstallation.this); } }); @@ -292,7 +292,7 @@ public String getPushType() { public void setPushType(String pushType) { if (pushType != null) { - performPut(KEY_PUSH_TYPE, pushType.toString()); + performPut(KEY_PUSH_TYPE, pushType); } } diff --git a/parse/src/main/java/com/parse/ParseJSONUtils.java b/parse/src/main/java/com/parse/ParseJSONUtils.java index 24774b71d..6ac3a565c 100644 --- a/parse/src/main/java/com/parse/ParseJSONUtils.java +++ b/parse/src/main/java/com/parse/ParseJSONUtils.java @@ -8,6 +8,8 @@ */ package com.parse; +import android.support.annotation.NonNull; + import org.json.JSONException; import org.json.JSONObject; @@ -16,7 +18,7 @@ import java.util.List; /** - * Static utility methods pertaining to {@link JSONObject} and {@link JSONArray} instances. + * Static utility methods pertaining to org.json classes. */ class ParseJSONUtils { @@ -47,6 +49,7 @@ public static JSONObject create(JSONObject copyFrom, Collection excludes public static Iterable keys(JSONObject object) { final JSONObject finalObject = object; return new Iterable() { + @NonNull @Override public Iterator iterator() { return finalObject.keys(); diff --git a/parse/src/main/java/com/parse/ParseNotificationManager.java b/parse/src/main/java/com/parse/ParseNotificationManager.java index 68a8e9acf..9c4e87197 100644 --- a/parse/src/main/java/com/parse/ParseNotificationManager.java +++ b/parse/src/main/java/com/parse/ParseNotificationManager.java @@ -18,46 +18,34 @@ * A utility class for building and showing notifications. */ class ParseNotificationManager { - public static final String TAG = "com.parse.ParseNotificationManager"; private final AtomicInteger notificationCount = new AtomicInteger(0); - private volatile boolean shouldShowNotifications = true; public static ParseNotificationManager getInstance() { return Singleton.INSTANCE; } - public void setShouldShowNotifications(boolean show) { - shouldShowNotifications = show; - } - - public int getNotificationCount() { - return notificationCount.get(); - } - public void showNotification(Context context, Notification notification) { if (context != null && notification != null) { notificationCount.incrementAndGet(); - if (shouldShowNotifications) { - // Fire off the notification - NotificationManager nm = - (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - - // Pick an id that probably won't overlap anything - int notificationId = (int) System.currentTimeMillis(); - - try { - nm.notify(notificationId, notification); - } catch (SecurityException e) { - // Some phones throw an exception for unapproved vibration - notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND; - nm.notify(notificationId, notification); - } + // Fire off the notification + NotificationManager nm = + (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + + // Pick an id that probably won't overlap anything + int notificationId = (int) System.currentTimeMillis(); + + try { + nm.notify(notificationId, notification); + } catch (SecurityException e) { + // Some phones throw an exception for unapproved vibration + notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND; + nm.notify(notificationId, notification); } } } - public static class Singleton { + private static class Singleton { private static final ParseNotificationManager INSTANCE = new ParseNotificationManager(); } } diff --git a/parse/src/main/java/com/parse/ParseObject.java b/parse/src/main/java/com/parse/ParseObject.java index db96e2a8c..a9cab958b 100644 --- a/parse/src/main/java/com/parse/ParseObject.java +++ b/parse/src/main/java/com/parse/ParseObject.java @@ -2792,7 +2792,7 @@ private Task deleteAsync(final String sessionToken, Task toAwait) { return toAwait.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { isDeleting = true; if (state.objectId() == null) { return task.cast(); // no reason to call delete since it doesn't exist diff --git a/parse/src/main/java/com/parse/ParseObjectCurrentController.java b/parse/src/main/java/com/parse/ParseObjectCurrentController.java index 3c9a648e5..39cfd8669 100644 --- a/parse/src/main/java/com/parse/ParseObjectCurrentController.java +++ b/parse/src/main/java/com/parse/ParseObjectCurrentController.java @@ -15,29 +15,29 @@ interface ParseObjectCurrentController { /** * Persist the currentParseObject * - * @param object - * @return + * @param object object + * @return task */ Task setAsync(T object); /** * Get the persisted currentParseObject * - * @return + * @return task */ Task getAsync(); /** * Check whether the currentParseObject exists or not * - * @return + * @return task */ Task existsAsync(); /** * Judge whether the given ParseObject is the currentParseObject * - * @param object + * @param object object * @return {@code true} if the give {@link ParseObject} is the currentParseObject */ boolean isCurrent(T object); diff --git a/parse/src/main/java/com/parse/ParseObjectSubclassingController.java b/parse/src/main/java/com/parse/ParseObjectSubclassingController.java index 7442a1d54..7135fbaf2 100644 --- a/parse/src/main/java/com/parse/ParseObjectSubclassingController.java +++ b/parse/src/main/java/com/parse/ParseObjectSubclassingController.java @@ -39,7 +39,7 @@ private static Constructor getConstructor(Class clazz) { - Constructor constructor = null; + Constructor constructor; synchronized (mutex) { constructor = registeredSubclasses.get(className); @@ -56,7 +56,7 @@ private static Constructor getConstructor(Class previousConstructor = null; + Constructor previousConstructor; synchronized (mutex) { previousConstructor = registeredSubclasses.get(className); @@ -111,7 +111,7 @@ private static Constructor getConstructor(Class constructor = null; + Constructor constructor; synchronized (mutex) { constructor = registeredSubclasses.get(className); diff --git a/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java b/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java index 6b96abe2a..dc2aa7285 100644 --- a/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java +++ b/parse/src/main/java/com/parse/ParsePinningEventuallyQueue.java @@ -122,10 +122,10 @@ public void setConnected(boolean connected) { super.setConnected(connected); if (connected) { connectionTaskCompletionSource.trySetResult(null); - connectionTaskCompletionSource = Task.create(); + connectionTaskCompletionSource = new TaskCompletionSource<>(); connectionTaskCompletionSource.trySetResult(null); } else { - connectionTaskCompletionSource = Task.create(); + connectionTaskCompletionSource = new TaskCompletionSource<>(); } } } @@ -145,10 +145,10 @@ public Task pendingCountAsync() { taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return pendingCountAsync(toAwait).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { int count = task.getResult(); tcs.setResult(count); return Task.forResult(null); @@ -163,10 +163,10 @@ public Task then(Task task) throws Exception { public Task pendingCountAsync(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return EventuallyPin.findAllPinned().continueWithTask(new Continuation, Task>() { @Override - public Task then(Task> task) throws Exception { + public Task then(Task> task) { List pins = task.getResult(); return Task.forResult(pins.size()); } @@ -180,7 +180,7 @@ public void pause() { synchronized (connectionLock) { // Error out tasks waiting on waitForConnectionAsync. connectionTaskCompletionSource.trySetError(new PauseException()); - connectionTaskCompletionSource = Task.create(); + connectionTaskCompletionSource = new TaskCompletionSource<>(); connectionTaskCompletionSource.trySetError(new PauseException()); } @@ -206,10 +206,10 @@ public void resume() { // Reset waitForConnectionAsync. if (isConnected()) { connectionTaskCompletionSource.trySetResult(null); - connectionTaskCompletionSource = Task.create(); + connectionTaskCompletionSource = new TaskCompletionSource<>(); connectionTaskCompletionSource.trySetResult(null); } else { - connectionTaskCompletionSource = Task.create(); + connectionTaskCompletionSource = new TaskCompletionSource<>(); } populateQueueAsync(); @@ -234,7 +234,7 @@ public Task enqueueEventuallyAsync(final ParseRESTCommand command, taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return enqueueEventuallyAsync(command, object, toAwait, tcs); } }); @@ -246,12 +246,12 @@ private Task enqueueEventuallyAsync(final ParseRESTCommand command, final ParseObject object, Task toAwait, final TaskCompletionSource tcs) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { Task pinTask = EventuallyPin.pinEventuallyCommand(object, command); return pinTask.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { EventuallyPin pin = task.getResult(); Exception error = task.getError(); if (error != null) { @@ -267,7 +267,7 @@ public Task then(Task task) throws Exception { // We don't need to wait for this. populateQueueAsync().continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { /* * We need to wait until after we populated the operationSetTaskQueue to notify * that we've enqueued this command. @@ -293,7 +293,7 @@ public Task then(Task task) throws Exception { private Task populateQueueAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return populateQueueAsync(toAwait); } }); @@ -302,13 +302,13 @@ public Task then(Task toAwait) throws Exception { private Task populateQueueAsync(Task toAwait) { return toAwait.continueWithTask(new Continuation>>() { @Override - public Task> then(Task task) throws Exception { + public Task> then(Task task) { // We don't want to enqueue any EventuallyPins that are already queued. return EventuallyPin.findAllPinned(eventuallyPinUUIDQueue); } }).onSuccessTask(new Continuation, Task>() { @Override - public Task then(Task> task) throws Exception { + public Task then(Task> task) { List pins = task.getResult(); for (final EventuallyPin pin : pins) { @@ -337,10 +337,10 @@ private Task runEventuallyAsync(final EventuallyPin eventuallyPin) { operationSetTaskQueue.enqueue(new Continuation>() { @Override - public Task then(final Task toAwait) throws Exception { + public Task then(final Task toAwait) { return runEventuallyAsync(eventuallyPin, toAwait).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { eventuallyPinUUIDQueue.remove(uuid); return task; } @@ -360,15 +360,15 @@ public Task then(Task task) throws Exception { private Task runEventuallyAsync(final EventuallyPin eventuallyPin, final Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return waitForConnectionAsync(); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return waitForOperationSetAndEventuallyPin(null, eventuallyPin).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { Exception error = task.getError(); if (error != null) { if (error instanceof PauseException) { @@ -438,7 +438,7 @@ public Task then(Task task) throws Exception { if (pendingEventuallyTasks.containsKey(uuid)) { tcs = pendingEventuallyTasks.get(uuid); } else { - tcs = Task.create(); + tcs = new TaskCompletionSource<>(); pendingEventuallyTasks.put(uuid, tcs); } return tcs.getTask(); @@ -449,7 +449,7 @@ public Task then(Task task) throws Exception { return process(eventuallyPin, operationSet).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (taskQueueSyncLock) { pendingEventuallyTasks.remove(uuid); uuidToOperationSet.remove(uuid); @@ -499,7 +499,7 @@ public Task then(Task task) throws Exception { return executeTask.continueWithTask(new Continuation>() { @Override - public Task then(final Task executeTask) throws Exception { + public Task then(final Task executeTask) { Exception error = executeTask.getError(); if (error != null) { if (error instanceof ParseException @@ -520,7 +520,7 @@ public Task then(final Task executeTask) throws Exceptio // since this EventuallyPin is still in eventuallyPinUUIDQueue. return eventuallyPin.unpinInBackground(EventuallyPin.PIN_NAME).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { JSONObject result = executeTask.getResult(); if (type == EventuallyPin.TYPE_SAVE) { return object.handleSaveEventuallyResultAsync(result, operationSet); @@ -536,7 +536,7 @@ public Task then(Task task) throws Exception { } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return executeTask; } }); @@ -564,13 +564,13 @@ public void clear() { Task task = taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return EventuallyPin.findAllPinned().onSuccessTask(new Continuation, Task>() { @Override - public Task then(Task> task) throws Exception { + public Task then(Task> task) { List pins = task.getResult(); List> tasks = new ArrayList<>(); @@ -609,7 +609,7 @@ private Task whenAll(Collection taskQueues) { for (TaskQueue taskQueue : taskQueues) { Task task = taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return toAwait; } }); diff --git a/parse/src/main/java/com/parse/ParsePlugins.java b/parse/src/main/java/com/parse/ParsePlugins.java index 5f60b788e..1a02703e9 100644 --- a/parse/src/main/java/com/parse/ParsePlugins.java +++ b/parse/src/main/java/com/parse/ParsePlugins.java @@ -20,6 +20,9 @@ import okhttp3.Request; import okhttp3.Response; +/** + * Public for LiveQuery. You probably don't need access + */ public class ParsePlugins { private static final String INSTALLATION_ID_LOCATION = "installationId"; diff --git a/parse/src/main/java/com/parse/ParsePolygon.java b/parse/src/main/java/com/parse/ParsePolygon.java index 508e0ac9a..bbe1a142b 100644 --- a/parse/src/main/java/com/parse/ParsePolygon.java +++ b/parse/src/main/java/com/parse/ParsePolygon.java @@ -35,7 +35,6 @@ * object.save(); * */ - public class ParsePolygon implements Parcelable { public final static Creator CREATOR = new Creator() { diff --git a/parse/src/main/java/com/parse/ParsePush.java b/parse/src/main/java/com/parse/ParsePush.java index 2026967e5..56fb5b6f2 100644 --- a/parse/src/main/java/com/parse/ParsePush.java +++ b/parse/src/main/java/com/parse/ParsePush.java @@ -251,38 +251,6 @@ public void setPushTime(long time) { builder.pushTime(time); } - /** - * Set whether this push notification will go to iOS devices. - *

- * Setting this to {@code true} will set {@link #setPushToAndroid(boolean)} to {@code false}. - *

- * Note: You must set up iOS push certificates before sending pushes to iOS. - * - * @deprecated Please use {@link #setQuery(ParseQuery)} with a {@link ParseQuery} targeting - * {@link ParseInstallation}s with a constraint on the {@code deviceType} field. If you use - * {@code #setPushToIOS(boolean)} or {@link #setPushToAndroid(boolean)}, then you will only be - * able to send to one of these two device types (e.g. and not Windows). - */ - @Deprecated - public void setPushToIOS(boolean pushToIOS) { - builder.pushToIOS(pushToIOS); - } - - /** - * Set whether this push notification will go to Android devices. - *

- * Setting this to {@code true} will set {@link #setPushToIOS(boolean)} to {@code false}. - * - * @deprecated Please use {@link #setQuery(ParseQuery)} with a {@link ParseQuery} targeting - * {@link ParseInstallation}s with a constraint on the {@code deviceType} field. If you use - * {@code #setPushToAndroid(boolean)} or {@link #setPushToIOS(boolean)}, then you will only be - * able to send to one of these two device types (e.g. and not Windows). - */ - @Deprecated - public void setPushToAndroid(boolean pushToAndroid) { - builder.pushToAndroid(pushToAndroid); - } - /** * Sets the entire data of the push message. See the push guide for more details on the data * format. This will overwrite any data specified in {@link #setMessage(String)}. @@ -316,7 +284,7 @@ public Task sendInBackground() { final State state = builder.build(); return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String sessionToken = task.getResult(); return getPushController().sendInBackground(state, sessionToken); } @@ -351,8 +319,6 @@ public void sendInBackground(SendCallback callback) { private final Long expirationTime; private final Long expirationTimeInterval; private final Long pushTime; - private final Boolean pushToIOS; - private final Boolean pushToAndroid; private final JSONObject data; private State(Builder builder) { this.channelSet = builder.channelSet == null ? @@ -361,8 +327,6 @@ private State(Builder builder) { this.expirationTime = builder.expirationTime; this.expirationTimeInterval = builder.expirationTimeInterval; this.pushTime = builder.pushTime; - this.pushToIOS = builder.pushToIOS; - this.pushToAndroid = builder.pushToAndroid; // Since in builder.build() we check data is not null, we do not need to check it again here. JSONObject copyData = null; try { @@ -393,14 +357,6 @@ public Long pushTime() { return pushTime; } - public Boolean pushToIOS() { - return pushToIOS; - } - - public Boolean pushToAndroid() { - return pushToAndroid; - } - public JSONObject data() { // Since in builder.build() we check data is not null, we do not need to check it again here. JSONObject copyData = null; @@ -419,8 +375,6 @@ public JSONObject data() { private Long expirationTime; private Long expirationTimeInterval; private Long pushTime; - private Boolean pushToIOS; - private Boolean pushToAndroid; private JSONObject data; public Builder() { @@ -437,8 +391,6 @@ public Builder(State state) { this.expirationTime = state.expirationTime(); this.expirationTimeInterval = state.expirationTimeInterval(); this.pushTime = state.pushTime(); - this.pushToIOS = state.pushToIOS(); - this.pushToAndroid = state.pushToAndroid(); // Since in state.build() we check data is not null, we do not need to check it again here. JSONObject copyData = null; try { @@ -473,20 +425,6 @@ public Builder pushTime(Long pushTime) { return this; } - public Builder pushToIOS(Boolean pushToIOS) { - checkArgument(query == null, "Cannot set push targets (i.e. setPushToAndroid or " + - "setPushToIOS) when pushing to a query"); - this.pushToIOS = pushToIOS; - return this; - } - - public Builder pushToAndroid(Boolean pushToAndroid) { - checkArgument(query == null, "Cannot set push targets (i.e. setPushToAndroid or " + - "setPushToIOS) when pushing to a query"); - this.pushToAndroid = pushToAndroid; - return this; - } - public Builder data(JSONObject data) { this.data = data; return this; @@ -504,8 +442,6 @@ public Builder channelSet(Collection channelSet) { public Builder query(ParseQuery query) { checkArgument(query != null, "Cannot target a null query"); - checkArgument(pushToIOS == null && pushToAndroid == null, "Cannot set push targets " + - "(i.e. setPushToAndroid or setPushToIOS) when pushing to a query"); checkArgument( query.getClassName().equals( getSubclassingController().getClassName(ParseInstallation.class)), diff --git a/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java b/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java index f4190f464..be14a83a8 100644 --- a/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java +++ b/parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java @@ -76,6 +76,7 @@ * {@link #getActivity(Context, Intent)}. */ // Hack note: Javadoc smashes the last two paragraphs together without the

tags. +@SuppressWarnings("unused") public class ParsePushBroadcastReceiver extends BroadcastReceiver { /** * The name of the Intent extra which contains a channel used to route this notification. @@ -118,16 +119,18 @@ public class ParsePushBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); - switch (intentAction) { - case ACTION_PUSH_RECEIVE: - onPushReceive(context, intent); - break; - case ACTION_PUSH_DELETE: - onPushDismiss(context, intent); - break; - case ACTION_PUSH_OPEN: - onPushOpen(context, intent); - break; + if (intentAction != null) { + switch (intentAction) { + case ACTION_PUSH_RECEIVE: + onPushReceive(context, intent); + break; + case ACTION_PUSH_DELETE: + onPushDismiss(context, intent); + break; + case ACTION_PUSH_OPEN: + onPushOpen(context, intent); + break; + } } } diff --git a/parse/src/main/java/com/parse/ParsePushChannelsController.java b/parse/src/main/java/com/parse/ParsePushChannelsController.java index a54f06d89..fd6738d0f 100644 --- a/parse/src/main/java/com/parse/ParsePushChannelsController.java +++ b/parse/src/main/java/com/parse/ParsePushChannelsController.java @@ -26,7 +26,7 @@ public Task subscribeInBackground(final String channel) { } return getCurrentInstallationController().getAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseInstallation installation = task.getResult(); List channels = installation.getList(ParseInstallation.KEY_CHANNELS); if (channels == null @@ -47,7 +47,7 @@ public Task unsubscribeInBackground(final String channel) { } return getCurrentInstallationController().getAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseInstallation installation = task.getResult(); List channels = installation.getList(ParseInstallation.KEY_CHANNELS); if (channels != null && channels.contains(channel)) { diff --git a/parse/src/main/java/com/parse/ParsePushController.java b/parse/src/main/java/com/parse/ParsePushController.java index 20d9b0713..22c460472 100644 --- a/parse/src/main/java/com/parse/ParsePushController.java +++ b/parse/src/main/java/com/parse/ParsePushController.java @@ -12,8 +12,6 @@ class ParsePushController { - /* package for test */ final static String DEVICE_TYPE_IOS = "ios"; - /* package for test */ final static String DEVICE_TYPE_ANDROID = "android"; private final ParseHttpClient restClient; public ParsePushController(ParseHttpClient restClient) { @@ -24,25 +22,9 @@ public Task sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); } - /* package for test */ ParseRESTCommand buildRESTSendPushCommand(ParsePush.State state, + ParseRESTCommand buildRESTSendPushCommand(ParsePush.State state, String sessionToken) { - // pushToAndroid & pushToIOS are deprecated. It's OK to err on the side of omitting - // a type constraint because the pusher will do a query rewrite on the backend to - // constraint the query to supported device types only. - String deviceType = null; - if (state.queryState() == null) { - // android is on by default, ios is off by default - boolean willPushToAndroid = state.pushToAndroid() != null && state.pushToAndroid(); - boolean willPushToIOS = state.pushToIOS() != null && state.pushToIOS(); - if (willPushToIOS && willPushToAndroid) { - // Push to both by not including a 'type' parameter - } else if (willPushToIOS) { - deviceType = DEVICE_TYPE_IOS; - } else if (willPushToAndroid) { - deviceType = DEVICE_TYPE_ANDROID; - } - } - return ParseRESTPushCommand.sendPushCommand(state.queryState(), state.channelSet(), deviceType, + return ParseRESTPushCommand.sendPushCommand(state.queryState(), state.channelSet(), state.expirationTime(), state.expirationTimeInterval(), state.pushTime(), state.data(), sessionToken); } diff --git a/parse/src/main/java/com/parse/ParseQuery.java b/parse/src/main/java/com/parse/ParseQuery.java index 48a3aab60..7653f22cc 100644 --- a/parse/src/main/java/com/parse/ParseQuery.java +++ b/parse/src/main/java/com/parse/ParseQuery.java @@ -89,8 +89,11 @@ * if your application has already spawned a background task to perform work, that background task * could use the blocking calls and avoid the code complexity of callbacks. */ +@SuppressWarnings("UnusedReturnValue") public class ParseQuery { + public static final int MAX_LIMIT = 1000; + private final State.Builder builder; private ParseUser user; // Just like ParseFile @@ -164,7 +167,7 @@ public static ParseQuery or(List> queri * @param subclass The {@link ParseObject} subclass type to retrieve. * @return A new {@code ParseQuery}. */ - public static ParseQuery getQuery(Class subclass) { + public static ParseQuery getQuery(@NonNull Class subclass) { return new ParseQuery<>(subclass); } @@ -175,20 +178,10 @@ public static ParseQuery getQuery(Class subclass) * @param className The name of the class to retrieve {@link ParseObject}s for. * @return A new {@code ParseQuery}. */ - public static ParseQuery getQuery(String className) { + public static ParseQuery getQuery(@NonNull String className) { return new ParseQuery<>(className); } - /** - * Constructs a query for {@link ParseUser}s. - * - * @deprecated Please use {@link ParseUser#getQuery()} instead. - */ - @Deprecated - public static ParseQuery getUserQuery() { - return ParseUser.getQuery(); - } - private static void throwIfLDSEnabled() { throwIfLDSEnabled(false); } @@ -413,7 +406,7 @@ private Task perform(Callable> runnable, final } return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { tcs.trySetResult(null); // release currentTasks.remove(tcs); return task; @@ -465,10 +458,10 @@ private Task> findAsync(final State state) { final TaskCompletionSource tcs = new TaskCompletionSource<>(); return perform(new Callable>>() { @Override - public Task> call() throws Exception { + public Task> call() { return getUserAsync(state).onSuccessTask(new Continuation>>() { @Override - public Task> then(Task task) throws Exception { + public Task> then(Task task) { final ParseUser user = task.getResult(); return findAsync(state, user, tcs.getTask()); } @@ -532,10 +525,10 @@ private Task getFirstAsync(final State state) { final TaskCompletionSource tcs = new TaskCompletionSource<>(); return perform(new Callable>() { @Override - public Task call() throws Exception { + public Task call() { return getUserAsync(state).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseUser user = task.getResult(); return getFirstAsync(state, user, tcs.getTask()); } @@ -608,10 +601,10 @@ private Task countAsync(final State state) { final TaskCompletionSource tcs = new TaskCompletionSource<>(); return perform(new Callable>() { @Override - public Task call() throws Exception { + public Task call() { return getUserAsync(state).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseUser user = task.getResult(); return countAsync(state, user, tcs.getTask()); } @@ -761,10 +754,10 @@ private Task doCacheThenNetwork( final TaskCompletionSource tcs = new TaskCompletionSource<>(); return perform(new Callable>() { @Override - public Task call() throws Exception { + public Task call() { return getUserAsync(state).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseUser user = task.getResult(); final State cacheState = new State.Builder(state) .setCachePolicy(CachePolicy.CACHE_ONLY) @@ -777,7 +770,7 @@ public Task then(Task task) throws Exception { executionTask = ParseTaskUtils.callbackOnMainThreadAsync(executionTask, callback); return executionTask.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isCancelled()) { return task; } @@ -798,7 +791,7 @@ public Task then(Task task) throws Exception { * @param value The value that the {@link ParseObject} must contain. * @return this, so you can chain this call. */ - public ParseQuery whereEqualTo(String key, Object value) { + public ParseQuery whereEqualTo(@NonNull String key, Object value) { builder.whereEqualTo(key, value); return this; } @@ -880,7 +873,7 @@ public ParseQuery whereGreaterThanOrEqualTo(String key, Object value) { * @param values The values that will match. * @return this, so you can chain this call. */ - public ParseQuery whereContainedIn(String key, Collection values) { + public ParseQuery whereContainedIn(String key, Collection values) { builder.addCondition(key, "$in", values); return this; } @@ -999,7 +992,7 @@ public ParseQuery whereDoesNotMatchKeyInQuery(String key, String keyInQuery, * @param values The values that will not match. * @return this, so you can chain this call. */ - public ParseQuery whereNotContainedIn(String key, Collection values) { + public ParseQuery whereNotContainedIn(String key, Collection values) { builder.addCondition(key, "$nin", values); return this; } @@ -1850,7 +1843,7 @@ public Builder whereText(String key, String value) { } public Builder addCondition(String key, String condition, - Collection value) { + Collection value) { return addConditionInternal(key, condition, Collections.unmodifiableCollection(value)); } diff --git a/parse/src/main/java/com/parse/ParseRESTCommand.java b/parse/src/main/java/com/parse/ParseRESTCommand.java index da3dc0795..7d4df4ca1 100644 --- a/parse/src/main/java/com/parse/ParseRESTCommand.java +++ b/parse/src/main/java/com/parse/ParseRESTCommand.java @@ -388,7 +388,7 @@ public void setLocalId(String localId) { * command's result. If so, change the "create" operation to an "update", and add the objectId to * the command. */ - private void maybeChangeServerOperation() throws JSONException { + private void maybeChangeServerOperation() { if (localId != null) { String objectId = getLocalIdManager().getObjectId(localId); if (objectId != null) { diff --git a/parse/src/main/java/com/parse/ParseRESTFileCommand.java b/parse/src/main/java/com/parse/ParseRESTFileCommand.java index 53d3af39c..02e37ebcd 100644 --- a/parse/src/main/java/com/parse/ParseRESTFileCommand.java +++ b/parse/src/main/java/com/parse/ParseRESTFileCommand.java @@ -8,15 +8,14 @@ */ package com.parse; -/** - * REST network command for creating & uploading {@link ParseFile}s. - */ - import com.parse.http.ParseHttpBody; import com.parse.http.ParseHttpRequest; import java.io.File; +/** + * REST network command for creating & uploading {@link ParseFile}s. + */ class ParseRESTFileCommand extends ParseRESTCommand { private final byte[] data; diff --git a/parse/src/main/java/com/parse/ParseRESTObjectBatchCommand.java b/parse/src/main/java/com/parse/ParseRESTObjectBatchCommand.java index 8fa067b8e..e59f06560 100644 --- a/parse/src/main/java/com/parse/ParseRESTObjectBatchCommand.java +++ b/parse/src/main/java/com/parse/ParseRESTObjectBatchCommand.java @@ -146,7 +146,7 @@ public Void then(Task task) throws Exception { protected Task onResponseAsync(ParseHttpResponse response, ProgressCallback downloadProgressCallback) { InputStream responseStream = null; - String content = null; + String content; try { responseStream = response.getContent(); content = new String(ParseIOUtils.toByteArray(responseStream)); diff --git a/parse/src/main/java/com/parse/ParseRESTPushCommand.java b/parse/src/main/java/com/parse/ParseRESTPushCommand.java index 09c8f798d..a2b7fc442 100644 --- a/parse/src/main/java/com/parse/ParseRESTPushCommand.java +++ b/parse/src/main/java/com/parse/ParseRESTPushCommand.java @@ -35,7 +35,7 @@ public ParseRESTPushCommand( } public static ParseRESTPushCommand sendPushCommand(ParseQuery.State query, - Set targetChannels, String targetDeviceType, Long expirationTime, + Set targetChannels, Long expirationTime, Long expirationInterval, Long pushTime, JSONObject payload, String sessionToken) { JSONObject parameters = new JSONObject(); try { @@ -47,10 +47,6 @@ public static ParseRESTPushCommand sendPushCommand(ParseQuery.State set, ParseEncoder objectEncoder) - throws JSONException { + JSONArray convertSetToArray(Set set, ParseEncoder objectEncoder) { JSONArray array = new JSONArray(); for (ParseObject obj : set) { array.put(objectEncoder.encode(obj)); diff --git a/parse/src/main/java/com/parse/ParseRequest.java b/parse/src/main/java/com/parse/ParseRequest.java index b637c457c..fa1100439 100644 --- a/parse/src/main/java/com/parse/ParseRequest.java +++ b/parse/src/main/java/com/parse/ParseRequest.java @@ -135,7 +135,7 @@ public Task then(Task task) throws Exception { } }, NETWORK_EXECUTOR).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isFaulted()) { Exception error = task.getError(); if (error instanceof IOException) { @@ -212,7 +212,7 @@ private Task executeAsync( } return sendOneRequestAsync(client, request, downloadProgressCallback).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { Exception e = task.getError(); if (task.isFaulted() && e instanceof ParseException) { if (cancellationToken != null && cancellationToken.isCancelled()) { @@ -240,7 +240,7 @@ public void run() { downloadProgressCallback, cancellationToken).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isCancelled()) { retryTask.setCancelled(); } else if (task.isFaulted()) { diff --git a/parse/src/main/java/com/parse/ParseSQLiteCursor.java b/parse/src/main/java/com/parse/ParseSQLiteCursor.java index 528194315..30d727c64 100644 --- a/parse/src/main/java/com/parse/ParseSQLiteCursor.java +++ b/parse/src/main/java/com/parse/ParseSQLiteCursor.java @@ -199,7 +199,7 @@ public void close() { // Basically close _eventually_. Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { cursor.close(); return null; } diff --git a/parse/src/main/java/com/parse/ParseSQLiteDatabase.java b/parse/src/main/java/com/parse/ParseSQLiteDatabase.java index d2f9bf548..76282193d 100644 --- a/parse/src/main/java/com/parse/ParseSQLiteDatabase.java +++ b/parse/src/main/java/com/parse/ParseSQLiteDatabase.java @@ -53,7 +53,7 @@ private ParseSQLiteDatabase(int flags) { taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { synchronized (currentLock) { current = toAwait; } @@ -67,7 +67,7 @@ static Task openDatabaseAsync(final SQLiteOpenHelper helper final ParseSQLiteDatabase db = new ParseSQLiteDatabase(flags); return db.open(helper).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return Task.forResult(db); } }); @@ -77,7 +77,7 @@ public Task isReadOnlyAsync() { synchronized (currentLock) { Task task = current.continueWith(new Continuation() { @Override - public Boolean then(Task task) throws Exception { + public Boolean then(Task task) { return db.isReadOnly(); } }); @@ -90,7 +90,7 @@ public Task isOpenAsync() { synchronized (currentLock) { Task task = current.continueWith(new Continuation() { @Override - public Boolean then(Task task) throws Exception { + public Boolean then(Task task) { return db.isOpen(); } }); @@ -107,7 +107,7 @@ public boolean inTransaction() { synchronized (currentLock) { current = current.continueWith(new Continuation() { @Override - public SQLiteDatabase then(Task task) throws Exception { + public SQLiteDatabase then(Task task) { // get*Database() is synchronous and calls through SQLiteOpenHelper#onCreate, onUpdate, // etc. return (openFlags & SQLiteDatabase.OPEN_READONLY) == SQLiteDatabase.OPEN_READONLY @@ -116,7 +116,7 @@ public SQLiteDatabase then(Task task) throws Exception { } }, dbExecutor).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db = task.getResult(); return task.makeVoid(); } @@ -134,14 +134,14 @@ public Task beginTransactionAsync() { synchronized (currentLock) { current = current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.beginTransaction(); return task; } }, dbExecutor); return current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -158,14 +158,14 @@ public Task setTransactionSuccessfulAsync() { synchronized (currentLock) { current = current.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { db.setTransactionSuccessful(); return task; } }, dbExecutor); return current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -182,7 +182,7 @@ public Task endTransactionAsync() { synchronized (currentLock) { current = current.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { db.endTransaction(); // We want to swallow any exceptions from our Session task return null; @@ -190,7 +190,7 @@ public Void then(Task task) throws Exception { }, dbExecutor); return current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -206,7 +206,7 @@ public Task closeAsync() { synchronized (currentLock) { current = current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { try { db.close(); } finally { @@ -217,7 +217,7 @@ public Task then(Task task) throws Exception { }, dbExecutor); return current.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -235,12 +235,12 @@ public Task queryAsync(final String table, final String[] select, final synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Cursor then(Task task) throws Exception { + public Cursor then(Task task) { return db.query(table, select, where, args, null, null, null); } }, dbExecutor).onSuccess(new Continuation() { @Override - public Cursor then(Task task) throws Exception { + public Cursor then(Task task) { Cursor cursor = ParseSQLiteCursor.create(task.getResult(), dbExecutor); /* Ensure the cursor window is filled on the dbExecutor thread. We need to do this because * the cursor cannot be filled from a different thread than it was created on. @@ -252,7 +252,7 @@ public Cursor then(Task task) throws Exception { current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -270,14 +270,14 @@ public Task insertWithOnConflict(final String table, final ContentValues v synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Long then(Task task) throws Exception { + public Long then(Task task) { return db.insertWithOnConflict(table, null, values, conflictAlgorithm); } }, dbExecutor); current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -294,14 +294,14 @@ public Task insertOrThrowAsync(final String table, final ContentValues val synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Long then(Task task) throws Exception { + public Long then(Task task) { return db.insertOrThrow(table, null, values); } }, dbExecutor); current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -319,14 +319,14 @@ public Task updateAsync(final String table, final ContentValues values, synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Integer then(Task task) throws Exception { + public Integer then(Task task) { return db.update(table, values, where, args); } }, dbExecutor); current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -343,14 +343,14 @@ public Task deleteAsync(final String table, final String where, final Stri synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Integer then(Task task) throws Exception { + public Integer then(Task task) { return db.delete(table, where, args); } }, dbExecutor); current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } @@ -367,12 +367,12 @@ public Task rawQueryAsync(final String sql, final String[] args) { synchronized (currentLock) { Task task = current.onSuccess(new Continuation() { @Override - public Cursor then(Task task) throws Exception { + public Cursor then(Task task) { return db.rawQuery(sql, args); } }, dbExecutor).onSuccess(new Continuation() { @Override - public Cursor then(Task task) throws Exception { + public Cursor then(Task task) { Cursor cursor = ParseSQLiteCursor.create(task.getResult(), dbExecutor); // Ensure the cursor window is filled on the dbExecutor thread. We need to do this because // the cursor cannot be filled from a different thread than it was created on. @@ -383,7 +383,7 @@ public Cursor then(Task task) throws Exception { current = task.makeVoid(); return task.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { // We want to jump off the dbExecutor return task; } diff --git a/parse/src/main/java/com/parse/ParseSession.java b/parse/src/main/java/com/parse/ParseSession.java index aa0114d4e..307f352a1 100644 --- a/parse/src/main/java/com/parse/ParseSession.java +++ b/parse/src/main/java/com/parse/ParseSession.java @@ -46,14 +46,14 @@ private static ParseSessionController getSessionController() { public static Task getCurrentSessionInBackground() { return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String sessionToken = task.getResult(); if (sessionToken == null) { return Task.forResult(null); } return getSessionController().getSessionAsync(sessionToken).onSuccess(new Continuation() { @Override - public ParseSession then(Task task) throws Exception { + public ParseSession then(Task task) { ParseObject.State result = task.getResult(); return ParseObject.from(result); } @@ -88,7 +88,7 @@ static Task upgradeToRevocableSessionAsync(String sessionToken) { return getSessionController().upgradeToRevocable(sessionToken).onSuccess(new Continuation() { @Override - public String then(Task task) throws Exception { + public String then(Task task) { ParseObject.State result = task.getResult(); return ParseObject.from(result).getSessionToken(); } diff --git a/parse/src/main/java/com/parse/ParseSetOperation.java b/parse/src/main/java/com/parse/ParseSetOperation.java index e75039f62..a502a1d3b 100644 --- a/parse/src/main/java/com/parse/ParseSetOperation.java +++ b/parse/src/main/java/com/parse/ParseSetOperation.java @@ -8,12 +8,11 @@ */ package com.parse; +import android.os.Parcel; + /** * An operation where a field is set to a given value regardless of its previous value. */ - -import android.os.Parcel; - class ParseSetOperation implements ParseFieldOperation { /* package */ final static String OP_NAME = "Set"; diff --git a/parse/src/main/java/com/parse/ParseTaskUtils.java b/parse/src/main/java/com/parse/ParseTaskUtils.java index 98aee1d81..068066687 100644 --- a/parse/src/main/java/com/parse/ParseTaskUtils.java +++ b/parse/src/main/java/com/parse/ParseTaskUtils.java @@ -105,7 +105,7 @@ static Task callbackOnMainThreadAsync(Task task, final TaskCompletionSource tcs = new TaskCompletionSource(); task.continueWith(new Continuation() { @Override - public Void then(final Task task) throws Exception { + public Void then(final Task task) { if (task.isCancelled() && !reportCancellation) { tcs.setCancelled(); return null; diff --git a/parse/src/main/java/com/parse/ParseUser.java b/parse/src/main/java/com/parse/ParseUser.java index d6987777a..4d55b13d9 100644 --- a/parse/src/main/java/com/parse/ParseUser.java +++ b/parse/src/main/java/com/parse/ParseUser.java @@ -30,6 +30,7 @@ * The {@code ParseUser} is a local representation of user data that can be saved and retrieved from * the Parse cloud. */ +@SuppressWarnings("unused") @ParseClassName("_User") public class ParseUser extends ParseObject { @@ -101,12 +102,12 @@ public static Task logInInBackground(String username, String password return getUserController().logInAsync(username, password).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { State result = task.getResult(); final ParseUser newCurrent = ParseObject.from(result); return saveCurrentUserAsync(newCurrent).onSuccess(new Continuation() { @Override - public ParseUser then(Task task) throws Exception { + public ParseUser then(Task task) { return newCurrent; } }); @@ -163,13 +164,13 @@ public static Task becomeInBackground(String sessionToken) { return getUserController().getUserAsync(sessionToken).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { State result = task.getResult(); final ParseUser user = ParseObject.from(result); return saveCurrentUserAsync(user).onSuccess(new Continuation() { @Override - public ParseUser then(Task task) throws Exception { + public ParseUser then(Task task) { return user; } }); @@ -391,15 +392,15 @@ public static Task logInWithInBackground( final Continuation> logInWithTask = new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getUserController().logInAsync(authType, authData).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser.State result = task.getResult(); final ParseUser user = ParseObject.from(result); return saveCurrentUserAsync(user).onSuccess(new Continuation() { @Override - public ParseUser then(Task task) throws Exception { + public ParseUser then(Task task) { return user; } }); @@ -411,7 +412,7 @@ public ParseUser then(Task task) throws Exception { // Handle claiming of user. return getCurrentUserController().getAsync(false).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseUser user = task.getResult(); if (user != null) { synchronized (user.mutex) { @@ -421,10 +422,10 @@ public Task then(Task task) throws Exception { user.getAuthData(ParseAnonymousUtils.AUTH_TYPE); return user.taskQueue.enqueue(new Continuation>() { @Override - public Task then(final Task toAwait) throws Exception { + public Task then(final Task toAwait) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (user.mutex) { // Replace any anonymity with the new linked authData. user.stripAnonymity(); @@ -435,7 +436,7 @@ public Task then(Task task) throws Exception { } }).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (user.mutex) { if (task.isFaulted()) { user.removeAuthData(authType); @@ -458,7 +459,7 @@ public Task then(Task task) throws Exception { return user.linkWithInBackground(authType, authData) .continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isFaulted()) { Exception error = task.getError(); if (error instanceof ParseException @@ -530,7 +531,7 @@ public static Task enableRevocableSessionInBackground() { return getCurrentUserController().getAsync(false).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser user = task.getResult(); if (user == null) { return Task.forResult(null); @@ -606,7 +607,7 @@ public boolean isAuthenticated() { } @Override - public void remove(String key) { + public void remove(@NonNull String key) { if (KEY_USERNAME.equals(key)) { throw new IllegalArgumentException("Can't remove the username key."); } @@ -876,12 +877,12 @@ private void restoreAnonymity(Map anonymousData) { // If the user is the currently logged in user, we persist all data to disk return task.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return cleanUpAuthDataAsync(); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return saveCurrentUserAsync(ParseUser.this); } }); @@ -921,17 +922,17 @@ public ParseUser fetch() throws ParseException { if (isCurrentUser()) { return task.onSuccessTask(new Continuation>() { @Override - public Task then(final Task fetchAsyncTask) throws Exception { + public Task then(final Task fetchAsyncTask) { return cleanUpAuthDataAsync(); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return saveCurrentUserAsync(ParseUser.this); } }).onSuccess(new Continuation() { @Override - public T then(Task task) throws Exception { + public T then(Task task) { return (T) ParseUser.this; } }); @@ -957,7 +958,7 @@ public T then(Task task) throws Exception { public Task signUpInBackground() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return signUpAsync(task); } }); @@ -1021,7 +1022,7 @@ public Task then(Task task) throws Exception { return user.saveAsync(sessionToken, isLazy, toAwait).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (task.isCancelled() || task.isFaulted()) { // Error synchronized (user.mutex) { if (oldUsername != null) { @@ -1052,17 +1053,17 @@ public Task then(Task task) throws Exception { return toAwait.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getUserController().signUpAsync( getState(), operations, sessionToken ).continueWithTask(new Continuation>() { @Override - public Task then(final Task signUpTask) throws Exception { + public Task then(final Task signUpTask) { ParseUser.State result = signUpTask.getResult(); return handleSaveResultAsync(result, operations).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (!signUpTask.isCancelled() && !signUpTask.isFaulted()) { return saveCurrentUserAsync(ParseUser.this); } @@ -1198,7 +1199,7 @@ private Task synchronizeAuthDataAsync( ParseAuthenticationManager manager, final String authType, Map authData) { return manager.restoreAuthenticationAsync(authType, authData).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { boolean success = !task.isFaulted() && task.getResult(); if (!success) { return unlinkFromInBackground(authType); @@ -1222,7 +1223,7 @@ private Task linkWithAsync( return saveAsync(sessionToken, isLazy, toAwait).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { synchronized (mutex) { if (task.isFaulted() || task.isCancelled()) { removeAuthData(authType); @@ -1244,7 +1245,7 @@ private Task linkWithAsync( final String sessionToken) { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return linkWithAsync(authType, authData, task, sessionToken); } }); @@ -1317,10 +1318,10 @@ public Task unlinkFromInBackground(final String authType) { // Otherwise, treat this as a SignUpOrLogIn return toAwait.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return getUserController().logInAsync(getState(), operations).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { final ParseUser.State result = task.getResult(); Task resultTask; @@ -1332,14 +1333,14 @@ public Task then(Task task) throws Exception { resultTask = handleSaveResultAsync(result, operations).onSuccess(new Continuation() { @Override - public ParseUser.State then(Task task) throws Exception { + public ParseUser.State then(Task task) { return result; } }); } return resultTask.onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { ParseUser.State result = task.getResult(); if (!result.isNew()) { // If the result is not a new user, treat this as a fresh logIn with complete @@ -1392,7 +1393,7 @@ protected void onRestoreInstanceState(Bundle savedState) { /* package */ Task upgradeToRevocableSessionAsync() { return taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task toAwait) throws Exception { + public Task then(Task toAwait) { return upgradeToRevocableSessionAsync(toAwait); } }); @@ -1402,12 +1403,12 @@ private Task upgradeToRevocableSessionAsync(Task toAwait) { final String sessionToken = getSessionToken(); return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return ParseSession.upgradeToRevocableSessionAsync(sessionToken); } }).onSuccessTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { String result = task.getResult(); return setSessionTokenInBackground(result); } diff --git a/parse/src/main/java/com/parse/ParseWakeLock.java b/parse/src/main/java/com/parse/ParseWakeLock.java deleted file mode 100644 index 721e77e09..000000000 --- a/parse/src/main/java/com/parse/ParseWakeLock.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015-present, Parse, LLC. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -package com.parse; - -import android.content.Context; -import android.os.PowerManager; - -/** - * Utility class that wraps a PowerManager.WakeLock and logs an error if the app doesn't have - * permissions to acquire wake locks. - */ -class ParseWakeLock { - private static final String TAG = "com.parse.ParseWakeLock"; - - private static volatile boolean hasWakeLockPermission = true; - private final PowerManager.WakeLock wakeLock; - - private ParseWakeLock(PowerManager.WakeLock wakeLock) { - this.wakeLock = wakeLock; - } - - public static ParseWakeLock acquireNewWakeLock(Context context, int type, String reason, long timeout) { - PowerManager.WakeLock wl = null; - - if (hasWakeLockPermission) { - try { - PowerManager pm = (PowerManager) context.getApplicationContext().getSystemService(Context.POWER_SERVICE); - - if (pm != null) { - wl = pm.newWakeLock(type, reason); - - if (wl != null) { - wl.setReferenceCounted(false); - - if (timeout == 0) { - wl.acquire(); - } else { - wl.acquire(timeout); - } - } - } - } catch (SecurityException e) { - PLog.e(TAG, "Failed to acquire a PowerManager.WakeLock. This is" + - "necessary for reliable handling of pushes. Please add this to your Manifest.xml: " + - " "); - - hasWakeLockPermission = false; - wl = null; - } - } - - return new ParseWakeLock(wl); - } - - public void release() { - if (wakeLock != null) { - wakeLock.release(); - } - } -} diff --git a/parse/src/main/java/com/parse/PushHistory.java b/parse/src/main/java/com/parse/PushHistory.java index 5b3819e14..e7da8e707 100644 --- a/parse/src/main/java/com/parse/PushHistory.java +++ b/parse/src/main/java/com/parse/PushHistory.java @@ -8,6 +8,8 @@ */ package com.parse; +import android.support.annotation.NonNull; + import org.json.JSONException; import org.json.JSONObject; @@ -138,7 +140,7 @@ public Entry(String pushId, String timestamp) { } @Override - public int compareTo(Entry other) { + public int compareTo(@NonNull Entry other) { return timestamp.compareTo(other.timestamp); } } diff --git a/parse/src/main/java/com/parse/RefreshCallback.java b/parse/src/main/java/com/parse/RefreshCallback.java deleted file mode 100644 index f7b0fa80e..000000000 --- a/parse/src/main/java/com/parse/RefreshCallback.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015-present, Parse, LLC. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ -package com.parse; - -/** - * A {@code RefreshCallback} is used to run code after refresh is used to update a {@link ParseObject} in a - * background thread. - *

- * The easiest way to use a {@code RefreshCallback} is through an anonymous inner class. Override - * the {@code done} function to specify what the callback should do after the refresh is complete. - * The {@code done} function will be run in the UI thread, while the refresh happens in a - * background thread. This ensures that the UI does not freeze while the refresh happens. - *

- * For example, this sample code refreshes an object of class {@code "MyClass"} and id - * {@code myId}. It calls a different function depending on whether the refresh succeeded or - * not. - *

- *

- * object.refreshInBackground(new RefreshCallback() {
- *   public void done(ParseObject object, ParseException e) {
- *     if (e == null) {
- *       objectWasRefreshedSuccessfully(object);
- *     } else {
- *       objectRefreshFailed();
- *     }
- *   }
- * });
- * 
- */ -public interface RefreshCallback extends ParseCallback2 { - /** - * Override this function with the code you want to run after the save is complete. - * - * @param object The object that was refreshed, or {@code null} if it did not succeed. - * @param e The exception raised by the login, or {@code null} if it succeeded. - */ - @Override - void done(ParseObject object, ParseException e); -} diff --git a/parse/src/main/java/com/parse/TaskQueue.java b/parse/src/main/java/com/parse/TaskQueue.java index 7260c1df5..df127ab41 100644 --- a/parse/src/main/java/com/parse/TaskQueue.java +++ b/parse/src/main/java/com/parse/TaskQueue.java @@ -33,10 +33,10 @@ class TaskQueue { static Continuation> waitFor(final Task toAwait) { return new Continuation>() { @Override - public Task then(final Task task) throws Exception { + public Task then(final Task task) { return toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task ignored) throws Exception { + public Task then(Task ignored) { return task; } }); @@ -56,7 +56,7 @@ private Task getTaskToAwait() { Task toAwait = tail != null ? tail : Task.forResult(null); return toAwait.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { return null; } }); diff --git a/parse/src/test/java/com/parse/CachedCurrentInstallationControllerTest.java b/parse/src/test/java/com/parse/CachedCurrentInstallationControllerTest.java index 1f623f5d4..bee718324 100644 --- a/parse/src/test/java/com/parse/CachedCurrentInstallationControllerTest.java +++ b/parse/src/test/java/com/parse/CachedCurrentInstallationControllerTest.java @@ -205,7 +205,7 @@ public void testExistAsyncFromStore() throws Exception { //endregion @Test - public void testClearFromMemory() throws Exception { + public void testClearFromMemory() { CachedCurrentInstallationController controller = new CachedCurrentInstallationController(null, null); controller.currentInstallation = mock(ParseInstallation.class); @@ -216,7 +216,7 @@ public void testClearFromMemory() throws Exception { } @Test - public void testClearFromDisk() throws Exception { + public void testClearFromDisk() { // Mock installationId InstallationId installationId = mock(InstallationId.class); //noinspection unchecked @@ -237,7 +237,7 @@ public void testClearFromDisk() throws Exception { } @Test - public void testIsCurrent() throws Exception { + public void testIsCurrent() { // Create test controller CachedCurrentInstallationController controller = new CachedCurrentInstallationController(null, null); diff --git a/parse/src/test/java/com/parse/CachedCurrentUserControllerTest.java b/parse/src/test/java/com/parse/CachedCurrentUserControllerTest.java index a4756c7d0..8bd37eb91 100644 --- a/parse/src/test/java/com/parse/CachedCurrentUserControllerTest.java +++ b/parse/src/test/java/com/parse/CachedCurrentUserControllerTest.java @@ -329,7 +329,7 @@ public void testLogOutAsyncWithDeleteInDiskCurrentUserFailure() throws Exception //region testLazyLogin @Test - public void testLazyLogin() throws Exception { + public void testLazyLogin() { CachedCurrentUserController controller = new CachedCurrentUserController(null); @@ -390,7 +390,7 @@ public void testGetCurrentSessionTokenAsyncWithNoCurrentUserSet() throws Excepti //region testClearFromMemory @Test - public void testClearFromMemory() throws Exception { + public void testClearFromMemory() { CachedCurrentUserController controller = new CachedCurrentUserController(null); controller.currentUser = mock(ParseUser.class); @@ -406,7 +406,7 @@ public void testClearFromMemory() throws Exception { //region testClearFromDisk() @Test - public void testClearFromDisk() throws Exception { + public void testClearFromDisk() { ParseObjectStore store = (ParseObjectStore) mock(ParseObjectStore.class); when(store.deleteAsync()).thenReturn(Task.forResult(null)); @@ -465,7 +465,7 @@ public void testExistsAsyncWithNoInMemoryAndInDiskCurrentUserSet() throws Except //region testIsCurrent @Test - public void testIsCurrent() throws Exception { + public void testIsCurrent() { CachedCurrentUserController controller = new CachedCurrentUserController(null); ParseUser currentUser = new ParseUser(); diff --git a/parse/src/test/java/com/parse/EventuallyPinTest.java b/parse/src/test/java/com/parse/EventuallyPinTest.java index 8f6b4db6c..dcfaec909 100644 --- a/parse/src/test/java/com/parse/EventuallyPinTest.java +++ b/parse/src/test/java/com/parse/EventuallyPinTest.java @@ -26,13 +26,13 @@ public class EventuallyPinTest { public ExpectedException thrown = ExpectedException.none(); @Before - public void setUp() throws Exception { + public void setUp() { ParseObject.registerSubclass(EventuallyPin.class); ParseObject.registerSubclass(ParsePin.class); } @After - public void tearDown() throws Exception { + public void tearDown() { ParseObject.unregisterSubclass(EventuallyPin.class); ParseObject.unregisterSubclass(ParsePin.class); Parse.setLocalDatastore(null); diff --git a/parse/src/test/java/com/parse/ListsTest.java b/parse/src/test/java/com/parse/ListsTest.java index ee402c35a..b32bd301e 100644 --- a/parse/src/test/java/com/parse/ListsTest.java +++ b/parse/src/test/java/com/parse/ListsTest.java @@ -18,7 +18,7 @@ public class ListsTest { @Test - public void testPartition() throws Exception { + public void testPartition() { List list = new ArrayList<>(); for (int i = 0; i < 99; i++) { list.add(i); diff --git a/parse/src/test/java/com/parse/OfflineQueryLogicTest.java b/parse/src/test/java/com/parse/OfflineQueryLogicTest.java index 44f93a6bb..c249ffc5e 100644 --- a/parse/src/test/java/com/parse/OfflineQueryLogicTest.java +++ b/parse/src/test/java/com/parse/OfflineQueryLogicTest.java @@ -316,7 +316,7 @@ public void testMatchesEqualsWithGeoPoint() throws Exception { @Test public void testMatchesEqualsWithPolygon() throws Exception { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); @@ -334,7 +334,7 @@ public void testMatchesEqualsWithPolygon() throws Exception { .build(); assertTrue(matches(logic, query, object)); - List diff = new ArrayList(); + List diff = new ArrayList<>(); diff.add(new ParseGeoPoint(0, 0)); diff.add(new ParseGeoPoint(0, 10)); diff.add(new ParseGeoPoint(10, 10)); @@ -689,7 +689,7 @@ public void testMatchesWithin() throws ParseException { @Test public void testMatchesGeoIntersects() throws ParseException { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); @@ -726,13 +726,13 @@ public void testMatchesGeoIntersects() throws ParseException { @Test public void testMatchesGeoWithin() throws ParseException { - List smallBox = new ArrayList(); + List smallBox = new ArrayList<>(); smallBox.add(new ParseGeoPoint(0, 0)); smallBox.add(new ParseGeoPoint(0, 1)); smallBox.add(new ParseGeoPoint(1, 1)); smallBox.add(new ParseGeoPoint(1, 0)); - List largeBox = new ArrayList(); + List largeBox = new ArrayList<>(); largeBox.add(new ParseGeoPoint(0, 0)); largeBox.add(new ParseGeoPoint(0, 10)); largeBox.add(new ParseGeoPoint(10, 10)); diff --git a/parse/src/test/java/com/parse/ParseACLTest.java b/parse/src/test/java/com/parse/ParseACLTest.java index 7a4aad0e0..8e000c1ee 100644 --- a/parse/src/test/java/com/parse/ParseACLTest.java +++ b/parse/src/test/java/com/parse/ParseACLTest.java @@ -64,7 +64,7 @@ public void tearDown() { } @Test - public void testConstructor() throws Exception { + public void testConstructor() { ParseACL acl = new ParseACL(); assertEquals(0, acl.getPermissionsById().size()); @@ -75,7 +75,7 @@ public void testConstructor() throws Exception { //region testCopy @Test - public void testConstructorWithUser() throws Exception { + public void testConstructorWithUser() { ParseUser user = new ParseUser(); user.setObjectId("test"); ParseACL acl = new ParseACL(user); @@ -85,7 +85,7 @@ public void testConstructorWithUser() throws Exception { } @Test - public void testCopy() throws Exception { + public void testCopy() { ParseACL acl = new ParseACL(); final ParseUser unresolvedUser = mock(ParseUser.class); when(unresolvedUser.isLazy()).thenReturn(true); @@ -112,7 +112,7 @@ public void testCopy() throws Exception { //region toJson @Test - public void testCopyWithSaveListener() throws Exception { + public void testCopyWithSaveListener() { ParseACL acl = new ParseACL(); final ParseUser unresolvedUser = mock(ParseUser.class); when(unresolvedUser.isLazy()).thenReturn(true); @@ -173,7 +173,7 @@ public void testToJson() throws Exception { } @Test - public void testParcelable() throws Exception { + public void testParcelable() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", true); ParseUser user = new ParseUser(); @@ -200,7 +200,7 @@ public void testParcelable() throws Exception { //region testCreateACLFromJSONObject @Test - public void testParcelableWithUnresolvedUser() throws Exception { + public void testParcelableWithUnresolvedUser() { ParseFieldOperations.registerDefaultDecoders(); // Needed for unparceling ParseObjects ParseACL acl = new ParseACL(); ParseUser unresolved = new ParseUser(); @@ -245,7 +245,7 @@ public void testCreateACLFromJSONObject() throws Exception { } @Test - public void testResolveUserWithNewUser() throws Exception { + public void testResolveUserWithNewUser() { ParseUser unresolvedUser = new ParseUser(); setLazy(unresolvedUser); ParseACL acl = new ParseACL(); @@ -266,7 +266,7 @@ public void testResolveUserWithNewUser() throws Exception { //region testSetAccess @Test - public void testResolveUserWithUnresolvedUser() throws Exception { + public void testResolveUserWithUnresolvedUser() { ParseACL acl = new ParseACL(); ParseUser unresolvedUser = new ParseUser(); setLazy(unresolvedUser); @@ -285,7 +285,7 @@ public void testResolveUserWithUnresolvedUser() throws Exception { } @Test - public void testSetAccessWithNoPermissionAndNotAllowed() throws Exception { + public void testSetAccessWithNoPermissionAndNotAllowed() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", false); @@ -295,7 +295,7 @@ public void testSetAccessWithNoPermissionAndNotAllowed() throws Exception { } @Test - public void testSetAccessWithAllowed() throws Exception { + public void testSetAccessWithAllowed() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", true); @@ -305,7 +305,7 @@ public void testSetAccessWithAllowed() throws Exception { } @Test - public void testSetAccessWithPermissionsAndNotAllowed() throws Exception { + public void testSetAccessWithPermissionsAndNotAllowed() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", true); @@ -317,7 +317,7 @@ public void testSetAccessWithPermissionsAndNotAllowed() throws Exception { } @Test - public void testSetPublicReadAccessAllowed() throws Exception { + public void testSetPublicReadAccessAllowed() { ParseACL acl = new ParseACL(); acl.setPublicReadAccess(true); @@ -326,7 +326,7 @@ public void testSetPublicReadAccessAllowed() throws Exception { } @Test - public void testSetPublicReadAccessNotAllowed() throws Exception { + public void testSetPublicReadAccessNotAllowed() { ParseACL acl = new ParseACL(); acl.setPublicReadAccess(false); @@ -336,7 +336,7 @@ public void testSetPublicReadAccessNotAllowed() throws Exception { } @Test - public void testSetPublicWriteAccessAllowed() throws Exception { + public void testSetPublicWriteAccessAllowed() { ParseACL acl = new ParseACL(); acl.setPublicWriteAccess(true); @@ -346,7 +346,7 @@ public void testSetPublicWriteAccessAllowed() throws Exception { } @Test - public void testSetPublicWriteAccessNotAllowed() throws Exception { + public void testSetPublicWriteAccessNotAllowed() { ParseACL acl = new ParseACL(); acl.setPublicWriteAccess(false); @@ -356,7 +356,7 @@ public void testSetPublicWriteAccessNotAllowed() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetReadAccessWithNullUserId() throws Exception { + public void testSetReadAccessWithNullUserId() { ParseACL acl = new ParseACL(); String userId = null; @@ -364,7 +364,7 @@ public void testSetReadAccessWithNullUserId() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetWriteAccessWithNullUserId() throws Exception { + public void testSetWriteAccessWithNullUserId() { ParseACL acl = new ParseACL(); String userId = null; @@ -372,7 +372,7 @@ public void testSetWriteAccessWithNullUserId() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetRoleReadAccessWithInvalidRole() throws Exception { + public void testSetRoleReadAccessWithInvalidRole() { ParseRole role = new ParseRole(); role.setName("Player"); ParseACL acl = new ParseACL(); @@ -381,7 +381,7 @@ public void testSetRoleReadAccessWithInvalidRole() throws Exception { } @Test - public void testSetRoleReadAccess() throws Exception { + public void testSetRoleReadAccess() { ParseRole role = new ParseRole(); role.setName("Player"); role.setObjectId("test"); @@ -394,7 +394,7 @@ public void testSetRoleReadAccess() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetRoleWriteAccessWithInvalidRole() throws Exception { + public void testSetRoleWriteAccessWithInvalidRole() { ParseRole role = new ParseRole(); role.setName("Player"); ParseACL acl = new ParseACL(); @@ -403,7 +403,7 @@ public void testSetRoleWriteAccessWithInvalidRole() throws Exception { } @Test - public void testSetRoleWriteAccess() throws Exception { + public void testSetRoleWriteAccess() { ParseRole role = new ParseRole(); role.setName("Player"); role.setObjectId("test"); @@ -416,7 +416,7 @@ public void testSetRoleWriteAccess() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetUserReadAccessWithNotSavedNotLazyUser() throws Exception { + public void testSetUserReadAccessWithNotSavedNotLazyUser() { ParseUser user = new ParseUser(); ParseACL acl = new ParseACL(); @@ -424,7 +424,7 @@ public void testSetUserReadAccessWithNotSavedNotLazyUser() throws Exception { } @Test - public void testSetUserReadAccessWithLazyUser() throws Exception { + public void testSetUserReadAccessWithLazyUser() { ParseUser unresolvedUser = mock(ParseUser.class); when(unresolvedUser.isLazy()).thenReturn(true); ParseACL acl = new ParseACL(); @@ -439,7 +439,7 @@ public void testSetUserReadAccessWithLazyUser() throws Exception { } @Test - public void testSetUserReadAccessWithNormalUser() throws Exception { + public void testSetUserReadAccessWithNormalUser() { ParseUser user = new ParseUser(); user.setObjectId("test"); ParseACL acl = new ParseACL(); @@ -451,7 +451,7 @@ public void testSetUserReadAccessWithNormalUser() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testSetUserWriteAccessWithNotSavedNotLazyUser() throws Exception { + public void testSetUserWriteAccessWithNotSavedNotLazyUser() { ParseUser user = new ParseUser(); ParseACL acl = new ParseACL(); @@ -459,7 +459,7 @@ public void testSetUserWriteAccessWithNotSavedNotLazyUser() throws Exception { } @Test - public void testSetUserWriteAccessWithLazyUser() throws Exception { + public void testSetUserWriteAccessWithLazyUser() { ParseUser user = mock(ParseUser.class); when(user.isLazy()).thenReturn(true); ParseACL acl = new ParseACL(); @@ -477,7 +477,7 @@ public void testSetUserWriteAccessWithLazyUser() throws Exception { //region testGetAccess @Test - public void testSetUserWriteAccessWithNormalUser() throws Exception { + public void testSetUserWriteAccessWithNormalUser() { ParseUser user = new ParseUser(); user.setObjectId("test"); ParseACL acl = new ParseACL(); @@ -489,14 +489,14 @@ public void testSetUserWriteAccessWithNormalUser() throws Exception { } @Test - public void testGetAccessWithNoPermission() throws Exception { + public void testGetAccessWithNoPermission() { ParseACL acl = new ParseACL(); assertFalse(acl.getReadAccess("userId")); } @Test - public void testGetAccessWithNoAccessType() throws Exception { + public void testGetAccessWithNoAccessType() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", true); @@ -504,7 +504,7 @@ public void testGetAccessWithNoAccessType() throws Exception { } @Test - public void testGetAccessWithPermission() throws Exception { + public void testGetAccessWithPermission() { ParseACL acl = new ParseACL(); acl.setReadAccess("userId", true); @@ -512,7 +512,7 @@ public void testGetAccessWithPermission() throws Exception { } @Test - public void testGetPublicReadAccess() throws Exception { + public void testGetPublicReadAccess() { ParseACL acl = new ParseACL(); acl.setPublicWriteAccess(true); @@ -520,7 +520,7 @@ public void testGetPublicReadAccess() throws Exception { } @Test - public void testGetPublicWriteAccess() throws Exception { + public void testGetPublicWriteAccess() { ParseACL acl = new ParseACL(); acl.setPublicWriteAccess(true); @@ -528,7 +528,7 @@ public void testGetPublicWriteAccess() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetReadAccessWithNullUserId() throws Exception { + public void testGetReadAccessWithNullUserId() { ParseACL acl = new ParseACL(); String userId = null; @@ -536,7 +536,7 @@ public void testGetReadAccessWithNullUserId() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetWriteAccessWithNullUserId() throws Exception { + public void testGetWriteAccessWithNullUserId() { ParseACL acl = new ParseACL(); String userId = null; @@ -544,7 +544,7 @@ public void testGetWriteAccessWithNullUserId() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetRoleReadAccessWithInvalidRole() throws Exception { + public void testGetRoleReadAccessWithInvalidRole() { ParseACL acl = new ParseACL(); ParseRole role = new ParseRole(); role.setName("Player"); @@ -553,7 +553,7 @@ public void testGetRoleReadAccessWithInvalidRole() throws Exception { } @Test - public void testGetRoleReadAccess() throws Exception { + public void testGetRoleReadAccess() { ParseACL acl = new ParseACL(); ParseRole role = new ParseRole(); role.setName("Player"); @@ -564,7 +564,7 @@ public void testGetRoleReadAccess() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetRoleWriteAccessWithInvalidRole() throws Exception { + public void testGetRoleWriteAccessWithInvalidRole() { ParseACL acl = new ParseACL(); ParseRole role = new ParseRole(); role.setName("Player"); @@ -573,7 +573,7 @@ public void testGetRoleWriteAccessWithInvalidRole() throws Exception { } @Test - public void testGetRoleWriteAccess() throws Exception { + public void testGetRoleWriteAccess() { ParseACL acl = new ParseACL(); ParseRole role = new ParseRole(); role.setName("Player"); @@ -584,7 +584,7 @@ public void testGetRoleWriteAccess() throws Exception { } @Test - public void testGetUserReadAccessWithUnresolvedUser() throws Exception { + public void testGetUserReadAccessWithUnresolvedUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); setLazy(user); @@ -595,7 +595,7 @@ public void testGetUserReadAccessWithUnresolvedUser() throws Exception { } @Test - public void testGetUserReadAccessWithLazyUser() throws Exception { + public void testGetUserReadAccessWithLazyUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); setLazy(user); @@ -604,7 +604,7 @@ public void testGetUserReadAccessWithLazyUser() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetUserReadAccessWithNotSavedUser() throws Exception { + public void testGetUserReadAccessWithNotSavedUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); @@ -612,7 +612,7 @@ public void testGetUserReadAccessWithNotSavedUser() throws Exception { } @Test - public void testGetUserReadAccessWithNormalUser() throws Exception { + public void testGetUserReadAccessWithNormalUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); user.setObjectId("test"); @@ -622,7 +622,7 @@ public void testGetUserReadAccessWithNormalUser() throws Exception { } @Test - public void testGetUserWriteAccessWithUnresolvedUser() throws Exception { + public void testGetUserWriteAccessWithUnresolvedUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); setLazy(user); @@ -633,7 +633,7 @@ public void testGetUserWriteAccessWithUnresolvedUser() throws Exception { } @Test - public void testGetUserWriteAccessWithLazyUser() throws Exception { + public void testGetUserWriteAccessWithLazyUser() { ParseACL acl = new ParseACL(); ParseUser user = mock(ParseUser.class); when(user.isLazy()).thenReturn(true); @@ -642,7 +642,7 @@ public void testGetUserWriteAccessWithLazyUser() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testGetUserWriteAccessWithNotSavedUser() throws Exception { + public void testGetUserWriteAccessWithNotSavedUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); @@ -654,7 +654,7 @@ public void testGetUserWriteAccessWithNotSavedUser() throws Exception { //region testGetter/Setter @Test - public void testGetUserWriteAccessWithNormalUser() throws Exception { + public void testGetUserWriteAccessWithNormalUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); user.setObjectId("test"); @@ -664,7 +664,7 @@ public void testGetUserWriteAccessWithNormalUser() throws Exception { } @Test - public void testIsShared() throws Exception { + public void testIsShared() { ParseACL acl = new ParseACL(); acl.setShared(true); @@ -674,7 +674,7 @@ public void testIsShared() throws Exception { //endregion @Test - public void testUnresolvedUser() throws Exception { + public void testUnresolvedUser() { ParseACL acl = new ParseACL(); ParseUser user = new ParseUser(); setLazy(user); diff --git a/parse/src/test/java/com/parse/ParseAnalyticsTest.java b/parse/src/test/java/com/parse/ParseAnalyticsTest.java index 47ae8de86..42bf0fbc9 100644 --- a/parse/src/test/java/com/parse/ParseAnalyticsTest.java +++ b/parse/src/test/java/com/parse/ParseAnalyticsTest.java @@ -76,7 +76,7 @@ public void tearDown() { // No need to test ParseAnalytics since it has no instance fields and all methods are static. @Test - public void testGetAnalyticsController() throws Exception { + public void testGetAnalyticsController() { assertSame(controller, ParseAnalytics.getAnalyticsController()); } @@ -128,7 +128,7 @@ public void testTrackEventInBackgroundNormalParameters() throws Exception { } @Test - public void testTrackEventInBackgroundNullCallback() throws Exception { + public void testTrackEventInBackgroundNullCallback() { Map dimensions = new HashMap<>(); ParseAnalytics.trackEventInBackground("test", dimensions, null); @@ -242,7 +242,7 @@ public void done(ParseException e) { //region testGetPushHashFromIntent @Test - public void testGetPushHashFromIntentNullIntent() throws Exception { + public void testGetPushHashFromIntentNullIntent() { String pushHash = ParseAnalytics.getPushHashFromIntent(null); assertEquals(null, pushHash); @@ -277,7 +277,7 @@ public void testGetPushHashFromIntentEmptyPushHashIntent() throws Exception { } @Test - public void testGetPushHashFromIntentWrongPushHashIntent() throws Exception { + public void testGetPushHashFromIntentWrongPushHashIntent() { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, "error_data"); diff --git a/parse/src/test/java/com/parse/ParseCloudCodeControllerTest.java b/parse/src/test/java/com/parse/ParseCloudCodeControllerTest.java index 4e6cd6834..f026e40e7 100644 --- a/parse/src/test/java/com/parse/ParseCloudCodeControllerTest.java +++ b/parse/src/test/java/com/parse/ParseCloudCodeControllerTest.java @@ -53,7 +53,7 @@ public void tearDown() { //region testConstructor @Test - public void testConstructor() throws Exception { + public void testConstructor() { ParseHttpClient restClient = mock(ParseHttpClient.class); ParseCloudCodeController controller = new ParseCloudCodeController(restClient); @@ -65,7 +65,7 @@ public void testConstructor() throws Exception { //region testConvertCloudResponse @Test - public void testConvertCloudResponseNullResponse() throws Exception { + public void testConvertCloudResponseNullResponse() { ParseHttpClient restClient = mock(ParseHttpClient.class); ParseCloudCodeController controller = new ParseCloudCodeController(restClient); @@ -111,7 +111,7 @@ public void testConvertCloudResponseJsonArrayResponse() throws Exception { //region testCallFunctionInBackground @Test - public void testCallFunctionInBackgroundCommand() throws Exception { + public void testCallFunctionInBackgroundCommand() { // TODO(mengyan): Verify proper command is constructed } diff --git a/parse/src/test/java/com/parse/ParseCloudTest.java b/parse/src/test/java/com/parse/ParseCloudTest.java index 10659276f..a8ee6d8f6 100644 --- a/parse/src/test/java/com/parse/ParseCloudTest.java +++ b/parse/src/test/java/com/parse/ParseCloudTest.java @@ -98,7 +98,7 @@ public void testCallFunctionSync() throws Exception { } @Test - public void testCallFunctionNullCallback() throws Exception { + public void testCallFunctionNullCallback() { ParseCloudCodeController controller = mockParseCloudCodeControllerWithResponse("result"); ParseCorePlugins.getInstance().registerCloudCodeController(controller); Map parameters = new HashMap<>(); diff --git a/parse/src/test/java/com/parse/ParseCoderTest.java b/parse/src/test/java/com/parse/ParseCoderTest.java index 4fd49d988..967e55aa7 100644 --- a/parse/src/test/java/com/parse/ParseCoderTest.java +++ b/parse/src/test/java/com/parse/ParseCoderTest.java @@ -22,7 +22,7 @@ public class ParseCoderTest { @Test - public void testBytes() throws Exception { + public void testBytes() { // string of bytes, including some invalid UTF8 data byte[] bytes = {4, 8, 16, 32, -128, 0, 0, 0}; diff --git a/parse/src/test/java/com/parse/ParseConfigControllerTest.java b/parse/src/test/java/com/parse/ParseConfigControllerTest.java index 37e26ebe9..3d55521a7 100644 --- a/parse/src/test/java/com/parse/ParseConfigControllerTest.java +++ b/parse/src/test/java/com/parse/ParseConfigControllerTest.java @@ -62,7 +62,7 @@ public void tearDown() { //region testConstructor @Test - public void testConstructor() throws Exception { + public void testConstructor() { ParseHttpClient restClient = mock(ParseHttpClient.class); ParseCurrentConfigController currentConfigController = mock(ParseCurrentConfigController.class); ParseConfigController controller = new ParseConfigController(restClient, diff --git a/parse/src/test/java/com/parse/ParseConfigTest.java b/parse/src/test/java/com/parse/ParseConfigTest.java index 667f6d526..cf1da2fb9 100644 --- a/parse/src/test/java/com/parse/ParseConfigTest.java +++ b/parse/src/test/java/com/parse/ParseConfigTest.java @@ -207,7 +207,7 @@ public void testGetSyncFail() { //region testGetCurrentConfig @Test - public void testGetCurrentConfigSuccess() throws Exception { + public void testGetCurrentConfigSuccess() { final Map params = new HashMap<>(); params.put("string", "value"); @@ -221,7 +221,7 @@ public void testGetCurrentConfigSuccess() throws Exception { } @Test - public void testGetCurrentConfigFail() throws Exception { + public void testGetCurrentConfigFail() { ParseException exception = new ParseException(ParseException.CONNECTION_FAILED, "error"); ParseConfigController controller = new ParseConfigController(mock(ParseHttpClient.class), mockParseCurrentConfigControllerWithException(exception)); @@ -237,7 +237,7 @@ public void testGetCurrentConfigFail() throws Exception { //region testGetBoolean @Test - public void testGetBooleanKeyExist() throws Exception { + public void testGetBooleanKeyExist() { final Map params = new HashMap<>(); params.put("key", true); @@ -247,7 +247,7 @@ public void testGetBooleanKeyExist() throws Exception { } @Test - public void testGetBooleanKeyNotExist() throws Exception { + public void testGetBooleanKeyNotExist() { final Map params = new HashMap<>(); params.put("key", true); @@ -257,7 +257,7 @@ public void testGetBooleanKeyNotExist() throws Exception { } @Test - public void testGetBooleanKeyExistValueNotBoolean() throws Exception { + public void testGetBooleanKeyExistValueNotBoolean() { final Map params = new HashMap<>(); params.put("key", 1); @@ -271,7 +271,7 @@ public void testGetBooleanKeyExistValueNotBoolean() throws Exception { //region testGetInt @Test - public void testGetIntKeyExist() throws Exception { + public void testGetIntKeyExist() { final Map params = new HashMap<>(); params.put("key", 998); @@ -281,7 +281,7 @@ public void testGetIntKeyExist() throws Exception { } @Test - public void testGetIntKeyNotExist() throws Exception { + public void testGetIntKeyNotExist() { final Map params = new HashMap<>(); params.put("key", 998); @@ -295,7 +295,7 @@ public void testGetIntKeyNotExist() throws Exception { //region testGetDouble @Test - public void testGetDoubleKeyExist() throws Exception { + public void testGetDoubleKeyExist() { final Map params = new HashMap<>(); params.put("key", 998.1); @@ -305,7 +305,7 @@ public void testGetDoubleKeyExist() throws Exception { } @Test - public void testGetDoubleKeyNotExist() throws Exception { + public void testGetDoubleKeyNotExist() { final Map params = new HashMap<>(); params.put("key", 998.1); @@ -319,7 +319,7 @@ public void testGetDoubleKeyNotExist() throws Exception { //region testGetLong @Test - public void testGetLongKeyExist() throws Exception { + public void testGetLongKeyExist() { final Map params = new HashMap<>(); params.put("key", (long) 998); @@ -329,7 +329,7 @@ public void testGetLongKeyExist() throws Exception { } @Test - public void testGetLongKeyNotExist() throws Exception { + public void testGetLongKeyNotExist() { final Map params = new HashMap<>(); params.put("key", (long) 998); @@ -343,7 +343,7 @@ public void testGetLongKeyNotExist() throws Exception { //region testGet @Test - public void testGetKeyExist() throws Exception { + public void testGetKeyExist() { final Map params = new HashMap<>(); params.put("key", "value"); @@ -353,7 +353,7 @@ public void testGetKeyExist() throws Exception { } @Test - public void testGetKeyNotExist() throws Exception { + public void testGetKeyNotExist() { final Map params = new HashMap<>(); params.put("key", "value"); @@ -363,7 +363,7 @@ public void testGetKeyNotExist() throws Exception { } @Test - public void testGetKeyExistValueNull() throws Exception { + public void testGetKeyExistValueNull() { final Map params = new HashMap<>(); params.put("key", JSONObject.NULL); params.put("keyAgain", null); @@ -380,7 +380,7 @@ public void testGetKeyExistValueNull() throws Exception { //region testGetString @Test - public void testGetStringKeyExist() throws Exception { + public void testGetStringKeyExist() { final Map params = new HashMap<>(); params.put("key", "value"); @@ -390,7 +390,7 @@ public void testGetStringKeyExist() throws Exception { } @Test - public void testGetStringKeyNotExist() throws Exception { + public void testGetStringKeyNotExist() { final Map params = new HashMap<>(); params.put("key", "value"); @@ -400,7 +400,7 @@ public void testGetStringKeyNotExist() throws Exception { } @Test - public void testGetStringKeyExistValueNotString() throws Exception { + public void testGetStringKeyExistValueNotString() { final Map params = new HashMap<>(); params.put("key", 1); @@ -410,7 +410,7 @@ public void testGetStringKeyExistValueNotString() throws Exception { } @Test - public void testGetStringKeyExistValueNull() throws Exception { + public void testGetStringKeyExistValueNull() { final Map params = new HashMap<>(); params.put("key", JSONObject.NULL); params.put("keyAgain", null); @@ -427,7 +427,7 @@ public void testGetStringKeyExistValueNull() throws Exception { //region testGetDate @Test - public void testGetDateKeyExist() throws Exception { + public void testGetDateKeyExist() { final Date date = new Date(); date.setTime(10); Date dateAgain = new Date(); @@ -441,7 +441,7 @@ public void testGetDateKeyExist() throws Exception { } @Test - public void testGetDateKeyNotExist() throws Exception { + public void testGetDateKeyNotExist() { final Date date = new Date(); date.setTime(10); Date dateAgain = new Date(); @@ -455,7 +455,7 @@ public void testGetDateKeyNotExist() throws Exception { } @Test - public void testGetDateKeyExistValueNotDate() throws Exception { + public void testGetDateKeyExistValueNotDate() { Date date = new Date(); date.setTime(20); final Map params = new HashMap<>(); @@ -467,7 +467,7 @@ public void testGetDateKeyExistValueNotDate() throws Exception { } @Test - public void testGetDateKeyExistValueNull() throws Exception { + public void testGetDateKeyExistValueNull() { Date date = new Date(); date.setTime(20); final Map params = new HashMap<>(); @@ -486,7 +486,7 @@ public void testGetDateKeyExistValueNull() throws Exception { //region testGetList @Test - public void testGetListKeyExist() throws Exception { + public void testGetListKeyExist() { final List list = new ArrayList<>(); list.add("foo"); list.add("bar"); @@ -504,7 +504,7 @@ public void testGetListKeyExist() throws Exception { } @Test - public void testGetListKeyNotExist() throws Exception { + public void testGetListKeyNotExist() { final List list = new ArrayList<>(); list.add("foo"); list.add("bar"); @@ -522,7 +522,7 @@ public void testGetListKeyNotExist() throws Exception { } @Test - public void testGetListKeyExistValueNotList() throws Exception { + public void testGetListKeyExistValueNotList() { final List list = new ArrayList<>(); list.add("foo"); list.add("bar"); @@ -536,7 +536,7 @@ public void testGetListKeyExistValueNotList() throws Exception { } @Test - public void testGetListKeyExistValueNull() throws Exception { + public void testGetListKeyExistValueNull() { final List list = new ArrayList<>(); list.add("fooAgain"); list.add("barAgain"); @@ -557,7 +557,7 @@ public void testGetListKeyExistValueNull() throws Exception { //region testGetNumber @Test - public void testGetNumberKeyExist() throws Exception { + public void testGetNumberKeyExist() { final Number number = 1; Number numberAgain = 2; final Map params = new HashMap<>(); @@ -569,7 +569,7 @@ public void testGetNumberKeyExist() throws Exception { } @Test - public void testGetNumberKeyNotExist() throws Exception { + public void testGetNumberKeyNotExist() { final Number number = 1; Number numberAgain = 2; final Map params = new HashMap<>(); @@ -581,7 +581,7 @@ public void testGetNumberKeyNotExist() throws Exception { } @Test - public void testGetNumberKeyExistValueNotNumber() throws Exception { + public void testGetNumberKeyExistValueNotNumber() { Number number = 2; final Map params = new HashMap<>(); params.put("key", new ArrayList()); @@ -592,7 +592,7 @@ public void testGetNumberKeyExistValueNotNumber() throws Exception { } @Test - public void testGetNumberKeyExistValueNull() throws Exception { + public void testGetNumberKeyExistValueNull() { Number number = 2; final Map params = new HashMap<>(); params.put("key", JSONObject.NULL); @@ -610,7 +610,7 @@ public void testGetNumberKeyExistValueNull() throws Exception { //region testGetMap @Test - public void testGetMapKeyExist() throws Exception { + public void testGetMapKeyExist() { final Map map = new HashMap<>(); map.put("first", "foo"); map.put("second", "bar"); @@ -632,7 +632,7 @@ public void testGetMapKeyExist() throws Exception { } @Test - public void testGetMapKeyNotExist() throws Exception { + public void testGetMapKeyNotExist() { final Map map = new HashMap<>(); map.put("first", "foo"); map.put("second", "bar"); @@ -650,7 +650,7 @@ public void testGetMapKeyNotExist() throws Exception { } @Test - public void testGetMapKeyExistValueNotMap() throws Exception { + public void testGetMapKeyExistValueNotMap() { Map map = new HashMap<>(); map.put("firstAgain", "fooAgain"); map.put("secondAgain", "barAgain"); @@ -664,7 +664,7 @@ public void testGetMapKeyExistValueNotMap() throws Exception { } @Test - public void testGetMapKeyExistValueNull() throws Exception { + public void testGetMapKeyExistValueNull() { Map map = new HashMap<>(); map.put("firstAgain", "fooAgain"); map.put("secondAgain", "barAgain"); @@ -838,7 +838,7 @@ public void testGetJsonArrayKeyExistValueNull() throws Exception { //region testGetParseGeoPoint @Test - public void testGetParseGeoPointKeyExist() throws Exception { + public void testGetParseGeoPointKeyExist() { final ParseGeoPoint geoPoint = new ParseGeoPoint(44.484, 26.029); ParseGeoPoint geoPointAgain = new ParseGeoPoint(45.484, 27.029); final Map params = new HashMap<>(); @@ -852,7 +852,7 @@ public void testGetParseGeoPointKeyExist() throws Exception { } @Test - public void testGetParseGeoPointKeyNotExist() throws Exception { + public void testGetParseGeoPointKeyNotExist() { final ParseGeoPoint geoPoint = new ParseGeoPoint(44.484, 26.029); ParseGeoPoint geoPointAgain = new ParseGeoPoint(45.484, 27.029); final Map params = new HashMap<>(); @@ -864,7 +864,7 @@ public void testGetParseGeoPointKeyNotExist() throws Exception { } @Test - public void testGetParseGeoPointKeyExistValueNotParseGeoPoint() throws Exception { + public void testGetParseGeoPointKeyExistValueNotParseGeoPoint() { ParseGeoPoint geoPoint = new ParseGeoPoint(45.484, 27.029); final Map params = new HashMap<>(); params.put("key", 1); @@ -875,7 +875,7 @@ public void testGetParseGeoPointKeyExistValueNotParseGeoPoint() throws Exception } @Test - public void testGetParseGeoPointKeyExistValueNull() throws Exception { + public void testGetParseGeoPointKeyExistValueNull() { ParseGeoPoint geoPoint = new ParseGeoPoint(45.484, 27.029); final Map params = new HashMap<>(); params.put("key", JSONObject.NULL); @@ -893,7 +893,7 @@ public void testGetParseGeoPointKeyExistValueNull() throws Exception { //region testGetParseFile @Test - public void testGetParseFileKeyExist() throws Exception { + public void testGetParseFileKeyExist() { final ParseFile file = new ParseFile( new ParseFile.State.Builder().name("image.png").url("http://yarr.com/image.png").build()); ParseFile fileAgain = new ParseFile( @@ -909,7 +909,7 @@ public void testGetParseFileKeyExist() throws Exception { } @Test - public void testGetParseFileKeyNotExist() throws Exception { + public void testGetParseFileKeyNotExist() { final ParseFile file = new ParseFile( new ParseFile.State.Builder().name("image.png").url("http://yarr.com/image.png").build()); ParseFile fileAgain = new ParseFile( @@ -923,7 +923,7 @@ public void testGetParseFileKeyNotExist() throws Exception { } @Test - public void testGetParseFileKeyExistValueNotParseFile() throws Exception { + public void testGetParseFileKeyExistValueNotParseFile() { ParseFile file = new ParseFile( new ParseFile.State.Builder().name("file.txt").url("http://yarr.com/file.txt").build()); final Map params = new HashMap<>(); @@ -935,7 +935,7 @@ public void testGetParseFileKeyExistValueNotParseFile() throws Exception { } @Test - public void testGetParseFileKeyExistValueNull() throws Exception { + public void testGetParseFileKeyExistValueNull() { ParseFile file = new ParseFile( new ParseFile.State.Builder().name("file.txt").url("http://yarr.com/file.txt").build()); final Map params = new HashMap<>(); @@ -954,7 +954,7 @@ public void testGetParseFileKeyExistValueNull() throws Exception { //region testToString @Test - public void testToStringList() throws Exception { + public void testToStringList() { final List list = new ArrayList<>(); list.add("foo"); list.add("bar"); @@ -973,7 +973,7 @@ public void testToStringList() throws Exception { } @Test - public void testToStringMap() throws Exception { + public void testToStringMap() { final Map map = new HashMap<>(); map.put("first", "foo"); map.put("second", "bar"); @@ -991,7 +991,7 @@ public void testToStringMap() throws Exception { } @Test - public void testToStringParseGeoPoint() throws Exception { + public void testToStringParseGeoPoint() { final ParseGeoPoint geoPoint = new ParseGeoPoint(45.484, 27.029); final Map params = new HashMap<>(); params.put("geoPoint", geoPoint); diff --git a/parse/src/test/java/com/parse/ParseCurrentConfigControllerTest.java b/parse/src/test/java/com/parse/ParseCurrentConfigControllerTest.java index 59f3e13bd..b7cbb500c 100644 --- a/parse/src/test/java/com/parse/ParseCurrentConfigControllerTest.java +++ b/parse/src/test/java/com/parse/ParseCurrentConfigControllerTest.java @@ -311,7 +311,7 @@ public void testGetCurrentConfigAsyncSuccessCurrentConfigNotSetDiskConfigNotExis //region testClearCurrentConfigForTesting @Test - public void testClearCurrentConfigForTestingSuccess() throws Exception { + public void testClearCurrentConfigForTestingSuccess() { File configFile = new File(temporaryFolder.getRoot(), "config"); ParseCurrentConfigController currentConfigController = new ParseCurrentConfigController(configFile); diff --git a/parse/src/test/java/com/parse/ParseDecoderTest.java b/parse/src/test/java/com/parse/ParseDecoderTest.java index 327739dae..056186083 100644 --- a/parse/src/test/java/com/parse/ParseDecoderTest.java +++ b/parse/src/test/java/com/parse/ParseDecoderTest.java @@ -205,7 +205,7 @@ public void testPolygonWithoutCoordinates() throws JSONException { @Test public void testPolygon() throws JSONException { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); diff --git a/parse/src/test/java/com/parse/ParseDefaultACLControllerTest.java b/parse/src/test/java/com/parse/ParseDefaultACLControllerTest.java index 4d29320ca..3cd1e4e4c 100644 --- a/parse/src/test/java/com/parse/ParseDefaultACLControllerTest.java +++ b/parse/src/test/java/com/parse/ParseDefaultACLControllerTest.java @@ -140,8 +140,7 @@ public void testGetDefaultACLWithCurrentUserAndLastCurrentUserNotSame() { when(acl.copy()).thenReturn(copiedACL); controller.defaultACL = acl; controller.defaultACLUsesCurrentUser = true; - ParseACL aclAgain = new ParseACL(); - controller.defaultACLWithCurrentUser = aclAgain; + controller.defaultACLWithCurrentUser = new ParseACL(); // Register currentUser ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class); ParseUser currentUser = mock(ParseUser.class); diff --git a/parse/src/test/java/com/parse/ParseEncoderTest.java b/parse/src/test/java/com/parse/ParseEncoderTest.java index bfcc15aec..5d09f4667 100644 --- a/parse/src/test/java/com/parse/ParseEncoderTest.java +++ b/parse/src/test/java/com/parse/ParseEncoderTest.java @@ -104,7 +104,7 @@ public void testParseGeoPoint() throws JSONException { @Test public void testParsePolygon() throws JSONException { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); @@ -118,7 +118,7 @@ public void testParsePolygon() throws JSONException { } @Test - public void testParseACL() throws JSONException { + public void testParseACL() { ParseACL parseACL = new ParseACL(); JSONObject aclJSON = (JSONObject) testClassObject.encode(parseACL); assertNotNull(aclJSON); @@ -177,13 +177,13 @@ public void testRelationContraint() throws JSONException { } @Test - public void testNull() throws JSONException { + public void testNull() { Object object = testClassObject.encode(null); assertEquals(object, JSONObject.NULL); } @Test - public void testPrimitives() throws JSONException { + public void testPrimitives() { String encodedStr = (String) testClassObject.encode("String"); assertEquals(encodedStr, "String"); int encodedInteger = (Integer) testClassObject.encode(5); @@ -196,7 +196,7 @@ public void testPrimitives() throws JSONException { } @Test - public void testIllegalArgument() throws JSONException { + public void testIllegalArgument() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("invalid type for ParseObject: " + ParseDecoder.class.toString()); diff --git a/parse/src/test/java/com/parse/ParseFileControllerTest.java b/parse/src/test/java/com/parse/ParseFileControllerTest.java index 8674577e0..b32fcb635 100644 --- a/parse/src/test/java/com/parse/ParseFileControllerTest.java +++ b/parse/src/test/java/com/parse/ParseFileControllerTest.java @@ -62,7 +62,7 @@ public void tearDown() { } @Test - public void testGetCacheFile() throws Exception { + public void testGetCacheFile() { File root = temporaryFolder.getRoot(); ParseFileController controller = new ParseFileController(null, root); @@ -97,7 +97,7 @@ public void testClearCache() throws IOException { //region testSaveAsync @Test - public void testSaveAsyncRequest() throws Exception { + public void testSaveAsyncRequest() { // TODO(grantland): Verify proper command is constructed } diff --git a/parse/src/test/java/com/parse/ParseFileHttpBodyTest.java b/parse/src/test/java/com/parse/ParseFileHttpBodyTest.java index a455b64de..a69066858 100644 --- a/parse/src/test/java/com/parse/ParseFileHttpBodyTest.java +++ b/parse/src/test/java/com/parse/ParseFileHttpBodyTest.java @@ -38,7 +38,7 @@ private static File makeTestFile(File root) throws IOException { return file; } - private static void verifyTestFileContent(byte[] bytes) throws IOException { + private static void verifyTestFileContent(byte[] bytes) { assertArrayEquals("content".getBytes(), bytes); } diff --git a/parse/src/test/java/com/parse/ParseFileUtilsTest.java b/parse/src/test/java/com/parse/ParseFileUtilsTest.java index 90a696ec9..684f6c3fe 100644 --- a/parse/src/test/java/com/parse/ParseFileUtilsTest.java +++ b/parse/src/test/java/com/parse/ParseFileUtilsTest.java @@ -56,7 +56,7 @@ public void testWriteStringToFile() throws Exception { ParseFileUtils.writeStringToFile(file, TEST_STRING, "UTF-8"); InputStream in = null; - String content = null; + String content; try { in = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -91,7 +91,7 @@ public void testWriteJSONObjectToFile() throws Exception { ParseFileUtils.writeJSONObjectToFile(file, new JSONObject(TEST_JSON)); InputStream in = null; - String content = null; + String content; try { in = new FileInputStream(file); ByteArrayOutputStream out = new ByteArrayOutputStream(); diff --git a/parse/src/test/java/com/parse/ParseHttpResponseTest.java b/parse/src/test/java/com/parse/ParseHttpResponseTest.java index 3c7fd3145..469562042 100644 --- a/parse/src/test/java/com/parse/ParseHttpResponseTest.java +++ b/parse/src/test/java/com/parse/ParseHttpResponseTest.java @@ -25,7 +25,7 @@ public class ParseHttpResponseTest { @Test - public void testParseHttpResponseDefaults() throws IOException { + public void testParseHttpResponseDefaults() { ParseHttpResponse response = new ParseHttpResponse.Builder().build(); assertNull(response.getContent()); @@ -68,7 +68,7 @@ public void testParseHttpResponseGetMethod() throws IOException { } @Test - public void testParseHttpResponseBuildWithParseHttpResponse() throws IOException { + public void testParseHttpResponseBuildWithParseHttpResponse() { Map headers = new HashMap<>(); String name = "name"; String value = "value"; diff --git a/parse/src/test/java/com/parse/ParseInstallationTest.java b/parse/src/test/java/com/parse/ParseInstallationTest.java index 4fc12ea5e..a543670d1 100644 --- a/parse/src/test/java/com/parse/ParseInstallationTest.java +++ b/parse/src/test/java/com/parse/ParseInstallationTest.java @@ -20,7 +20,7 @@ import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; -import java.util.Arrays; +import java.util.Collections; import java.util.Locale; import java.util.TimeZone; @@ -118,7 +118,7 @@ public void testImmutableKeys() { } try { - installation.removeAll(immutableKey, Arrays.asList()); + installation.removeAll(immutableKey, Collections.emptyList()); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("Cannot modify")); } @@ -126,7 +126,7 @@ public void testImmutableKeys() { } @Test(expected = RuntimeException.class) - public void testInstallationObjectIdCannotBeChanged() throws Exception { + public void testInstallationObjectIdCannotBeChanged() { boolean hasException = false; ParseInstallation installation = new ParseInstallation(); try { @@ -304,7 +304,7 @@ public void testUpdateBeforeSave() throws Exception { } @Test - public void testDeviceToken() throws Exception { + public void testDeviceToken() { ParseInstallation installation = new ParseInstallation(); installation.setDeviceToken("deviceToken"); @@ -318,7 +318,7 @@ public void testDeviceToken() throws Exception { } @Test - public void testDeviceTokenWithNullDeviceToken() throws Exception { + public void testDeviceTokenWithNullDeviceToken() { ParseInstallation installation = new ParseInstallation(); installation.setDeviceToken("deviceToken"); @@ -330,7 +330,7 @@ public void testDeviceTokenWithNullDeviceToken() throws Exception { } @Test - public void testGetCurrentInstallation() throws Exception { + public void testGetCurrentInstallation() { // Mock currentInstallationController to make setAsync work ParseCurrentInstallationController controller = mock(ParseCurrentInstallationController.class); @@ -349,7 +349,7 @@ public void testGetCurrentInstallation() throws Exception { // testFetchAsync @Test - public void testLocaleIdentifierSpecialCases() throws Exception { + public void testLocaleIdentifierSpecialCases() { mocksForUpdateBeforeSave(); ParseInstallation installation = new ParseInstallation(); diff --git a/parse/src/test/java/com/parse/ParseKeyValueCacheTest.java b/parse/src/test/java/com/parse/ParseKeyValueCacheTest.java index 26001918b..98e50979f 100644 --- a/parse/src/test/java/com/parse/ParseKeyValueCacheTest.java +++ b/parse/src/test/java/com/parse/ParseKeyValueCacheTest.java @@ -39,7 +39,7 @@ public void setUp() throws Exception { } @After - public void tearDown() throws Exception { + public void tearDown() { ParseKeyValueCache.clearKeyValueCacheDir(); ParseKeyValueCache.maxKeyValueCacheBytes = ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_BYTES; ParseKeyValueCache.maxKeyValueCacheFiles = ParseKeyValueCache.DEFAULT_MAX_KEY_VALUE_CACHE_FILES; @@ -59,7 +59,7 @@ public void testMultipleAsynchronousWrites() throws ParseException { for (int i = 0; i < 1000; i++) { tasks.add(Task.call(new Callable() { @Override - public Void call() throws Exception { + public Void call() { ParseKeyValueCache.saveToKeyValueCache("foo", "test"); return null; } @@ -85,7 +85,7 @@ public void testSaveToKeyValueCacheWithoutCacheDir() throws Exception { } @Test - public void testGetSizeWithoutCacheDir() throws Exception { + public void testGetSizeWithoutCacheDir() { // Delete the cache folder(Simulate users clear the app cache) assertTrue(keyValueCacheDir.exists()); keyValueCacheDir.delete(); diff --git a/parse/src/test/java/com/parse/ParseObjectCurrentCoderTest.java b/parse/src/test/java/com/parse/ParseObjectCurrentCoderTest.java index c983b0d42..2ce2cb0d4 100644 --- a/parse/src/test/java/com/parse/ParseObjectCurrentCoderTest.java +++ b/parse/src/test/java/com/parse/ParseObjectCurrentCoderTest.java @@ -83,7 +83,7 @@ public void testEncodeSuccessWithEmptyState() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testEncodeFailureWithNotNullParseOperationSet() throws Exception { + public void testEncodeFailureWithNotNullParseOperationSet() { ParseObject.State state = new ParseObject.State.Builder("Test") .build(); diff --git a/parse/src/test/java/com/parse/ParseObjectTest.java b/parse/src/test/java/com/parse/ParseObjectTest.java index bbb4ff038..8a4c0504b 100644 --- a/parse/src/test/java/com/parse/ParseObjectTest.java +++ b/parse/src/test/java/com/parse/ParseObjectTest.java @@ -272,13 +272,13 @@ public void testGetAvailableIfKeyAvailable() { ParseObject.State state = mock(ParseObject.State.class); when(state.className()).thenReturn("TestObject"); when(state.isComplete()).thenReturn(false); - when(state.availableKeys()).thenReturn(new HashSet<>(Arrays.asList("foo"))); + when(state.availableKeys()).thenReturn(new HashSet<>(Collections.singletonList("foo"))); ParseObject object = ParseObject.from(state); object.get("foo"); } @Test - public void testGetList() throws Exception { + public void testGetList() { ParseObject object = new ParseObject("Test"); JSONArray array = new JSONArray(); array.put("value"); @@ -293,7 +293,7 @@ public void testGetList() throws Exception { } @Test - public void testGetListWithWrongValue() throws Exception { + public void testGetListWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -313,7 +313,7 @@ public void testGetJSONArray() throws Exception { } @Test - public void testGetJsonArrayWithWrongValue() throws Exception { + public void testGetJsonArrayWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -336,7 +336,7 @@ public void testGetJSONObject() throws Exception { } @Test - public void testGetJsonObjectWithWrongValue() throws Exception { + public void testGetJsonObjectWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -344,7 +344,7 @@ public void testGetJsonObjectWithWrongValue() throws Exception { } @Test - public void testGetBoolean() throws Exception { + public void testGetBoolean() { ParseObject object = new ParseObject("Test"); object.put("key", true); @@ -352,7 +352,7 @@ public void testGetBoolean() throws Exception { } @Test - public void testGetBooleanWithWrongValue() throws Exception { + public void testGetBooleanWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -360,7 +360,7 @@ public void testGetBooleanWithWrongValue() throws Exception { } @Test - public void testGetDate() throws Exception { + public void testGetDate() { ParseObject object = new ParseObject("Test"); Date date = new Date(); object.put("key", date); @@ -369,7 +369,7 @@ public void testGetDate() throws Exception { } @Test - public void testGetDateWithWrongValue() throws Exception { + public void testGetDateWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -377,7 +377,7 @@ public void testGetDateWithWrongValue() throws Exception { } @Test - public void testGetParseGeoPoint() throws Exception { + public void testGetParseGeoPoint() { ParseObject object = new ParseObject("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); object.put("key", point); @@ -386,7 +386,7 @@ public void testGetParseGeoPoint() throws Exception { } @Test - public void testGetParseGeoPointWithWrongValue() throws Exception { + public void testGetParseGeoPointWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -394,9 +394,9 @@ public void testGetParseGeoPointWithWrongValue() throws Exception { } @Test - public void testGetParsePolygon() throws Exception { + public void testGetParsePolygon() { ParseObject object = new ParseObject("Test"); - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); @@ -409,7 +409,7 @@ public void testGetParsePolygon() throws Exception { } @Test - public void testGetParsePolygonWithWrongValue() throws Exception { + public void testGetParsePolygonWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -417,7 +417,7 @@ public void testGetParsePolygonWithWrongValue() throws Exception { } @Test - public void testGetACL() throws Exception { + public void testGetACL() { ParseObject object = new ParseObject("Test"); ParseACL acl = new ParseACL(); object.put("ACL", acl); @@ -426,7 +426,7 @@ public void testGetACL() throws Exception { } @Test - public void testGetACLWithSharedACL() throws Exception { + public void testGetACLWithSharedACL() { ParseObject object = new ParseObject("Test"); ParseACL acl = new ParseACL(); acl.setShared(true); @@ -438,14 +438,14 @@ public void testGetACLWithSharedACL() throws Exception { } @Test - public void testGetACLWithNullValue() throws Exception { + public void testGetACLWithNullValue() { ParseObject object = new ParseObject("Test"); assertNull(object.getACL()); } @Test - public void testGetACLWithWrongValue() throws Exception { + public void testGetACLWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("ACL", 1); @@ -471,7 +471,7 @@ public void testGetMap() throws Exception { } @Test - public void testGetMapWithWrongValue() throws Exception { + public void testGetMapWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -479,7 +479,7 @@ public void testGetMapWithWrongValue() throws Exception { } @Test - public void testGetParseUser() throws Exception { + public void testGetParseUser() { ParseObject object = new ParseObject("Test"); ParseUser user = mock(ParseUser.class); object.put("key", user); @@ -488,7 +488,7 @@ public void testGetParseUser() throws Exception { } @Test - public void testGetParseUserWithWrongValue() throws Exception { + public void testGetParseUserWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -496,7 +496,7 @@ public void testGetParseUserWithWrongValue() throws Exception { } @Test - public void testGetParseFile() throws Exception { + public void testGetParseFile() { ParseObject object = new ParseObject("Test"); ParseFile file = mock(ParseFile.class); object.put("key", file); @@ -505,7 +505,7 @@ public void testGetParseFile() throws Exception { } @Test - public void testGetParseFileWithWrongValue() throws Exception { + public void testGetParseFileWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", 1); @@ -513,7 +513,7 @@ public void testGetParseFileWithWrongValue() throws Exception { } @Test - public void testGetDouble() throws Exception { + public void testGetDouble() { ParseObject object = new ParseObject("Test"); object.put("key", 1.1); @@ -525,7 +525,7 @@ public void testGetDouble() throws Exception { //region testParcelable @Test - public void testGetDoubleWithWrongValue() throws Exception { + public void testGetDoubleWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", "str"); @@ -533,7 +533,7 @@ public void testGetDoubleWithWrongValue() throws Exception { } @Test - public void testGetLong() throws Exception { + public void testGetLong() { ParseObject object = new ParseObject("Test"); object.put("key", 10L); @@ -541,7 +541,7 @@ public void testGetLong() throws Exception { } @Test - public void testGetLongWithWrongValue() throws Exception { + public void testGetLongWithWrongValue() { ParseObject object = new ParseObject("Test"); object.put("key", "str"); @@ -549,7 +549,7 @@ public void testGetLongWithWrongValue() throws Exception { } @Test - public void testParcelable() throws Exception { + public void testParcelable() { ParseObject object = ParseObject.createWithoutData("Test", "objectId"); object.isDeleted = true; object.put("long", 200L); @@ -617,7 +617,7 @@ public void testParcelable() throws Exception { } @Test - public void testParcelWithCircularReference() throws Exception { + public void testParcelWithCircularReference() { ParseObject parent = new ParseObject("Parent"); ParseObject child = new ParseObject("Child"); parent.setObjectId("parentId"); @@ -640,7 +640,7 @@ public void testParcelWithCircularReference() throws Exception { } @Test - public void testParcelWithCircularReferenceFromServer() throws Exception { + public void testParcelWithCircularReferenceFromServer() { ParseObject parent = new ParseObject("Parent"); ParseObject child = new ParseObject("Child"); parent.setState(new ParseObject.State.Builder("Parent") diff --git a/parse/src/test/java/com/parse/ParsePolygonTest.java b/parse/src/test/java/com/parse/ParsePolygonTest.java index 76815c110..412b891e0 100644 --- a/parse/src/test/java/com/parse/ParsePolygonTest.java +++ b/parse/src/test/java/com/parse/ParsePolygonTest.java @@ -36,7 +36,7 @@ public void testConstructors() { new ParseGeoPoint(1, 0) ); - List listPoints = new ArrayList(); + List listPoints = new ArrayList<>(); listPoints.add(new ParseGeoPoint(0, 0)); listPoints.add(new ParseGeoPoint(0, 1)); listPoints.add(new ParseGeoPoint(1, 1)); @@ -65,13 +65,13 @@ public void testThreePointMinimum() { @Test public void testEquality() { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); points.add(new ParseGeoPoint(1, 0)); - List diff = new ArrayList(); + List diff = new ArrayList<>(); diff.add(new ParseGeoPoint(0, 0)); diff.add(new ParseGeoPoint(0, 10)); diff.add(new ParseGeoPoint(10, 10)); @@ -93,7 +93,7 @@ public void testEquality() { @Test public void testContainsPoint() { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); @@ -110,7 +110,7 @@ public void testContainsPoint() { @Test public void testParcelable() { - List points = new ArrayList(); + List points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); diff --git a/parse/src/test/java/com/parse/ParsePushControllerTest.java b/parse/src/test/java/com/parse/ParsePushControllerTest.java index 92ed9f811..63d9e734f 100644 --- a/parse/src/test/java/com/parse/ParsePushControllerTest.java +++ b/parse/src/test/java/com/parse/ParsePushControllerTest.java @@ -232,66 +232,6 @@ public void testBuildRESTSendPushCommandWithQuery() throws Exception { assertEquals("1.2", inequality.getString("$lt")); } - @Test - public void testBuildRESTSendPushCommandWithPushToAndroid() throws Exception { - ParseHttpClient restClient = mock(ParseHttpClient.class); - ParsePushController controller = new ParsePushController(restClient); - - // Build PushState - JSONObject data = new JSONObject(); - data.put(ParsePush.KEY_DATA_MESSAGE, "hello world"); - ParsePush.State state = new ParsePush.State.Builder() - .pushToAndroid(true) - .data(data) - .build(); - - // Build command - ParseRESTCommand pushCommand = controller.buildRESTSendPushCommand(state, "sessionToken"); - - // Verify command - JSONObject jsonParameters = pushCommand.jsonParameters; - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_PUSH_TIME)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_EXPIRATION_TIME)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_EXPIRATION_INTERVAL)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_CHANNELS)); - assertEquals("hello world", - jsonParameters.getJSONObject(ParseRESTPushCommand.KEY_DATA) - .getString(ParsePush.KEY_DATA_MESSAGE)); - assertEquals(ParsePushController.DEVICE_TYPE_ANDROID, - jsonParameters.getJSONObject(ParseRESTPushCommand.KEY_WHERE) - .optString(ParseRESTPushCommand.KEY_DEVICE_TYPE, null)); - } - - @Test - public void testBuildRESTSendPushCommandWithPushToIOS() throws Exception { - ParseHttpClient restClient = mock(ParseHttpClient.class); - ParsePushController controller = new ParsePushController(restClient); - - // Build PushState - JSONObject data = new JSONObject(); - data.put(ParsePush.KEY_DATA_MESSAGE, "hello world"); - ParsePush.State state = new ParsePush.State.Builder() - .pushToIOS(true) - .data(data) - .build(); - - // Build command - ParseRESTCommand pushCommand = controller.buildRESTSendPushCommand(state, "sessionToken"); - - // Verify command - JSONObject jsonParameters = pushCommand.jsonParameters; - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_PUSH_TIME)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_EXPIRATION_TIME)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_EXPIRATION_INTERVAL)); - assertFalse(jsonParameters.has(ParseRESTPushCommand.KEY_CHANNELS)); - assertEquals("hello world", - jsonParameters.getJSONObject(ParseRESTPushCommand.KEY_DATA) - .getString(ParsePush.KEY_DATA_MESSAGE)); - assertEquals(ParsePushController.DEVICE_TYPE_IOS, - jsonParameters.getJSONObject(ParseRESTPushCommand.KEY_WHERE) - .optString(ParseRESTPushCommand.KEY_DEVICE_TYPE, null)); - } - //endregion //region testSendInBackground @@ -305,8 +245,6 @@ public void testBuildRESTSendPushCommandWithPushToIOSAndAndroid() throws Excepti JSONObject data = new JSONObject(); data.put(ParsePush.KEY_DATA_MESSAGE, "hello world"); ParsePush.State state = new ParsePush.State.Builder() - .pushToAndroid(true) - .pushToIOS(true) .data(data) .build(); diff --git a/parse/src/test/java/com/parse/ParsePushStateTest.java b/parse/src/test/java/com/parse/ParsePushStateTest.java index 1335ff5e2..d21690bf6 100644 --- a/parse/src/test/java/com/parse/ParsePushStateTest.java +++ b/parse/src/test/java/com/parse/ParsePushStateTest.java @@ -22,7 +22,6 @@ import java.util.Set; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -35,7 +34,7 @@ public class ParsePushStateTest { //region testDefaults @Test(expected = IllegalArgumentException.class) - public void testDefaultsWithoutData() throws Exception { + public void testDefaultsWithoutData() { // We have to set data to a state otherwise it will throw an exception JSONObject data = new JSONObject(); @@ -57,8 +56,6 @@ public void testDefaultsWithData() throws Exception { assertEquals(null, state.pushTime()); assertEquals(null, state.channelSet()); JSONAssert.assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); - assertEquals(null, state.pushToAndroid()); - assertEquals(null, state.pushToIOS()); assertEquals(null, state.queryState()); } @@ -75,8 +72,6 @@ public void testCopy() throws JSONException { JSONObject data = new JSONObject(); data.put("foo", "bar"); when(state.data()).thenReturn(data); - when(state.pushToAndroid()).thenReturn(true); - when(state.pushToIOS()).thenReturn(false); ParseQuery.State queryState = new ParseQuery.State.Builder<>(ParseInstallation.class).build(); when(state.queryState()).thenReturn(queryState); @@ -91,8 +86,6 @@ public void testCopy() throws JSONException { JSONObject dataCopy = copy.data(); assertNotSame(data, dataCopy); assertEquals("bar", dataCopy.get("foo")); - assertTrue(copy.pushToAndroid()); - assertFalse(copy.pushToIOS()); ParseQuery.State queryStateCopy = copy.queryState(); assertNotSame(queryState, queryStateCopy); assertEquals("_Installation", queryStateCopy.className()); @@ -281,7 +274,7 @@ public void testChannelSetDuplicateChannel() { //region testData @Test(expected = IllegalArgumentException.class) - public void testDataNullData() throws Exception { + public void testDataNullData() { ParsePush.State.Builder builder = new ParsePush.State.Builder(); ParsePush.State state = builder .data(null) @@ -305,88 +298,10 @@ public void testDataNormalData() throws Exception { //endregion - //region testPushToAndroid - - @Test - public void testPushToAndroidNullValue() { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .pushToAndroid(null) - .data(new JSONObject()) - .build(); - - assertEquals(null, state.pushToAndroid()); - } - - @Test - public void testPushToAndroidNormalValue() { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .pushToAndroid(true) - .data(new JSONObject()) - .build(); - - assertTrue(state.pushToAndroid()); - } - - @Test(expected = IllegalArgumentException.class) - public void testPushToAndroidQueryAlreadySet() throws Exception { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .query(ParseInstallation.getQuery()) - .pushToAndroid(true) - .data(new JSONObject()) - .build(); - } - - //endregion - - //region testPushToIOS - - @Test - public void testPushToIOSNullValue() { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .pushToIOS(null) - .data(new JSONObject()) - .build(); - - assertEquals(null, state.pushToIOS()); - } - - @Test - public void testPushToIOSNormalValue() { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .pushToIOS(true) - .data(new JSONObject()) - .build(); - - assertTrue(state.pushToIOS()); - } - - @Test(expected = IllegalArgumentException.class) - public void testPushToIOSQueryAlreadySet() throws Exception { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .query(ParseInstallation.getQuery()) - .pushToIOS(true) - .data(new JSONObject()) - .build(); - } - - //endregion - //region testQuery @Test(expected = IllegalArgumentException.class) - public void testQueryNullQuery() throws Exception { + public void testQueryNullQuery() { ParsePush.State.Builder builder = new ParsePush.State.Builder(); ParsePush.State state = builder @@ -396,19 +311,7 @@ public void testQueryNullQuery() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void testQueryPushToIOSPushToAndroidAlreadySet() throws Exception { - ParsePush.State.Builder builder = new ParsePush.State.Builder(); - - ParsePush.State state = builder - .pushToAndroid(true) - .pushToIOS(false) - .query(ParseInstallation.getQuery()) - .data(new JSONObject()) - .build(); - } - - @Test(expected = IllegalArgumentException.class) - public void testQueryNotInstallationQuery() throws Exception { + public void testQueryNotInstallationQuery() { ParsePush.State.Builder builder = new ParsePush.State.Builder(); ParsePush.State state = builder diff --git a/parse/src/test/java/com/parse/ParsePushTest.java b/parse/src/test/java/com/parse/ParsePushTest.java index 9bebca702..9eac7b4be 100644 --- a/parse/src/test/java/com/parse/ParsePushTest.java +++ b/parse/src/test/java/com/parse/ParsePushTest.java @@ -139,7 +139,7 @@ public void testSetMessage() throws Exception { // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive // builder test cases should be in ParsePushState test @Test - public void testSetExpirationTime() throws Exception { + public void testSetExpirationTime() { ParsePush push = new ParsePush(); push.setExpirationTime(10000); @@ -158,7 +158,7 @@ public void testSetExpirationTime() throws Exception { // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive // builder test cases should be in ParsePushState test @Test - public void testSetExpirationTimeInterval() throws Exception { + public void testSetExpirationTimeInterval() { ParsePush push = new ParsePush(); push.setExpirationTimeInterval(10000); @@ -211,7 +211,7 @@ public void testClearExpiration() { // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive // builder test cases should be in ParsePushState test @Test - public void testSetPushTime() throws Exception { + public void testSetPushTime() { ParsePush push = new ParsePush(); long time = System.currentTimeMillis() / 1000 + 1000; push.setPushTime(time); @@ -226,44 +226,6 @@ public void testSetPushTime() throws Exception { //endregion - //region testSetPushToIOS - - // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive - // builder test cases should be in ParsePushState test - @Test - public void testSetPushToIOS() throws Exception { - ParsePush push = new ParsePush(); - push.setPushToIOS(true); - - // Right now it is hard for us to test a builder, so we build a state to test the builder is - // set correctly - // We have to set message otherwise build() will throw an exception - push.setMessage("message"); - ParsePush.State state = push.builder.build(); - assertTrue(state.pushToIOS()); - } - - //endregion - - //region testSetPushToAndroid - - // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive - // builder test cases should be in ParsePushState test - @Test - public void testSetPushToAndroid() throws Exception { - ParsePush push = new ParsePush(); - push.setPushToAndroid(true); - - // Right now it is hard for us to test a builder, so we build a state to test the builder is - // set correctly - // We have to set message otherwise build() will throw an exception - push.setMessage("message"); - ParsePush.State state = push.builder.build(); - assertTrue(state.pushToAndroid()); - } - - //endregion - //region testSetQuery // We only test a basic case here to make sure logic in ParsePush is correct, more comprehensive @@ -474,7 +436,6 @@ public void testSendInBackgroundSuccess() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); ParseTaskUtils.wait(push.sendInBackground()); @@ -482,7 +443,6 @@ public void testSendInBackgroundSuccess() throws Exception { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); @@ -506,7 +466,6 @@ public void testSendInBackgroundWithCallbackSuccess() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); final Semaphore done = new Semaphore(0); final Capture exceptionCapture = new Capture<>(); @@ -524,7 +483,6 @@ public void done(ParseException e) { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); @@ -549,7 +507,6 @@ public void testSendInBackgroundFail() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); Task pushTask = push.sendInBackground(); pushTask.waitForCompletion(); @@ -558,7 +515,6 @@ public void testSendInBackgroundFail() throws Exception { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); @@ -586,7 +542,6 @@ public void testSendInBackgroundWithCallbackFail() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); final Semaphore done = new Semaphore(0); final Capture exceptionCapture = new Capture<>(); @@ -604,7 +559,6 @@ public void done(ParseException e) { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); @@ -628,7 +582,6 @@ public void testSendSuccess() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); push.send(); @@ -636,7 +589,6 @@ public void testSendSuccess() throws Exception { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); @@ -661,7 +613,6 @@ public void testSendFail() throws Exception { channels.add("testAgain"); push.builder.expirationTime((long) 1000) .data(data) - .pushToIOS(true) .channelSet(channels); try { push.send(); @@ -673,7 +624,6 @@ public void testSendFail() throws Exception { ArgumentCaptor stateCaptor = ArgumentCaptor.forClass(ParsePush.State.class); verify(controller, times(1)).sendInBackground(stateCaptor.capture(), anyString()); ParsePush.State state = stateCaptor.getValue(); - assertTrue(state.pushToIOS()); assertEquals(data, state.data(), JSONCompareMode.NON_EXTENSIBLE); assertEquals(2, state.channelSet().size()); assertTrue(state.channelSet().contains("test")); diff --git a/parse/src/test/java/com/parse/ParseQueryStateTest.java b/parse/src/test/java/com/parse/ParseQueryStateTest.java index 3538d2257..313f0d9b5 100644 --- a/parse/src/test/java/com/parse/ParseQueryStateTest.java +++ b/parse/src/test/java/com/parse/ParseQueryStateTest.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -75,8 +76,8 @@ public void testConstraints() { constraints = builder .whereEqualTo("foo", "bar") .whereEqualTo("foo", "baz") // Should overwrite since same key - .addCondition("people", "$in", Arrays.asList("stanley")) // Collection - .addCondition("people", "$in", Arrays.asList("grantland")) // Collection (overwrite) + .addCondition("people", "$in", Collections.singletonList("stanley")) // Collection + .addCondition("people", "$in", Collections.singletonList("grantland")) // Collection (overwrite) .addCondition("something", "$exists", false) // Object .build() .constraints(); @@ -137,7 +138,7 @@ public void testMisc() { // Include, SelectKeys, Limit, Skip builder.include("foo").include("bar"); assertEquals(2, builder.build().includes().size()); - builder.selectKeys(Arrays.asList("foo")).selectKeys(Arrays.asList("bar", "baz", "qux")); + builder.selectKeys(Collections.singletonList("foo")).selectKeys(Arrays.asList("bar", "baz", "qux")); assertEquals(4, builder.build().selectedKeys().size()); builder.setLimit(42); @@ -262,7 +263,7 @@ public void testOrThrowsWithIncludes() { public void testOrThrowsWithSelectedKeys() { List> subqueries = new ArrayList<>(); subqueries.add(new ParseQuery.State.Builder<>("TestObjectA")); - subqueries.add(new ParseQuery.State.Builder<>("TestObjectB").selectKeys(Arrays.asList("blah"))); + subqueries.add(new ParseQuery.State.Builder<>("TestObjectB").selectKeys(Collections.singletonList("blah"))); ParseQuery.State.Builder.or(subqueries).build(); } diff --git a/parse/src/test/java/com/parse/ParseQueryTest.java b/parse/src/test/java/com/parse/ParseQueryTest.java index 5425cface..51a35d68d 100644 --- a/parse/src/test/java/com/parse/ParseQueryTest.java +++ b/parse/src/test/java/com/parse/ParseQueryTest.java @@ -117,7 +117,7 @@ public void testConstructors() { } @Test - public void testCopy() throws InterruptedException { + public void testCopy() { ParseQuery query = new ParseQuery<>("TestObject"); query.setUser(new ParseUser()); query.whereEqualTo("foo", "bar"); @@ -153,7 +153,7 @@ public void testSetUser() throws ParseException { } @Test - public void testMultipleQueries() throws ParseException { + public void testMultipleQueries() { TestQueryController controller1 = new TestQueryController(); TestQueryController controller2 = new TestQueryController(); @@ -206,7 +206,7 @@ public void testMultipleQueriesWithInflightChanges() throws ParseException { } @Test - public void testCountLimitReset() throws ParseException { + public void testCountLimitReset() { // Mock CacheQueryController ParseQueryController controller = mock(CacheQueryController.class); ParseCorePlugins.getInstance().registerQueryController(controller); @@ -222,7 +222,7 @@ public void testCountLimitReset() throws ParseException { } @Test - public void testCountWithCallbackLimitReset() throws ParseException { + public void testCountWithCallbackLimitReset() { // Mock CacheQueryController CacheQueryController controller = mock(CacheQueryController.class); ParseCorePlugins.getInstance().registerQueryController(controller); @@ -246,7 +246,7 @@ public void testCountWithCallbackLimitReset() throws ParseException { //region testConditions @Test - public void testCountLimit() throws ParseException { + public void testCountLimit() { CacheQueryController controller = mock(CacheQueryController.class); ParseCorePlugins.getInstance().registerQueryController(controller); when(controller.countAsync( @@ -263,7 +263,7 @@ public void testCountLimit() throws ParseException { } @Test - public void testCountWithCallbackLimit() throws ParseException { + public void testCountWithCallbackLimit() { CacheQueryController controller = mock(CacheQueryController.class); ParseCorePlugins.getInstance().registerQueryController(controller); when(controller.countAsync( @@ -280,7 +280,7 @@ public void testCountWithCallbackLimit() throws ParseException { } @Test - public void testIsRunning() throws ParseException { + public void testIsRunning() { TestQueryController controller = new TestQueryController(); ParseCorePlugins.getInstance().registerQueryController(controller); TaskCompletionSource tcs = new TaskCompletionSource<>(); @@ -328,7 +328,7 @@ public void testQueryCancellation() throws ParseException { } @Test - public void testCachePolicy() throws Exception { + public void testCachePolicy() { ParseQuery query = new ParseQuery<>("Test"); query.setCachePolicy(ParseQuery.CachePolicy.CACHE_ELSE_NETWORK); @@ -336,7 +336,7 @@ public void testCachePolicy() throws Exception { } @Test - public void testFromNetwork() throws Exception { + public void testFromNetwork() { ParseQuery query = new ParseQuery<>("Test"); Parse.enableLocalDatastore(null); query.fromNetwork(); @@ -345,7 +345,7 @@ public void testFromNetwork() throws Exception { } @Test - public void testFromPin() throws Exception { + public void testFromPin() { ParseQuery query = new ParseQuery<>("Test"); Parse.enableLocalDatastore(null); query.fromPin(); @@ -357,7 +357,7 @@ public void testFromPin() throws Exception { } @Test - public void testMaxCacheAge() throws Exception { + public void testMaxCacheAge() { ParseQuery query = new ParseQuery<>("Test"); query.setMaxCacheAge(10); @@ -365,7 +365,7 @@ public void testMaxCacheAge() throws Exception { } @Test - public void testWhereNotEqualTo() throws Exception { + public void testWhereNotEqualTo() { ParseQuery query = new ParseQuery<>("Test"); query.whereNotEqualTo("key", "value"); @@ -374,7 +374,7 @@ public void testWhereNotEqualTo() throws Exception { } @Test - public void testWhereGreaterThan() throws Exception { + public void testWhereGreaterThan() { ParseQuery query = new ParseQuery<>("Test"); query.whereGreaterThan("key", "value"); @@ -383,7 +383,7 @@ public void testWhereGreaterThan() throws Exception { } @Test - public void testWhereLessThanOrEqualTo() throws Exception { + public void testWhereLessThanOrEqualTo() { ParseQuery query = new ParseQuery<>("Test"); query.whereLessThanOrEqualTo("key", "value"); @@ -392,7 +392,7 @@ public void testWhereLessThanOrEqualTo() throws Exception { } @Test - public void testWhereGreaterThanOrEqualTo() throws Exception { + public void testWhereGreaterThanOrEqualTo() { ParseQuery query = new ParseQuery<>("Test"); query.whereGreaterThanOrEqualTo("key", "value"); @@ -401,7 +401,7 @@ public void testWhereGreaterThanOrEqualTo() throws Exception { } @Test - public void testWhereContainedIn() throws Exception { + public void testWhereContainedIn() { ParseQuery query = new ParseQuery<>("Test"); List values = Arrays.asList("value", "valueAgain"); @@ -411,7 +411,7 @@ public void testWhereContainedIn() throws Exception { } @Test - public void testWhereFullText() throws Exception { + public void testWhereFullText() { ParseQuery query = new ParseQuery<>("Test"); String text = "TestString"; query.whereFullText("key", text); @@ -427,7 +427,7 @@ public void testWhereFullText() throws Exception { } @Test - public void testWhereContainsAll() throws Exception { + public void testWhereContainsAll() { ParseQuery query = new ParseQuery<>("Test"); List values = Arrays.asList("value", "valueAgain"); @@ -437,7 +437,7 @@ public void testWhereContainsAll() throws Exception { } @Test - public void testWhereContainsAllStartingWith() throws Exception { + public void testWhereContainsAllStartingWith() { ParseQuery query = new ParseQuery<>("Test"); String value = "value"; String valueAgain = "valueAgain"; @@ -456,7 +456,7 @@ public void testWhereContainsAllStartingWith() throws Exception { } @Test - public void testWhereNotContainedIn() throws Exception { + public void testWhereNotContainedIn() { ParseQuery query = new ParseQuery<>("Test"); List values = Arrays.asList("value", "valueAgain"); @@ -466,7 +466,7 @@ public void testWhereNotContainedIn() throws Exception { } @Test - public void testWhereMatches() throws Exception { + public void testWhereMatches() { ParseQuery query = new ParseQuery<>("Test"); query.whereMatches("key", "regex"); @@ -475,7 +475,7 @@ public void testWhereMatches() throws Exception { } @Test - public void testWhereMatchesWithModifiers() throws Exception { + public void testWhereMatchesWithModifiers() { ParseQuery query = new ParseQuery<>("Test"); query.whereMatches("key", "regex", "modifiers"); @@ -485,7 +485,7 @@ public void testWhereMatchesWithModifiers() throws Exception { } @Test - public void testWhereStartsWith() throws Exception { + public void testWhereStartsWith() { ParseQuery query = new ParseQuery<>("Test"); String value = "prefix"; @@ -495,7 +495,7 @@ public void testWhereStartsWith() throws Exception { } @Test - public void testWhereEndsWith() throws Exception { + public void testWhereEndsWith() { ParseQuery query = new ParseQuery<>("Test"); String value = "suffix"; @@ -505,7 +505,7 @@ public void testWhereEndsWith() throws Exception { } @Test - public void testWhereExists() throws Exception { + public void testWhereExists() { ParseQuery query = new ParseQuery<>("Test"); query.whereExists("key"); @@ -514,7 +514,7 @@ public void testWhereExists() throws Exception { } @Test - public void testWhereDoesNotExist() throws Exception { + public void testWhereDoesNotExist() { ParseQuery query = new ParseQuery<>("Test"); query.whereDoesNotExist("key"); @@ -523,7 +523,7 @@ public void testWhereDoesNotExist() throws Exception { } @Test - public void testWhereContains() throws Exception { + public void testWhereContains() { ParseQuery query = new ParseQuery<>("Test"); String value = "value"; @@ -533,7 +533,7 @@ public void testWhereContains() throws Exception { } @Test - public void testWhereMatchesQuery() throws Exception { + public void testWhereMatchesQuery() { ParseQuery query = new ParseQuery<>("Test"); ParseQuery conditionQuery = new ParseQuery<>("Test"); conditionQuery.whereExists("keyAgain"); @@ -544,7 +544,7 @@ public void testWhereMatchesQuery() throws Exception { } @Test - public void testWhereDoesNotMatchQuery() throws Exception { + public void testWhereDoesNotMatchQuery() { ParseQuery query = new ParseQuery<>("Test"); ParseQuery conditionQuery = new ParseQuery<>("Test"); conditionQuery.whereExists("keyAgain"); @@ -555,7 +555,7 @@ public void testWhereDoesNotMatchQuery() throws Exception { } @Test - public void testWhereMatchesKeyInQuery() throws Exception { + public void testWhereMatchesKeyInQuery() { ParseQuery query = new ParseQuery<>("Test"); ParseQuery conditionQuery = new ParseQuery<>("Test"); conditionQuery.whereExists("keyAgain"); @@ -569,7 +569,7 @@ public void testWhereMatchesKeyInQuery() throws Exception { } @Test - public void testWhereDoesNotMatchKeyInQuery() throws Exception { + public void testWhereDoesNotMatchKeyInQuery() { ParseQuery query = new ParseQuery<>("Test"); ParseQuery conditionQuery = new ParseQuery<>("Test"); conditionQuery.whereExists("keyAgain"); @@ -583,7 +583,7 @@ public void testWhereDoesNotMatchKeyInQuery() throws Exception { } @Test - public void testWhereNear() throws Exception { + public void testWhereNear() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); @@ -593,7 +593,7 @@ public void testWhereNear() throws Exception { } @Test - public void testWhereWithinGeoBox() throws Exception { + public void testWhereWithinGeoBox() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); ParseGeoPoint pointAgain = new ParseGeoPoint(20, 20); @@ -613,7 +613,7 @@ public void testWhereWithinGeoBox() throws Exception { } @Test - public void testWhereWithinPolygon() throws Exception { + public void testWhereWithinPolygon() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point1 = new ParseGeoPoint(10, 10); ParseGeoPoint point2 = new ParseGeoPoint(20, 20); @@ -635,7 +635,7 @@ public void testWhereWithinPolygon() throws Exception { } @Test - public void testWhereWithinPolygonWithPolygon() throws Exception { + public void testWhereWithinPolygonWithPolygon() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point1 = new ParseGeoPoint(10, 10); ParseGeoPoint point2 = new ParseGeoPoint(20, 20); @@ -657,7 +657,7 @@ public void testWhereWithinPolygonWithPolygon() throws Exception { } @Test - public void testWherePolygonContains() throws Exception { + public void testWherePolygonContains() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); @@ -674,7 +674,7 @@ public void testWherePolygonContains() throws Exception { } @Test - public void testWhereWithinRadians() throws Exception { + public void testWhereWithinRadians() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); @@ -687,7 +687,7 @@ public void testWhereWithinRadians() throws Exception { // TODO(mengyan): Add testOr illegal cases unit test @Test - public void testWhereWithinMiles() throws Exception { + public void testWhereWithinMiles() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); @@ -698,7 +698,7 @@ public void testWhereWithinMiles() throws Exception { } @Test - public void testWhereWithinKilometers() throws Exception { + public void testWhereWithinKilometers() { ParseQuery query = new ParseQuery<>("Test"); ParseGeoPoint point = new ParseGeoPoint(10, 10); @@ -709,7 +709,7 @@ public void testWhereWithinKilometers() throws Exception { } @Test - public void testClear() throws Exception { + public void testClear() { ParseQuery query = new ParseQuery<>("Test"); query.whereEqualTo("key", "value"); query.whereEqualTo("otherKey", "otherValue"); @@ -721,7 +721,7 @@ public void testClear() throws Exception { } @Test - public void testOr() throws Exception { + public void testOr() { ParseQuery query = new ParseQuery<>("Test"); query.whereEqualTo("key", "value"); ParseQuery queryAgain = new ParseQuery<>("Test"); @@ -747,7 +747,7 @@ public void testOr() throws Exception { } @Test - public void testInclude() throws Exception { + public void testInclude() { ParseQuery query = new ParseQuery<>("Test"); query.include("key"); @@ -759,7 +759,7 @@ public void testInclude() throws Exception { } @Test - public void testSelectKeys() throws Exception { + public void testSelectKeys() { ParseQuery query = new ParseQuery<>("Test"); query.selectKeys(Arrays.asList("key", "keyAgain")); @@ -772,7 +772,7 @@ public void testSelectKeys() throws Exception { } @Test - public void testAddAscendingOrder() throws Exception { + public void testAddAscendingOrder() { ParseQuery query = new ParseQuery<>("Test"); query.addAscendingOrder("key"); @@ -784,7 +784,7 @@ public void testAddAscendingOrder() throws Exception { } @Test - public void testAddDescendingOrder() throws Exception { + public void testAddDescendingOrder() { ParseQuery query = new ParseQuery<>("Test"); query.addDescendingOrder("key"); @@ -796,7 +796,7 @@ public void testAddDescendingOrder() throws Exception { } @Test - public void testOrderByAscending() throws Exception { + public void testOrderByAscending() { ParseQuery query = new ParseQuery<>("Test"); query.orderByAscending("key"); @@ -809,7 +809,7 @@ public void testOrderByAscending() throws Exception { } @Test - public void testOrderByDescending() throws Exception { + public void testOrderByDescending() { ParseQuery query = new ParseQuery<>("Test"); query.orderByDescending("key"); @@ -822,7 +822,7 @@ public void testOrderByDescending() throws Exception { } @Test - public void testLimit() throws Exception { + public void testLimit() { ParseQuery query = new ParseQuery<>("Test"); query.setLimit(5); @@ -831,7 +831,7 @@ public void testLimit() throws Exception { } @Test - public void testSkip() throws Exception { + public void testSkip() { ParseQuery query = new ParseQuery<>("Test"); query.setSkip(5); @@ -856,7 +856,7 @@ private static class TestQueryController implements ParseQueryController { public Task await(final Task task) { toAwait = toAwait.continueWithTask(new Continuation>() { @Override - public Task then(Task ignored) throws Exception { + public Task then(Task ignored) { return task; } }); @@ -869,14 +869,14 @@ public Task> findAsync(ParseQuery.State state final AtomicBoolean cancelled = new AtomicBoolean(false); cancellationToken.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { cancelled.set(true); return null; } }); return await(Task.forResult(null).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (cancelled.get()) { return Task.cancelled(); } @@ -891,14 +891,14 @@ public Task countAsync(ParseQuery.State stat final AtomicBoolean cancelled = new AtomicBoolean(false); cancellationToken.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { cancelled.set(true); return null; } }); return await(Task.forResult(null).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (cancelled.get()) { return Task.cancelled(); } @@ -913,14 +913,14 @@ public Task getFirstAsync(ParseQuery.State state, final AtomicBoolean cancelled = new AtomicBoolean(false); cancellationToken.continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { cancelled.set(true); return null; } }); return await(Task.forResult(null).continueWithTask(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { if (cancelled.get()) { return Task.cancelled(); } diff --git a/parse/src/test/java/com/parse/ParseRESTCommandTest.java b/parse/src/test/java/com/parse/ParseRESTCommandTest.java index df1632a5f..f00ce5bc2 100644 --- a/parse/src/test/java/com/parse/ParseRESTCommandTest.java +++ b/parse/src/test/java/com/parse/ParseRESTCommandTest.java @@ -58,12 +58,11 @@ private static ParseHttpResponse newMockParseHttpResponse(int statusCode, JSONOb } private static ParseHttpResponse newMockParseHttpResponse(int statusCode, String body) { - ParseHttpResponse mockResponse = new ParseHttpResponse.Builder() + return new ParseHttpResponse.Builder() .setStatusCode(statusCode) .setTotalSize((long) body.length()) .setContent(new ByteArrayInputStream(body.getBytes())) .build(); - return mockResponse; } @Before @@ -73,7 +72,7 @@ public void setUp() throws Exception { } @After - public void tearDown() throws Exception { + public void tearDown() { ParseRequest.setDefaultInitialRetryDelay(ParseRequest.DEFAULT_INITIAL_RETRY_DELAY); ParseCorePlugins.getInstance().reset(); ParseRESTCommand.server = null; @@ -249,7 +248,7 @@ public void testGetCacheKey() throws Exception { } @Test - public void testGetCacheKeyWithNoJSONParameters() throws Exception { + public void testGetCacheKeyWithNoJSONParameters() { // Make test command String httpPath = "www.parse.com"; String sessionToken = "sessionToken"; @@ -370,7 +369,7 @@ public void testResolveLocalIds() throws Exception { } @Test - public void testRetainLocalIds() throws Exception { + public void testRetainLocalIds() { // Register LocalIdManager LocalIdManager localIdManager = mock(LocalIdManager.class); when(localIdManager.createLocalId()).thenReturn("localIdAgain"); @@ -399,7 +398,7 @@ public void testRetainLocalIds() throws Exception { } @Test - public void testNewBodyWithNoJSONParameters() throws Exception { + public void testNewBodyWithNoJSONParameters() { // Make test command String httpPath = "www.parse.com"; String sessionToken = "sessionToken"; diff --git a/parse/src/test/java/com/parse/ParseRESTQueryCommandTest.java b/parse/src/test/java/com/parse/ParseRESTQueryCommandTest.java index b61da5e75..beca26387 100644 --- a/parse/src/test/java/com/parse/ParseRESTQueryCommandTest.java +++ b/parse/src/test/java/com/parse/ParseRESTQueryCommandTest.java @@ -20,6 +20,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; +import java.util.Collections; import java.util.Map; import static org.junit.Assert.assertEquals; @@ -46,7 +47,7 @@ public void testEncodeWithNoCount() throws Exception { ParseQuery.State state = new ParseQuery.State.Builder<>("TestObject") .orderByAscending("orderKey") .addCondition("inKey", "$in", Arrays.asList("inValue", "inValueAgain")) - .selectKeys(Arrays.asList("selectedKey, selectedKeyAgain")) + .selectKeys(Collections.singletonList("selectedKey, selectedKeyAgain")) .include("includeKey") .setLimit(5) .setSkip(6) @@ -75,7 +76,7 @@ public void testEncodeWithNoCount() throws Exception { } @Test - public void testEncodeWithCount() throws Exception { + public void testEncodeWithCount() { ParseQuery.State state = new ParseQuery.State.Builder<>("TestObject") .setSkip(6) .setLimit(3) diff --git a/parse/src/test/java/com/parse/ParseRESTUserCommandTest.java b/parse/src/test/java/com/parse/ParseRESTUserCommandTest.java index 8e315d6e9..bb0b23a51 100644 --- a/parse/src/test/java/com/parse/ParseRESTUserCommandTest.java +++ b/parse/src/test/java/com/parse/ParseRESTUserCommandTest.java @@ -44,7 +44,7 @@ public void tearDown() { //region testConstruct @Test - public void testGetCurrentUserCommand() throws Exception { + public void testGetCurrentUserCommand() { ParseRESTUserCommand command = ParseRESTUserCommand.getCurrentUserCommand("sessionToken"); assertEquals("users/me", command.httpPath); @@ -146,7 +146,7 @@ public void testAddAdditionalHeaders() throws Exception { //region testOnResponseAsync @Test - public void testOnResponseAsync() throws Exception { + public void testOnResponseAsync() { ParseRESTUserCommand command = ParseRESTUserCommand.getCurrentUserCommand("sessionToken"); diff --git a/parse/src/test/java/com/parse/ParseRelationTest.java b/parse/src/test/java/com/parse/ParseRelationTest.java index 38e7f068f..edc89c6f4 100644 --- a/parse/src/test/java/com/parse/ParseRelationTest.java +++ b/parse/src/test/java/com/parse/ParseRelationTest.java @@ -87,7 +87,7 @@ public void testConstructorWithJSONAndDecoder() throws Exception { //region testParcelable @Test - public void testParcelable() throws Exception { + public void testParcelable() { ParseFieldOperations.registerDefaultDecoders(); ParseRelation relation = new ParseRelation<>("Test"); ParseObject parent = new ParseObject("Parent"); @@ -117,7 +117,7 @@ public void testParcelable() throws Exception { //region testEnsureParentAndKey @Test - public void testEnsureParentAndKey() throws Exception { + public void testEnsureParentAndKey() { ParseRelation relation = new ParseRelation("Test"); ParseObject parent = mock(ParseObject.class); @@ -128,7 +128,7 @@ public void testEnsureParentAndKey() throws Exception { } @Test - public void testEnsureParentAndKeyWithDifferentParent() throws Exception { + public void testEnsureParentAndKeyWithDifferentParent() { ParseRelation relation = new ParseRelation(mock(ParseObject.class), "key"); thrown.expect(IllegalStateException.class); @@ -139,7 +139,7 @@ public void testEnsureParentAndKeyWithDifferentParent() throws Exception { } @Test - public void testEnsureParentAndKeyWithDifferentKey() throws Exception { + public void testEnsureParentAndKeyWithDifferentKey() { ParseObject parent = mock(ParseObject.class); ParseRelation relation = new ParseRelation(parent, "key"); @@ -155,7 +155,7 @@ public void testEnsureParentAndKeyWithDifferentKey() throws Exception { //region testAdd @Test - public void testAdd() throws Exception { + public void testAdd() { ParseObject parent = new ParseObject("Parent"); ParseRelation relation = new ParseRelation(parent, "key"); @@ -178,7 +178,7 @@ public void testAdd() throws Exception { //region testRemove @Test - public void testRemove() throws Exception { + public void testRemove() { ParseObject parent = new ParseObject("Parent"); ParseRelation relation = new ParseRelation(parent, "key"); @@ -202,7 +202,7 @@ public void testRemove() throws Exception { //region testGetQuery @Test - public void testGetQueryWithNoTargetClass() throws Exception { + public void testGetQueryWithNoTargetClass() { ParseObject parent = new ParseObject("Parent"); ParseRelation relation = new ParseRelation(parent, "key"); @@ -221,7 +221,7 @@ public void testGetQueryWithNoTargetClass() throws Exception { } @Test - public void testGetQueryWithTargetClass() throws Exception { + public void testGetQueryWithTargetClass() { ParseObject parent = new ParseObject("Parent"); ParseRelation relation = new ParseRelation(parent, "key"); relation.setTargetClass("targetClass"); diff --git a/parse/src/test/java/com/parse/ParseSessionTest.java b/parse/src/test/java/com/parse/ParseSessionTest.java index cba335674..bfe105479 100644 --- a/parse/src/test/java/com/parse/ParseSessionTest.java +++ b/parse/src/test/java/com/parse/ParseSessionTest.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.junit.Test; -import java.util.Arrays; +import java.util.Collections; import static org.junit.Assert.assertTrue; @@ -59,7 +59,7 @@ public void testImmutableKeys() { } try { - session.removeAll(immutableKey, Arrays.asList()); + session.removeAll(immutableKey, Collections.emptyList()); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("Cannot modify")); } diff --git a/parse/src/test/java/com/parse/ParseUserCurrentCoderTest.java b/parse/src/test/java/com/parse/ParseUserCurrentCoderTest.java index bc191d5bc..7940faf48 100644 --- a/parse/src/test/java/com/parse/ParseUserCurrentCoderTest.java +++ b/parse/src/test/java/com/parse/ParseUserCurrentCoderTest.java @@ -51,7 +51,7 @@ public void testEncodeSuccess() throws Exception { } @Test - public void testEncodeSuccessWithEmptyState() throws Exception { + public void testEncodeSuccessWithEmptyState() { ParseUser.State state = new ParseUser.State.Builder() .build(); @@ -94,7 +94,7 @@ public void testDecodeSuccessWithSessionTokenAndAuthData() throws Exception { } @Test - public void testDecodeSuccessWithoutSessionTokenAndAuthData() throws Exception { + public void testDecodeSuccessWithoutSessionTokenAndAuthData() { JSONObject objectJson = new JSONObject(); ParseUserCurrentCoder coder = ParseUserCurrentCoder.get(); @@ -109,7 +109,7 @@ public void testDecodeSuccessWithoutSessionTokenAndAuthData() throws Exception { } @Test - public void testEncodeDecodeWithNullValues() throws Exception { + public void testEncodeDecodeWithNullValues() { ParseUser.State state = new ParseUser.State.Builder() .sessionToken(null) .authData(null) diff --git a/parse/src/test/java/com/parse/ParseUserTest.java b/parse/src/test/java/com/parse/ParseUserTest.java index 63bdef749..f71689b5a 100644 --- a/parse/src/test/java/com/parse/ParseUserTest.java +++ b/parse/src/test/java/com/parse/ParseUserTest.java @@ -123,7 +123,7 @@ public void testImmutableKeys() { } @Test - public void testOnSaveRestoreState() throws Exception { + public void testOnSaveRestoreState() { ParseUser user = new ParseUser(); user.setObjectId("objId"); user.setIsCurrentUser(true); @@ -140,7 +140,7 @@ public void testOnSaveRestoreState() throws Exception { //region SignUpAsync @Test - public void testParcelableState() throws Exception { + public void testParcelableState() { ParseUser.State state = new ParseUser.State.Builder() .objectId("test") .isNew(true) @@ -406,7 +406,7 @@ public void testSignUpAsyncWithNoCurrentUserAndSignUpSuccess() throws Exception //region testLogInWithAsync @Test - public void testSignUpAsyncWithNoCurrentUserAndSignUpFailure() throws Exception { + public void testSignUpAsyncWithNoCurrentUserAndSignUpFailure() { // Register a mock currentUserController to make getCurrentUser work ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class); when(currentUserController.getAsync(anyBoolean())) @@ -867,7 +867,7 @@ public void testResolveLazinessAsyncWithAuthDataAndNotNewUserAndLDSEnabled() thr // TODO(mengyan): Add testValidateSaveWithIsAuthenticatedWithIsCurrentUser @Test - public void testValidateSaveWithNoObjectId() throws Exception { + public void testValidateSaveWithNoObjectId() { ParseUser user = new ParseUser(); thrown.expect(IllegalArgumentException.class); @@ -877,7 +877,7 @@ public void testValidateSaveWithNoObjectId() throws Exception { } @Test - public void testValidateSaveWithLDSNotEnabled() throws Exception { + public void testValidateSaveWithLDSNotEnabled() { // Register a mock currentUserController to make getCurrentUser work ParseUser currentUser = new ParseUser(); currentUser.setObjectId("test"); @@ -900,7 +900,7 @@ public void testValidateSaveWithLDSNotEnabled() throws Exception { //region testSaveAsync @Test - public void testValidateSaveWithLDSNotEnabledAndCurrentUserNotMatch() throws Exception { + public void testValidateSaveWithLDSNotEnabledAndCurrentUserNotMatch() { // Register a mock currentUserController to make getCurrentUser work ParseUser currentUser = new ParseUser(); currentUser.setObjectId("testAgain"); @@ -1084,7 +1084,7 @@ public void testUpgradeToRevocableSessionAsync() throws Exception { //region testUnlinkFromAsync @Test - public void testDontOverwriteSessionTokenForCurrentUser() throws Exception { + public void testDontOverwriteSessionTokenForCurrentUser() { ParseUser.State sessionTokenState = new ParseUser.State.Builder() .sessionToken("sessionToken") .put("key0", "value0") @@ -1278,7 +1278,7 @@ public void testBecome() throws Exception { //region testToRest @Test - public void testBecomeWithCallback() throws Exception { + public void testBecomeWithCallback() { // Register a mock currentUserController to make setCurrentUser work ParseCurrentUserController currentUserController = mock(ParseCurrentUserController.class); when(currentUserController.setAsync(any(ParseUser.class))) @@ -1336,7 +1336,7 @@ public void testToRest() throws Exception { //region testValidateDelete @Test - public void testValidDelete() throws Exception { + public void testValidDelete() { // Register a mock currentUserController to make getCurrentUser work ParseUser currentUser = new ParseUser(); currentUser.setObjectId("test"); @@ -1437,7 +1437,7 @@ public void testSynchronizeAllAuthData() throws Exception { //region testAutomaticUser @Test - public void testAutomaticUser() throws Exception { + public void testAutomaticUser() { new ParseUser(); ParseUser.disableAutomaticUser(); @@ -1452,7 +1452,7 @@ public void testAutomaticUser() throws Exception { //region testPinCurrentUserIfNeededAsync @Test - public void testPinCurrentUserIfNeededAsyncWithNoLDSEnabled() throws Exception { + public void testPinCurrentUserIfNeededAsyncWithNoLDSEnabled() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Method requires Local Datastore."); @@ -1464,7 +1464,7 @@ public void testPinCurrentUserIfNeededAsyncWithNoLDSEnabled() throws Exception { //region testRemove @Test - public void testPinCurrentUserIfNeededAsync() throws Exception { + public void testPinCurrentUserIfNeededAsync() { // Enable LDS Parse.enableLocalDatastore(null); // Register a mock currentUserController to make getCurrentUser work @@ -1487,7 +1487,7 @@ public void testPinCurrentUserIfNeededAsync() throws Exception { //region testSetState @Test - public void testRemoveWithUserName() throws Exception { + public void testRemoveWithUserName() { ParseUser user = new ParseUser(); thrown.expect(IllegalArgumentException.class); @@ -1497,7 +1497,7 @@ public void testRemoveWithUserName() throws Exception { } @Test - public void testSetCurrentUserStateWithoutAuthData() throws Exception { + public void testSetCurrentUserStateWithoutAuthData() { // Set user initial state String authType = "facebook"; Map authData = new HashMap<>(); @@ -1531,7 +1531,7 @@ public void testSetCurrentUserStateWithoutAuthData() throws Exception { //endregion @Test - public void testSetStateDoesNotAddNonExistentAuthData() throws Exception { + public void testSetStateDoesNotAddNonExistentAuthData() { // Set user initial state ParseUser.State userState = new ParseUser.State.Builder() .objectId("test") @@ -1600,7 +1600,7 @@ public void testSaveEventuallyWhenServerError() throws Exception { final Capture exceptionCapture = new Capture<>(); user.saveInBackground().continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { exceptionCapture.set(task.getError()); saveCountDown1.countDown(); return null; @@ -1622,7 +1622,7 @@ public Void then(Task task) throws Exception { final CountDownLatch saveEventuallyCountDown = new CountDownLatch(1); user.saveEventually().continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { exceptionCapture.set(task.getError()); saveEventuallyCountDown.countDown(); return null; @@ -1652,7 +1652,7 @@ public Void then(Task task) throws Exception { final CountDownLatch saveCountDown2 = new CountDownLatch(1); user.saveInBackground().continueWith(new Continuation() { @Override - public Void then(Task task) throws Exception { + public Void then(Task task) { exceptionCapture.set(task.getError()); saveCountDown2.countDown(); return null; diff --git a/parse/src/test/java/com/parse/SubclassTest.java b/parse/src/test/java/com/parse/SubclassTest.java index 7470df2c3..0e8054594 100644 --- a/parse/src/test/java/com/parse/SubclassTest.java +++ b/parse/src/test/java/com/parse/SubclassTest.java @@ -37,7 +37,7 @@ public void tearDown() throws Exception { } @SuppressWarnings("unused") - public void testUnregisteredConstruction() throws Exception { + public void testUnregisteredConstruction() { Exception thrown = null; try { new UnregisteredClass(); @@ -54,13 +54,13 @@ public void testUnregisteredConstruction() throws Exception { } @Test - public void testSubclassPointers() throws Exception { + public void testSubclassPointers() { Person flashPointer = (Person) ParseObject.createWithoutData("Person", "someFakeObjectId"); assertFalse(flashPointer.isDirty()); } @Test - public void testDirtyingConstructorsThrow() throws Exception { + public void testDirtyingConstructorsThrow() { ClassWithDirtyingConstructor dirtyObj = new ClassWithDirtyingConstructor(); assertTrue(dirtyObj.isDirty()); try { @@ -72,7 +72,7 @@ public void testDirtyingConstructorsThrow() throws Exception { } @Test - public void testRegisteringSubclassesUsesMostDescendantSubclass() throws Exception { + public void testRegisteringSubclassesUsesMostDescendantSubclass() { try { // When we register a ParseUser subclass, we have to clear the cached currentParseUser, so // we need to register a mock ParseUserController here, otherwise Parse.getCacheDir() will @@ -101,7 +101,7 @@ public void testRegisteringSubclassesUsesMostDescendantSubclass() throws Excepti } @Test - public void testRegisteringClassWithNoDefaultConstructorThrows() throws Exception { + public void testRegisteringClassWithNoDefaultConstructorThrows() { Exception thrown = null; try { ParseObject.registerSubclass(NoDefaultConstructor.class); diff --git a/parse/src/test/java/com/parse/TaskQueueTestHelper.java b/parse/src/test/java/com/parse/TaskQueueTestHelper.java index c6f808021..f6897e656 100644 --- a/parse/src/test/java/com/parse/TaskQueueTestHelper.java +++ b/parse/src/test/java/com/parse/TaskQueueTestHelper.java @@ -39,7 +39,7 @@ public void enqueue() { final TaskCompletionSource tcs = new TaskCompletionSource(); taskQueue.enqueue(new Continuation>() { @Override - public Task then(Task task) throws Exception { + public Task then(Task task) { return tcs.getTask(); } });