Last active
June 2, 2016 08:32
-
-
Save CDRussell/4150ac29676b2a2110daf24f295ba5e0 to your computer and use it in GitHub Desktop.
Helper functions for working with Tasks from BoltsAndroid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.Executor; | |
import bolts.Task; | |
import static org.junit.Assert.assertFalse; | |
import static org.junit.Assert.assertTrue; | |
public abstract class TaskHelper { | |
public static void assertTaskFinishedSuccessfully(Task<?> task) { | |
assertTrue(task.isCompleted()); | |
assertFalse(task.isCancelled()); | |
assertFalse(task.isFaulted()); | |
} | |
public static void assertTaskFailed(Task<?> task) { | |
assertTrue(task.isCompleted()); | |
assertFalse(task.isCancelled()); | |
assertTrue(task.isFaulted()); | |
} | |
public static Executor executeImmediately() { | |
return Runnable::run; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you can't use
Retrolambda
, then you can replaceRunnable::run
with