public class ExtraMatchers extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> org.hamcrest.Matcher<Collection<T>> |
allItemsMatch(org.hamcrest.Matcher<T> itemMatcher)
Matcher that checks all items in a collection to match the item-matcher.
|
static <T> org.hamcrest.Matcher<Set<T>> |
distinctFrom(Set<T> from)
Matcher to check that two sets does not have any common elements.
|
static org.hamcrest.Matcher<String> |
equalIgnoreIndent(String expected)
Equivalent to 'equalToLines' but also ignores any indentation each line has.
|
static org.hamcrest.Matcher<String> |
equalToLines(String expected)
Equivalent to 'equalTo' for strings that normalize the new-line to '\n',
this can make testing that should match output on various platforms
easier to wrote.
|
static <T extends Number> |
inRange(T lowerInclusive,
T upperExclusive)
Checks that the value is in a given numeric value range.
|
static org.hamcrest.Matcher<String> |
matchesRegex(Pattern pattern)
Matcher that uses a pattern to match against a string.
|
static org.hamcrest.Matcher<String> |
matchesRegex(String pattern)
Matcher that uses a pattern to match against a string.
|
static <T> org.hamcrest.Matcher<T> |
oneOf(T... alternatives)
Alternative to hamcrest 'oneOf' that simplifies to match any one of the
values given.
|
public static <T extends Number> org.hamcrest.Matcher<T> inRange(@Nonnull T lowerInclusive, @Nonnull T upperExclusive)
T - The number type.lowerInclusive - The lower inclusive accepted value.upperExclusive - The upper exclusive accepted value (the exact value not accepted).public static org.hamcrest.Matcher<String> equalToLines(@Nonnull String expected)
expected - The expected line content.public static org.hamcrest.Matcher<String> equalIgnoreIndent(@Nonnull String expected)
expected - The expected line content.@SafeVarargs public static <T> org.hamcrest.Matcher<T> oneOf(T... alternatives)
T - The value type.alternatives - The value alternatives.public static <T> org.hamcrest.Matcher<Set<T>> distinctFrom(Set<T> from)
T - The element type.from - The set it should not match.public static <T> org.hamcrest.Matcher<Collection<T>> allItemsMatch(org.hamcrest.Matcher<T> itemMatcher)
T - The item type.itemMatcher - The matcher for each individual item.public static org.hamcrest.Matcher<String> matchesRegex(String pattern)
pattern - The pattern to use.Copyright © 2017. All rights reserved.