@Beta
public class Asserts
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Asserts.BooleanWithMessage |
Modifier and Type | Field and Description |
---|---|
static Duration |
DEFAULT_TIMEOUT
The default timeout for assertions.
|
Modifier and Type | Method and Description |
---|---|
static void |
assertEqualsIgnoringOrder(java.lang.Iterable<?> actual,
java.lang.Iterable<?> expected) |
static void |
assertEqualsIgnoringOrder(java.lang.Iterable<?> actual,
java.lang.Iterable<?> expected,
boolean logDuplicates,
java.lang.String errmsg) |
static void |
assertFails(java.util.concurrent.Callable<?> c) |
static void |
assertFails(java.lang.Runnable r) |
static void |
assertFailsWith(java.util.concurrent.Callable<?> c,
groovy.lang.Closure<java.lang.Boolean> exceptionChecker) |
static void |
assertFailsWith(java.util.concurrent.Callable<?> c,
com.google.common.base.Predicate<? super java.lang.Throwable> exceptionChecker) |
static void |
assertFailsWith(java.lang.Runnable c,
java.lang.Class<? extends java.lang.Throwable> validException,
java.lang.Class<? extends java.lang.Throwable>... otherValidExceptions) |
static void |
assertFailsWith(java.lang.Runnable r,
com.google.common.base.Predicate<? super java.lang.Throwable> exceptionChecker) |
static void |
assertFalse(boolean condition,
java.lang.String message)
Asserts that a condition is false.
|
static void |
assertReturnsEventually(java.lang.Runnable r,
Duration timeout) |
static <T> void |
assertThat(T object,
com.google.common.base.Predicate<T> condition) |
static void |
assertTrue(boolean condition,
java.lang.String message)
Asserts that a condition is true.
|
static <T> void |
continually(java.util.Map<java.lang.String,?> flags,
com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<? super T> predicate) |
static <T> void |
continually(java.util.Map<java.lang.String,?> flags,
com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<T> predicate,
java.lang.String errMsg) |
static <T> void |
continually(com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<T> predicate) |
static <T> void |
eventually(java.util.Map<java.lang.String,?> flags,
com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<T> predicate) |
static <T> void |
eventually(java.util.Map<java.lang.String,?> flags,
com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<T> predicate,
java.lang.String errMsg) |
static <T> void |
eventually(com.google.common.base.Supplier<? extends T> supplier,
com.google.common.base.Predicate<T> predicate) |
static java.lang.AssertionError |
fail(java.lang.String message)
Fails a test with the given message.
|
static <T> T |
succeedsContinually(java.util.concurrent.Callable<T> c) |
static <T> T |
succeedsContinually(java.util.Map<?,?> flags,
java.util.concurrent.Callable<T> job) |
static <T> void |
succeedsContinually(java.util.Map<?,?> flags,
java.lang.Runnable r) |
static <T> void |
succeedsContinually(java.lang.Runnable r) |
static <T> T |
succeedsEventually(java.util.concurrent.Callable<T> c)
Asserts given callable succeeds (runs without failure) in default duration.
|
static <T> T |
succeedsEventually(java.util.Map<java.lang.String,?> flags,
java.util.concurrent.Callable<T> c)
Convenience method for cases where we need to test until something is true.
|
static void |
succeedsEventually(java.util.Map<java.lang.String,?> flags,
java.lang.Runnable r) |
static void |
succeedsEventually(java.lang.Runnable r)
Asserts given runnable succeeds in default duration.
|
public static final Duration DEFAULT_TIMEOUT
public static void assertTrue(boolean condition, java.lang.String message)
condition
- the condition to evaluatemessage
- the assertion error messagepublic static void assertFalse(boolean condition, java.lang.String message)
condition
- the condition to evaluatemessage
- the assertion error messagepublic static java.lang.AssertionError fail(java.lang.String message)
message
- the assertion error messagepublic static void assertEqualsIgnoringOrder(java.lang.Iterable<?> actual, java.lang.Iterable<?> expected)
public static void assertEqualsIgnoringOrder(java.lang.Iterable<?> actual, java.lang.Iterable<?> expected, boolean logDuplicates, java.lang.String errmsg)
public static <T> void eventually(com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<T> predicate)
public static <T> void eventually(java.util.Map<java.lang.String,?> flags, com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<T> predicate)
public static <T> void eventually(java.util.Map<java.lang.String,?> flags, com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<T> predicate, java.lang.String errMsg)
public static <T> void continually(com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<T> predicate)
public static <T> void continually(java.util.Map<java.lang.String,?> flags, com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<? super T> predicate)
public static <T> void continually(java.util.Map<java.lang.String,?> flags, com.google.common.base.Supplier<? extends T> supplier, com.google.common.base.Predicate<T> predicate, java.lang.String errMsg)
public static void succeedsEventually(java.lang.Runnable r)
DEFAULT_TIMEOUT
public static void succeedsEventually(java.util.Map<java.lang.String,?> flags, java.lang.Runnable r)
public static <T> T succeedsEventually(java.util.concurrent.Callable<T> c)
DEFAULT_TIMEOUT
public static <T> T succeedsEventually(java.util.Map<java.lang.String,?> flags, java.util.concurrent.Callable<T> c)
The following flags are supported:
flags,
- accepts the flags listed abover
- finallyBlock
- public static <T> void succeedsContinually(java.lang.Runnable r)
public static <T> void succeedsContinually(java.util.Map<?,?> flags, java.lang.Runnable r)
public static <T> T succeedsContinually(java.util.concurrent.Callable<T> c)
public static <T> T succeedsContinually(java.util.Map<?,?> flags, java.util.concurrent.Callable<T> job)
public static void assertFails(java.lang.Runnable r)
public static void assertFails(java.util.concurrent.Callable<?> c)
public static void assertFailsWith(java.util.concurrent.Callable<?> c, groovy.lang.Closure<java.lang.Boolean> exceptionChecker)
public static void assertFailsWith(java.lang.Runnable c, java.lang.Class<? extends java.lang.Throwable> validException, java.lang.Class<? extends java.lang.Throwable>... otherValidExceptions)
public static void assertFailsWith(java.lang.Runnable r, com.google.common.base.Predicate<? super java.lang.Throwable> exceptionChecker)
public static void assertFailsWith(java.util.concurrent.Callable<?> c, com.google.common.base.Predicate<? super java.lang.Throwable> exceptionChecker)
public static void assertReturnsEventually(java.lang.Runnable r, Duration timeout) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public static <T> void assertThat(T object, com.google.common.base.Predicate<T> condition)