MCPcopy Create free account
hub / github.com/BoltsFramework/Bolts-Java / testOnSuccess

Method testOnSuccess

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

Source from the content-addressed store, hash-verified

385 }
386
387 public void testOnSuccess() {
388 Continuation<Integer, Integer> continuation = new Continuation<Integer, Integer>() {
389 public Integer then(Task<Integer> task) {
390 return task.getResult().intValue() + 1;
391 }
392 };
393 Task<Integer> complete = Task.forResult(5).onSuccess(continuation);
394 Task<Integer> error = Task.<Integer> forError(new IllegalStateException()).onSuccess(
395 continuation);
396 Task<Integer> cancelled = Task.<Integer> cancelled().onSuccess(continuation);
397
398 assertTrue(complete.isCompleted());
399 assertEquals(6, complete.getResult().intValue());
400 assertFalse(complete.isFaulted());
401 assertFalse(complete.isCancelled());
402
403 assertTrue(error.isCompleted());
404 assertTrue(error.getError() instanceof RuntimeException);
405 assertTrue(error.isFaulted());
406 assertFalse(error.isCancelled());
407
408 assertTrue(cancelled.isCompleted());
409 assertFalse(cancelled.isFaulted());
410 assertTrue(cancelled.isCancelled());
411 }
412
413 public void testOnSuccessTask() {
414 Continuation<Integer, Task<Integer>> continuation = new Continuation<Integer, Task<Integer>>() {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected