Java Code Examples for org.hamcrest.Matchers#contains()
The following examples show how to use
org.hamcrest.Matchers#contains() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InfluxHistoryTest.java From monsoon with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static Matcher<Iterable<? extends TimeSeriesCollection>> computeDataMatcher(Collection<KeyedQuery> queries, boolean reverse) { final List<Matcher<? super TimeSeriesCollection>> result = computeData(queries) .map(Matchers::equalTo) .collect(Collectors.toList()); if (reverse) Collections.reverse(result); return Matchers.contains(result); }
Example 2
Source File: WindowMatchers.java From beam with Apache License 2.0 | 5 votes |
public static <T> Matcher<WindowedValue<? extends T>> isSingleWindowedValue( Matcher<? super T> valueMatcher, Matcher<? super Instant> timestampMatcher, Matcher<? super BoundedWindow> windowMatcher) { return new WindowedValueMatcher<>( valueMatcher, timestampMatcher, Matchers.contains(windowMatcher), Matchers.anything()); }
Example 3
Source File: WindowMatchers.java From beam with Apache License 2.0 | 5 votes |
public static <T> Matcher<WindowedValue<? extends T>> isSingleWindowedValue( Matcher<? super T> valueMatcher, Matcher<? super Instant> timestampMatcher, Matcher<? super BoundedWindow> windowMatcher, Matcher<? super PaneInfo> paneInfoMatcher) { return new WindowedValueMatcher<>( valueMatcher, timestampMatcher, Matchers.contains(windowMatcher), paneInfoMatcher); }
Example 4
Source File: TypeCoercerTest.java From buck with Apache License 2.0 | 5 votes |
/** Traverse visits every element of an input value without coercing to the output type. */ @Test public void traverseShouldVisitEveryObject() throws NoSuchFieldException { Type type = TestFields.class.getField("stringMapOfLists").getGenericType(); @SuppressWarnings("unchecked") TypeCoercer<Object, ImmutableMap<String, ImmutableList<String>>> coercer = (TypeCoercer<Object, ImmutableMap<String, ImmutableList<String>>>) typeCoercerFactory.typeCoercerForType(TypeToken.of(type)); ImmutableMap<String, ImmutableList<String>> input = ImmutableMap.of( "foo", ImmutableList.of("//foo:bar", "//foo:baz"), "bar", ImmutableList.of(":bar", "//foo:foo")); TestTraversal traversal = new TestTraversal(); coercer.traverse(cellNameResolver, input, traversal); Matcher<Iterable<?>> matcher = Matchers.contains( ImmutableList.of( sameInstance((Object) input), is((Object) "foo"), sameInstance((Object) input.get("foo")), is((Object) "//foo:bar"), is((Object) "//foo:baz"), is((Object) "bar"), sameInstance((Object) input.get("bar")), is((Object) ":bar"), is((Object) "//foo:foo"))); assertThat(traversal.getObjects(), matcher); }
Example 5
Source File: MatcherUtils.java From sakai with Educational Community License v2.0 | 4 votes |
public static <T, R> Matcher<Iterable<? extends R>> containsUsingCustomMatcher(List<T> items, MatcherFunction<T, R> matcherFunction) { return Matchers.contains(createMatchers(items, matcherFunction)); }
Example 6
Source File: MatcherUtils.java From sakai with Educational Community License v2.0 | 4 votes |
public static <T, R> Matcher<Iterable<? extends R>> containsUsingCustomMatcher(List<T> items, MatcherFunction<T, R> matcherFunction) { return Matchers.contains(createMatchers(items, matcherFunction)); }