IsDateInDay extends TypeSafeMatcher<Date> { @Override protected void describeMismatchSafely(final Date date, final Description mismatchDescription) { mismatchDescription.appendValue(date).appendText(" has not day ").appendValue(dayOfWeek); } IsDateInDay(final int weekDay); static Matcher<Date> sunday(); static Matcher<Date> monday(); static Matcher<Date> tuesday(); static Matcher<Date> wednesday(); static Matcher<Date> thursday(); static Matcher<Date> friday(); static Matcher<Date> saturday(); @Override void describeTo(final Description description);  }
@Test public void testDescribeMismatchSafely() throws Exception { BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <SUNDAY>", monday), sundayMatcher, monday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <MONDAY>", sunday), mondayMatcher, sunday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <TUESDAY>", monday), tuesdayMatcher, monday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <WEDNESDAY>", monday), wednesdayMatcher, monday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <THURSDAY>", monday), thursdayMatcher, monday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <FRIDAY>", monday), fridayMatcher, monday); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not day <SATURDAY>", monday), saturdayMatcher, monday); }