()
| 411 | } |
| 412 | |
| 413 | public void testOnSuccessTask() { |
| 414 | Continuation<Integer, Task<Integer>> continuation = new Continuation<Integer, Task<Integer>>() { |
| 415 | public Task<Integer> then(Task<Integer> task) { |
| 416 | return Task.forResult(task.getResult().intValue() + 1); |
| 417 | } |
| 418 | }; |
| 419 | Task<Integer> complete = Task.forResult(5).onSuccessTask(continuation); |
| 420 | Task<Integer> error = Task.<Integer> forError(new IllegalStateException()).onSuccessTask( |
| 421 | continuation); |
| 422 | Task<Integer> cancelled = Task.<Integer> cancelled().onSuccessTask(continuation); |
| 423 | |
| 424 | assertTrue(complete.isCompleted()); |
| 425 | assertEquals(6, complete.getResult().intValue()); |
| 426 | assertFalse(complete.isFaulted()); |
| 427 | assertFalse(complete.isCancelled()); |
| 428 | |
| 429 | assertTrue(error.isCompleted()); |
| 430 | assertTrue(error.getError() instanceof RuntimeException); |
| 431 | assertTrue(error.isFaulted()); |
| 432 | assertFalse(error.isCancelled()); |
| 433 | |
| 434 | assertTrue(cancelled.isCompleted()); |
| 435 | assertFalse(cancelled.isFaulted()); |
| 436 | assertTrue(cancelled.isCancelled()); |
| 437 | } |
| 438 | |
| 439 | public void testContinueWhile() { |
| 440 | final AtomicInteger count = new AtomicInteger(0); |
nothing calls this directly
no test coverage detected