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

Method testOnSuccessTask

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

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 9

forResultMethod · 0.95
forErrorMethod · 0.95
cancelledMethod · 0.95
onSuccessTaskMethod · 0.80
isCompletedMethod · 0.80
getResultMethod · 0.80
isFaultedMethod · 0.80
isCancelledMethod · 0.80
getErrorMethod · 0.80

Tested by

no test coverage detected