### Question:
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();  }### Answer:
@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); }
@Test @SuppressWarnings("unchecked") public void testNoMatchFirst() throws Exception { when(firstMatcher.matches(first)).thenReturn(false); assertThat(new CollectionOneToOneMatcher<Object>(Arrays.asList(firstMatcher, secondMatcher)).matches(iterable), is(false)); verify(firstMatcher).matches(first); verifyNoMoreInteractions(firstMatcher); verifyZeroInteractions(secondMatcher); }
@Test @SuppressWarnings("unchecked") public void testNoMatchSecond() throws Exception { when(firstMatcher.matches(first)).thenReturn(true); when(secondMatcher.matches(second)).thenReturn(false); assertThat(new CollectionOneToOneMatcher<Object>(Arrays.asList(firstMatcher, secondMatcher)).matches(iterable), is(false)); verify(firstMatcher).matches(first); verifyNoMoreInteractions(firstMatcher); verify(secondMatcher).matches(second); verifyNoMoreInteractions(secondMatcher); }
@Test @SuppressWarnings("unchecked") public void testNoMatchSize() throws Exception { assertThat(new CollectionOneToOneMatcher<Object>(Arrays.asList(firstMatcher, secondMatcher)).matches(Collections.singletonList(firstMatcher)), is(false)); verifyZeroInteractions(firstMatcher); verifyZeroInteractions(secondMatcher); }