Class SerializableMatchers
- All Implemented Interfaces:
Serializable
SerializableMatcher instances.
Most matchers are wrappers for hamcrest's Matchers. Please be familiar with the
documentation there. Values retained by a SerializableMatcher are required to be
serializable, either via Java serialization or via a provided Coder.
The following matchers are novel to Apache Beam:
kvWithKey(K)for matching just the key of aKV.kvWithValue(V)for matching just the value of aKV.kv(org.apache.beam.sdk.testing.SerializableMatcher<? super K>, org.apache.beam.sdk.testing.SerializableMatcher<? super V>)for matching the key and value of aKV.
For example, to match a group from GroupByKey, which
has type KV<K, Iterable<V>> for some K and V and where the order of the
iterable is undefined, use a matcher like kv(equalTo("some key"), containsInAnyOrder(1, 2,
3)).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SerializableMatcher<T> allOf(Iterable<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.allOf(Iterable).static <T> SerializableMatcher<T> allOf(SerializableMatcher<T>... matchers) ASerializableMatcherwith identical criteria toMatchers.allOf(Matcher[]).static <T> SerializableMatcher<T> anyOf(Iterable<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.anyOf(Iterable).static <T> SerializableMatcher<T> anyOf(SerializableMatcher<T>... matchers) ASerializableMatcherwith identical criteria toMatchers.anyOf(Matcher[]).static SerializableMatcher<Object> anything()ASerializableMatcherwith identical criteria toMatchers.anything().static <T> SerializableMatcher<T[]> arrayContaining(List<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(List).static <T> SerializableMatcher<T[]> arrayContaining(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Object[]).static <T> SerializableMatcher<T[]> arrayContaining(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Matcher[]).static <T extends Serializable>
SerializableMatcher<T[]> arrayContaining(T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Object[]).static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(Collection<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Collection).static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Object[]).static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Matcher[]).static <T extends Serializable>
SerializableMatcher<T[]> arrayContainingInAnyOrder(T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Object[]).static <T> SerializableMatcher<T[]> arrayWithSize(int size) ASerializableMatcherwith identical criteria toMatchers.arrayWithSize(int).static <T> SerializableMatcher<T[]> arrayWithSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.arrayWithSize(Matcher).static SerializableMatcher<Double> closeTo(double target, double error) ASerializableMatcherwith identical criteria toMatchers.closeTo(double,double).static <T extends Serializable>
SerializableMatcher<Iterable<? extends T>> contains(List<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.contains(List).static <T> SerializableMatcher<Iterable<? extends T>> ASerializableMatcherwith identical criteria toMatchers.contains(Object[]).static <T> SerializableMatcher<Iterable<? extends T>> contains(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.contains(Matcher[]).static <T extends Serializable>
SerializableMatcher<Iterable<? extends T>> contains(T... items) ASerializableMatcherwith identical criteria toMatchers.contains(Object[]).static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(Collection<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Collection).static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Object[]).static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Matcher[]).static <T extends Serializable>
SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(T... items) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Object[]).static SerializableMatcher<String> containsString(String substring) ASerializableMatcherwith identical criteria toMatchers.containsString(java.lang.String).static <T> SerializableMatcher<Collection<? extends T>> empty()ASerializableMatcherwith identical criteria toMatchers.empty().static <T> SerializableMatcher<T[]> ASerializableMatcherwith identical criteria toMatchers.emptyArray().static <T> SerializableMatcher<Iterable<? extends T>> ASerializableMatcherwith identical criteria toMatchers.emptyIterable().static SerializableMatcher<String> ASerializableMatcherwith identical criteria toMatchers.endsWith(java.lang.String).static <T> SerializableMatcher<T> ASerializableMatcherwith identical criteria toMatchers.equalTo(Object).static <T extends Serializable>
SerializableMatcher<T> equalTo(T expected) ASerializableMatcherwith identical criteria toMatchers.equalTo(Object).static <T> SerializableMatcher<T> fromSupplier(org.apache.beam.sdk.util.SerializableSupplier<Matcher<T>> supplier) Constructs aSerializableMatcherfrom a non-serializableMatchervia indirection throughSerializableSupplier.static <T extends Comparable<T> & Serializable>
SerializableMatcher<T> greaterThan(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.greaterThan(Comparable).static <T extends Comparable<T> & Serializable>
SerializableMatcher<T> greaterThan(T target) ASerializableMatcherwith identical criteria toMatchers.greaterThan(Comparable).static <T extends Comparable<T> & Serializable>
SerializableMatcher<T> greaterThanOrEqualTo(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.greaterThanOrEqualTo(Comparable).static <T extends Comparable<T>>
SerializableMatcher<T> greaterThanOrEqualTo(T target) ASerializableMatcherwith identical criteria toMatchers.greaterThanOrEqualTo(Comparable).static <T> SerializableMatcher<Iterable<? super T>> ASerializableMatcherwith identical criteria toMatchers.hasItem(Object).static <T> SerializableMatcher<Iterable<? super T>> hasItem(SerializableMatcher<? super T> matcher) ASerializableMatcherwith identical criteria toMatchers.hasItem(Matcher).static <T extends Serializable>
SerializableMatcher<Iterable<? super T>> hasItem(T target) ASerializableMatcherwith identical criteria toMatchers.hasItem(Object).static <T> SerializableMatcher<Collection<? extends T>> hasSize(int size) ASerializableMatcherwith identical criteria toMatchers.hasSize(int).static <T> SerializableMatcher<Collection<? extends T>> hasSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.hasSize(Matcher).static <T extends Serializable>
SerializableMatcher<T> isIn(Collection<T> collection) ASerializableMatcherwith identical criteria toMatchers.isIn(Collection).static <T> SerializableMatcher<T> isIn(Coder<T> coder, Collection<T> collection) ASerializableMatcherwith identical criteria toMatchers.isIn(Collection).static <T> SerializableMatcher<T> ASerializableMatcherwith identical criteria toMatchers.isIn(Object[]).static <T extends Serializable>
SerializableMatcher<T> isIn(T[] items) ASerializableMatcherwith identical criteria toMatchers.isIn(Object[]).static <T> SerializableMatcher<T> ASerializableMatcherwith identical criteria toMatchers.isOneOf(T...).static <T extends Serializable>
SerializableMatcher<T> isOneOf(T... elems) ASerializableMatcherwith identical criteria toMatchers.isOneOf(T...).static <T> SerializableMatcher<Iterable<T>> iterableWithSize(int size) ASerializableMatcherwith identical criteria toMatchers.iterableWithSize(int).static <T> SerializableMatcher<Iterable<T>> iterableWithSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.iterableWithSize(Matcher).static <K,V> SerializableMatcher <KV<? extends K, ? extends V>> kv(SerializableMatcher<? super K> keyMatcher, SerializableMatcher<? super V> valueMatcher) ASerializableMatcherthat matches anyKVwith matching key and value.static <K extends Serializable,V>
SerializableMatcher<KV<? extends K, ? extends V>> kvWithKey(K key) ASerializableMatcherthat matches anyKVwith the specified key.static <K,V> SerializableMatcher <KV<? extends K, ? extends V>> ASerializableMatcherthat matches anyKVwith the specified key.static <K,V> SerializableMatcher <KV<? extends K, ? extends V>> kvWithKey(SerializableMatcher<? super K> keyMatcher) ASerializableMatcherthat matches anyKVwith matching key.static <K,V> SerializableMatcher <KV<? extends K, ? extends V>> kvWithValue(Coder<V> coder, V value) ASerializableMatcherthat matches anyKVwith the specified value.static <K,V> SerializableMatcher <KV<? extends K, ? extends V>> kvWithValue(SerializableMatcher<? super V> valueMatcher) ASerializableMatcherthat matches anyKVwith matching value.static <K,V extends Serializable>
SerializableMatcher<KV<? extends K, ? extends V>> kvWithValue(V value) ASerializableMatcherthat matches anyKVwith the specified value.static <T extends Comparable<T>>
SerializableMatcher<T> ASerializableMatcherwith identical criteria toMatchers.lessThan(Comparable).static <T extends Comparable<T> & Serializable>
SerializableMatcher<T> lessThan(T target) ASerializableMatcherwith identical criteria toMatchers.lessThan(Comparable).static <T extends Comparable<T>>
SerializableMatcher<T> lessThanOrEqualTo(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.lessThanOrEqualTo(Comparable).static <T extends Comparable<T> & Serializable>
SerializableMatcher<T> lessThanOrEqualTo(T target) ASerializableMatcherwith identical criteria toMatchers.lessThanOrEqualTo(Comparable).static <T> SerializableMatcher<T> not(SerializableMatcher<T> matcher) ASerializableMatcherwith identical criteria toMatchers.not(org.hamcrest.Matcher<T>).static SerializableMatcher<Object> ASerializableMatcherwith identical criteria toMatchers.nullValue().static SerializableMatcher<String> startsWith(String substring) ASerializableMatcherwith identical criteria toMatchers.startsWith(java.lang.String).
-
Method Details
-
allOf
public static <T> SerializableMatcher<T> allOf(Iterable<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.allOf(Iterable). -
allOf
ASerializableMatcherwith identical criteria toMatchers.allOf(Matcher[]). -
anyOf
public static <T> SerializableMatcher<T> anyOf(Iterable<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.anyOf(Iterable). -
anyOf
ASerializableMatcherwith identical criteria toMatchers.anyOf(Matcher[]). -
anything
ASerializableMatcherwith identical criteria toMatchers.anything(). -
arrayContaining
@SafeVarargs public static <T extends Serializable> SerializableMatcher<T[]> arrayContaining(T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Object[]). -
arrayContaining
ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Object[]).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
arrayContaining
@SafeVarargs public static <T> SerializableMatcher<T[]> arrayContaining(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(Matcher[]). -
arrayContaining
public static <T> SerializableMatcher<T[]> arrayContaining(List<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.arrayContaining(List). -
arrayContainingInAnyOrder
@SafeVarargs public static <T extends Serializable> SerializableMatcher<T[]> arrayContainingInAnyOrder(T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Object[]). -
arrayContainingInAnyOrder
@SafeVarargs public static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Object[]).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
arrayContainingInAnyOrder
@SafeVarargs public static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Matcher[]). -
arrayContainingInAnyOrder
public static <T> SerializableMatcher<T[]> arrayContainingInAnyOrder(Collection<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.arrayContainingInAnyOrder(Collection). -
arrayWithSize
ASerializableMatcherwith identical criteria toMatchers.arrayWithSize(int). -
arrayWithSize
public static <T> SerializableMatcher<T[]> arrayWithSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.arrayWithSize(Matcher). -
closeTo
ASerializableMatcherwith identical criteria toMatchers.closeTo(double,double). -
contains
@SafeVarargs public static <T extends Serializable> SerializableMatcher<Iterable<? extends T>> contains(T... items) ASerializableMatcherwith identical criteria toMatchers.contains(Object[]). -
contains
@SafeVarargs public static <T> SerializableMatcher<Iterable<? extends T>> contains(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.contains(Object[]).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
contains
@SafeVarargs public static <T> SerializableMatcher<Iterable<? extends T>> contains(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.contains(Matcher[]). -
contains
public static <T extends Serializable> SerializableMatcher<Iterable<? extends T>> contains(List<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.contains(List). -
containsInAnyOrder
@SafeVarargs public static <T extends Serializable> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(T... items) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Object[]). -
containsInAnyOrder
@SafeVarargs public static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(Coder<T> coder, T... items) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Object[]).The items of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
containsInAnyOrder
@SafeVarargs public static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(SerializableMatcher<? super T>... matchers) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Matcher[]). -
containsInAnyOrder
public static <T> SerializableMatcher<Iterable<? extends T>> containsInAnyOrder(Collection<SerializableMatcher<? super T>> serializableMatchers) ASerializableMatcherwith identical criteria toMatchers.containsInAnyOrder(Collection). -
containsString
ASerializableMatcherwith identical criteria toMatchers.containsString(java.lang.String). -
empty
ASerializableMatcherwith identical criteria toMatchers.empty(). -
emptyArray
ASerializableMatcherwith identical criteria toMatchers.emptyArray(). -
emptyIterable
ASerializableMatcherwith identical criteria toMatchers.emptyIterable(). -
endsWith
ASerializableMatcherwith identical criteria toMatchers.endsWith(java.lang.String). -
equalTo
ASerializableMatcherwith identical criteria toMatchers.equalTo(Object). -
equalTo
ASerializableMatcherwith identical criteria toMatchers.equalTo(Object).The expected value of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
greaterThan
ASerializableMatcherwith identical criteria toMatchers.greaterThan(Comparable). -
greaterThan
public static <T extends Comparable<T> & Serializable> SerializableMatcher<T> greaterThan(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.greaterThan(Comparable).The target value of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
greaterThanOrEqualTo
ASerializableMatcherwith identical criteria toMatchers.greaterThanOrEqualTo(Comparable). -
greaterThanOrEqualTo
public static <T extends Comparable<T> & Serializable> SerializableMatcher<T> greaterThanOrEqualTo(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.greaterThanOrEqualTo(Comparable).The target value of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
hasItem
ASerializableMatcherwith identical criteria toMatchers.hasItem(Object). -
hasItem
ASerializableMatcherwith identical criteria toMatchers.hasItem(Object).The item of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
hasItem
public static <T> SerializableMatcher<Iterable<? super T>> hasItem(SerializableMatcher<? super T> matcher) ASerializableMatcherwith identical criteria toMatchers.hasItem(Matcher). -
hasSize
ASerializableMatcherwith identical criteria toMatchers.hasSize(int). -
hasSize
public static <T> SerializableMatcher<Collection<? extends T>> hasSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.hasSize(Matcher). -
iterableWithSize
ASerializableMatcherwith identical criteria toMatchers.iterableWithSize(int). -
iterableWithSize
public static <T> SerializableMatcher<Iterable<T>> iterableWithSize(SerializableMatcher<? super Integer> sizeMatcher) ASerializableMatcherwith identical criteria toMatchers.iterableWithSize(Matcher). -
isIn
ASerializableMatcherwith identical criteria toMatchers.isIn(Collection). -
isIn
ASerializableMatcherwith identical criteria toMatchers.isIn(Collection).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
isIn
ASerializableMatcherwith identical criteria toMatchers.isIn(Object[]). -
isIn
ASerializableMatcherwith identical criteria toMatchers.isIn(Object[]).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
isOneOf
ASerializableMatcherwith identical criteria toMatchers.isOneOf(T...). -
isOneOf
ASerializableMatcherwith identical criteria toMatchers.isOneOf(T...).The items of type
Twill be serialized using the providedCoder. They are explicitly not required or expected to be serializable via Java serialization. -
kvWithKey
public static <K extends Serializable,V> SerializableMatcher<KV<? extends K,? extends V>> kvWithKey(K key) ASerializableMatcherthat matches anyKVwith the specified key. -
kvWithKey
public static <K,V> SerializableMatcher<KV<? extends K,? extends V>> kvWithKey(Coder<K> coder, K key) ASerializableMatcherthat matches anyKVwith the specified key.The key of type
Kwill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
kvWithKey
public static <K,V> SerializableMatcher<KV<? extends K,? extends V>> kvWithKey(SerializableMatcher<? super K> keyMatcher) ASerializableMatcherthat matches anyKVwith matching key. -
kvWithValue
public static <K,V extends Serializable> SerializableMatcher<KV<? extends K,? extends V>> kvWithValue(V value) ASerializableMatcherthat matches anyKVwith the specified value. -
kvWithValue
public static <K,V> SerializableMatcher<KV<? extends K,? extends V>> kvWithValue(Coder<V> coder, V value) ASerializableMatcherthat matches anyKVwith the specified value.The value of type
Vwill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
kvWithValue
public static <K,V> SerializableMatcher<KV<? extends K,? extends V>> kvWithValue(SerializableMatcher<? super V> valueMatcher) ASerializableMatcherthat matches anyKVwith matching value. -
kv
public static <K,V> SerializableMatcher<KV<? extends K,? extends V>> kv(SerializableMatcher<? super K> keyMatcher, SerializableMatcher<? super V> valueMatcher) ASerializableMatcherthat matches anyKVwith matching key and value. -
lessThan
ASerializableMatcherwith identical criteria toMatchers.lessThan(Comparable). -
lessThan
ASerializableMatcherwith identical criteria toMatchers.lessThan(Comparable).The target value of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
lessThanOrEqualTo
public static <T extends Comparable<T> & Serializable> SerializableMatcher<T> lessThanOrEqualTo(T target) ASerializableMatcherwith identical criteria toMatchers.lessThanOrEqualTo(Comparable). -
lessThanOrEqualTo
public static <T extends Comparable<T>> SerializableMatcher<T> lessThanOrEqualTo(Coder<T> coder, T target) ASerializableMatcherwith identical criteria toMatchers.lessThanOrEqualTo(Comparable).The target value of type
Twill be serialized using the providedCoder. It is explicitly not required or expected to be serializable via Java serialization. -
not
ASerializableMatcherwith identical criteria toMatchers.not(org.hamcrest.Matcher<T>). -
nullValue
ASerializableMatcherwith identical criteria toMatchers.nullValue(). -
startsWith
ASerializableMatcherwith identical criteria toMatchers.startsWith(java.lang.String). -
fromSupplier
public static <T> SerializableMatcher<T> fromSupplier(org.apache.beam.sdk.util.SerializableSupplier<Matcher<T>> supplier) Constructs aSerializableMatcherfrom a non-serializableMatchervia indirection throughSerializableSupplier.To wrap a
Matcherwhich is not serializable, provide aSerializableSupplierwith aSupplier.get()method that returns a fresh instance of theMatcherdesired. The resultingSerializableMatcherwill behave according to theMatcherreturned byget()when it is invoked during matching (which may occur on another machine).return fromSupplier(new SerializableSupplier<Matcher<T>>() { * @Override public Matcher<T> get() { return new MyMatcherForT(); } });
-