use of com.parse.boltsinternal.AggregateException in project Parse-SDK-Android by ParsePlatform.
the class ParseTaskUtilsTest method testWaitForTaskWrapsAggregateExceptionAsParseException.
/**
* Verifies {@link AggregateException} gets wrapped with {@link ParseException} when thrown from
* {@link com.parse.ParseTaskUtils#wait(Task)}.
*/
@Test
public void testWaitForTaskWrapsAggregateExceptionAsParseException() {
final Exception error = new RuntimeException("This task failed.");
final ArrayList<Task<Void>> tasks = new ArrayList<>();
for (int i = 0; i < 20; i++) {
final int number = i;
Task<Void> task = Task.callInBackground(() -> {
Thread.sleep((long) (Math.random() * 100));
if (number == 10 || number == 11) {
throw error;
}
return null;
});
tasks.add(task);
}
try {
ParseTaskUtils.wait(Task.whenAll(tasks));
} catch (ParseException e) {
assertTrue(e.getCause() instanceof AggregateException);
}
}
Aggregations