()
| 228 | } |
| 229 | |
| 230 | public void testWhenAllOneError() { |
| 231 | final Exception error = new RuntimeException("This task failed."); |
| 232 | |
| 233 | runTaskTest(new Callable<Task<?>>() { |
| 234 | @Override |
| 235 | public Task<?> call() throws Exception { |
| 236 | final ArrayList<Task<Void>> tasks = new ArrayList<Task<Void>>(); |
| 237 | for (int i = 0; i < 20; i++) { |
| 238 | final int number = i; |
| 239 | Task<Void> task = Task.callInBackground(new Callable<Void>() { |
| 240 | @Override |
| 241 | public Void call() throws Exception { |
| 242 | Thread.sleep((long) (Math.random() * 1000)); |
| 243 | if (number == 10) { |
| 244 | throw error; |
| 245 | } |
| 246 | return null; |
| 247 | } |
| 248 | }); |
| 249 | tasks.add(task); |
| 250 | } |
| 251 | return Task.whenAll(tasks).continueWith(new Continuation<Void, Void>() { |
| 252 | @Override |
| 253 | public Void then(Task<Void> task) { |
| 254 | assertTrue(task.isCompleted()); |
| 255 | assertTrue(task.isFaulted()); |
| 256 | assertFalse(task.isCancelled()); |
| 257 | |
| 258 | assertFalse(task.getError() instanceof AggregateException); |
| 259 | assertEquals(error, task.getError()); |
| 260 | |
| 261 | for (Task<Void> t : tasks) { |
| 262 | assertTrue(t.isCompleted()); |
| 263 | } |
| 264 | return null; |
| 265 | } |
| 266 | }); |
| 267 | } |
| 268 | }); |
| 269 | } |
| 270 | |
| 271 | public void testWhenAllTwoErrors() { |
| 272 | final Exception error = new RuntimeException("This task failed."); |
nothing calls this directly
no test coverage detected