@Test public void testNoMatch() throws Exception { when(elementMatcher.matches(element)).thenReturn(false); assertThat(new CollectionElementMatcher<Object>(1, elementMatcher).matches(iterable), is(false)); verify(elementMatcher).matches(element); verifyNoMoreInteractions(elementMatcher); }
public boolean matches(Iterable<? extends T> target) { Iterator<? extends T> iterator = target.iterator(); for (int index = 0; index < this.index; index++) { if (iterator.hasNext()) { iterator.next(); } else { return false; } } return iterator.hasNext() && matcher.matches(iterator.next()); }
CollectionElementMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { Iterator<? extends T> iterator = target.iterator(); for (int index = 0; index < this.index; index++) { if (iterator.hasNext()) { iterator.next(); } else { return false; } } return iterator.hasNext() && matcher.matches(iterator.next()); } }
CollectionElementMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { Iterator<? extends T> iterator = target.iterator(); for (int index = 0; index < this.index; index++) { if (iterator.hasNext()) { iterator.next(); } else { return false; } } return iterator.hasNext() && matcher.matches(iterator.next()); } CollectionElementMatcher(int index, ElementMatcher<? super T> matcher); }
CollectionElementMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { Iterator<? extends T> iterator = target.iterator(); for (int index = 0; index < this.index; index++) { if (iterator.hasNext()) { iterator.next(); } else { return false; } } return iterator.hasNext() && matcher.matches(iterator.next()); } CollectionElementMatcher(int index, ElementMatcher<? super T> matcher); boolean matches(Iterable<? extends T> target); @Override String toString(); }
CollectionElementMatcher extends ElementMatcher.Junction.AbstractBase<Iterable<? extends T>> { public boolean matches(Iterable<? extends T> target) { Iterator<? extends T> iterator = target.iterator(); for (int index = 0; index < this.index; index++) { if (iterator.hasNext()) { iterator.next(); } else { return false; } } return iterator.hasNext() && matcher.matches(iterator.next()); } CollectionElementMatcher(int index, ElementMatcher<? super T> matcher); boolean matches(Iterable<? extends T> target); @Override String toString();  }