/** * Checks that the {@code Iterable} contains elements that match the provided matchers, in any * order. * * <p>Returns this {@code IterableAssert}. */ @SafeVarargs final PCollectionContentsAssert<T> containsInAnyOrder( SerializableMatcher<? super T>... elementMatchers) { return satisfies(SerializableMatchers.containsInAnyOrder(elementMatchers)); }
@Test public void testContainsInAnyOrderSerializable() throws Exception { assertThat( ImmutableList.of(2, 1, 3), SerializableUtils.ensureSerializable(containsInAnyOrder(1, 2, 3))); }
@Test public void testKvMatcherGBKLikeFailure() throws Exception { AssertionError exc = assertionShouldFail( () -> assertThat( KV.of("key", ImmutableList.of(1, 2, 3)), SerializableMatchers.<String, Iterable<Integer>>kv( anything(), containsInAnyOrder(1, 2, 3, 4)))); assertThat(exc.getMessage(), Matchers.containsString("value did not match")); }
@Test public void testKvMatcherGBKLikeSuccess() throws Exception { assertThat( KV.of("key", ImmutableList.of(1, 2, 3)), SerializableMatchers.<Object, Iterable<Integer>>kv( anything(), containsInAnyOrder(3, 2, 1))); }
@Test public void testContainsInAnyOrderNotSerializable() throws Exception { assertThat( ImmutableList.of(new NotSerializableClass()), SerializableUtils.ensureSerializable( containsInAnyOrder(new NotSerializableClassCoder(), new NotSerializableClass()))); }