@Test public void reportsMismatchWithAReadableDescriptionForMultipleItems() { final Matcher<Iterable<Integer>> matcher = hasItems(3, 4); assertMismatchDescription("a collection containing <4> mismatches were: [was <1>, was <2>, was <3>]", matcher, asList(1, 2, 3)); }
@SafeVarargs public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers) { List<Matcher<? super Iterable<T>>> all = new ArrayList<>(itemMatchers.length); for (Matcher<? super T> elementMatcher : itemMatchers) { all.add(new IsIterableContaining<>(elementMatcher)); } return allOf(all); }
IsIterableContaining extends TypeSafeDiagnosingMatcher<Iterable<? super T>> { @SafeVarargs public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers) { List<Matcher<? super Iterable<T>>> all = new ArrayList<>(itemMatchers.length); for (Matcher<? super T> elementMatcher : itemMatchers) { all.add(new IsIterableContaining<>(elementMatcher)); } return allOf(all); } }
IsIterableContaining extends TypeSafeDiagnosingMatcher<Iterable<? super T>> { @SafeVarargs public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers) { List<Matcher<? super Iterable<T>>> all = new ArrayList<>(itemMatchers.length); for (Matcher<? super T> elementMatcher : itemMatchers) { all.add(new IsIterableContaining<>(elementMatcher)); } return allOf(all); } IsIterableContaining(Matcher<? super T> elementMatcher); }
IsIterableContaining extends TypeSafeDiagnosingMatcher<Iterable<? super T>> { @SafeVarargs public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers) { List<Matcher<? super Iterable<T>>> all = new ArrayList<>(itemMatchers.length); for (Matcher<? super T> elementMatcher : itemMatchers) { all.add(new IsIterableContaining<>(elementMatcher)); } return allOf(all); } IsIterableContaining(Matcher<? super T> elementMatcher); @Override void describeTo(Description description); static Matcher<Iterable<? super T>> hasItem(Matcher<? super T> itemMatcher); static Matcher<Iterable<? super T>> hasItem(T item); @SafeVarargs static Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers); @SafeVarargs static Matcher<Iterable<T>> hasItems(T... items); }
IsIterableContaining extends TypeSafeDiagnosingMatcher<Iterable<? super T>> { @SafeVarargs public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers) { List<Matcher<? super Iterable<T>>> all = new ArrayList<>(itemMatchers.length); for (Matcher<? super T> elementMatcher : itemMatchers) { all.add(new IsIterableContaining<>(elementMatcher)); } return allOf(all); } IsIterableContaining(Matcher<? super T> elementMatcher); @Override void describeTo(Description description); static Matcher<Iterable<? super T>> hasItem(Matcher<? super T> itemMatcher); static Matcher<Iterable<? super T>> hasItem(T item); @SafeVarargs static Matcher<Iterable<T>> hasItems(Matcher<? super T>... itemMatchers); @SafeVarargs static Matcher<Iterable<T>> hasItems(T... items);  }