ConjunctionMatcher extends TypeSafeDiagnosingMatcher<T> { @Override public void describeTo(Description description) { if (matchers.isEmpty()) { description.appendText(compositeDescription != null ? compositeDescription : "anything"); } else { String start = (compositeDescription != null) ? compositeDescription + " " : ""; description.appendList(start, SEPARATOR, "", matchers); } } ConjunctionMatcher(String compositeDescription, Iterable<Matcher<? super T>> matchers); ConjunctionMatcher<T> and(Matcher<? super T> matcher); @Override void describeTo(Description description);  }
@Test public void describeToWhenMatcherDescribesMatcher() { StringDescription description = new StringDescription(); compose("x", anything("y")).describeTo(description); assertThat(description.toString(), is("x y")); }
@Test public void describeToWhenEmptyMatchersOmitsMatchers() { StringDescription description = new StringDescription(); compose("x", emptyList()).describeTo(description); assertThat(description.toString(), is("x")); }
@Test public void describeToWhenNoDescriptionOmitsPrefix() { StringDescription description = new StringDescription(); compose(anything("x")).describeTo(description); assertThat(description.toString(), is("x")); }
@Test public void describeToWhenNoDescriptionAndEmptyMatchersDescribesAnything() { StringDescription description = new StringDescription(); compose(emptyList()).describeTo(description); assertThat(description.toString(), is("anything")); }