### Question:
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();  }### Answer:
@Test public void testMatch() throws Exception { when(elementMatcher.matches(element)).thenReturn(true); assertThat(new CollectionElementMatcher<Object>(1, elementMatcher).matches(iterable), is(true)); verify(elementMatcher).matches(element); verifyNoMoreInteractions(elementMatcher); }
@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); }
@Test public void testNoMatchIndex() throws Exception { assertThat(new CollectionElementMatcher<Object>(2, elementMatcher).matches(iterable), is(false)); verifyZeroInteractions(elementMatcher); }