@Test @SuppressWarnings("unchecked") public void testMatch() throws Exception { when(firstMatcher.matches(first)).thenReturn(true); when(secondMatcher.matches(second)).thenReturn(true); assertThat(new CollectionOneToOneMatcher<Object>(Arrays.asList(firstMatcher, secondMatcher)).matches(iterable), is(true)); verify(firstMatcher).matches(first); verifyNoMoreInteractions(firstMatcher); verify(secondMatcher).matches(second); verifyNoMoreInteractions(secondMatcher); }
public boolean matches(Iterable<? extends T> target) { if ((target instanceof Collection) && ((Collection<?>) target).size() != matchers.size()) { return false; } Iterator<? extends ElementMatcher<? super T>> iterator = matchers.iterator(); for (T value : target) { if (!iterator.hasNext() || !iterator.next().matches(value)) { return false; } } return true; }
CollectionOneToOneMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { if ((target instanceof Collection) && ((Collection<?>) target).size() != matchers.size()) { return false; } Iterator<? extends ElementMatcher<? super T>> iterator = matchers.iterator(); for (T value : target) { if (!iterator.hasNext() || !iterator.next().matches(value)) { return false; } } return true; } }
CollectionOneToOneMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { if ((target instanceof Collection) && ((Collection<?>) target).size() != matchers.size()) { return false; } Iterator<? extends ElementMatcher<? super T>> iterator = matchers.iterator(); for (T value : target) { if (!iterator.hasNext() || !iterator.next().matches(value)) { return false; } } return true; } CollectionOneToOneMatcher(List<? extends ElementMatcher<? super T>> matchers); }
CollectionOneToOneMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { if ((target instanceof Collection) && ((Collection<?>) target).size() != matchers.size()) { return false; } Iterator<? extends ElementMatcher<? super T>> iterator = matchers.iterator(); for (T value : target) { if (!iterator.hasNext() || !iterator.next().matches(value)) { return false; } } return true; } CollectionOneToOneMatcher(List<? extends ElementMatcher<? super T>> matchers); boolean matches(Iterable<? extends T> target); @Override String toString(); }
CollectionOneToOneMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { if ((target instanceof Collection) && ((Collection<?>) target).size() != matchers.size()) { return false; } Iterator<? extends ElementMatcher<? super T>> iterator = matchers.iterator(); for (T value : target) { if (!iterator.hasNext() || !iterator.next().matches(value)) { return false; } } return true; } CollectionOneToOneMatcher(List<? extends ElementMatcher<? super T>> matchers); boolean matches(Iterable<? extends T> target); @Override String toString();  }