MCPcopy Index your code
hub / github.com/BoltsFramework/Bolts-Java / testWhenAllSuccess

Method testWhenAllSuccess

BoltsTest/src/bolts/TaskTest.java:198–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

196 }
197
198 public void testWhenAllSuccess() {
199 runTaskTest(new Callable<Task<?>>() {
200 @Override
201 public Task<?> call() throws Exception {
202 final ArrayList<Task<Void>> tasks = new ArrayList<Task<Void>>();
203 for (int i = 0; i < 20; i++) {
204 Task<Void> task = Task.callInBackground(new Callable<Void>() {
205 @Override
206 public Void call() throws Exception {
207 Thread.sleep((long) (Math.random() * 1000));
208 return null;
209 }
210 });
211 tasks.add(task);
212 }
213 return Task.whenAll(tasks).continueWith(new Continuation<Void, Void>() {
214 @Override
215 public Void then(Task<Void> task) {
216 assertTrue(task.isCompleted());
217 assertFalse(task.isFaulted());
218 assertFalse(task.isCancelled());
219
220 for (Task<Void> t : tasks) {
221 assertTrue(t.isCompleted());
222 }
223 return null;
224 }
225 });
226 }
227 });
228 }
229
230 public void testWhenAllOneError() {
231 final Exception error = new RuntimeException("This task failed.");

Callers

nothing calls this directly

Calls 1

runTaskTestMethod · 0.95

Tested by

no test coverage detected