IsDate extends TypeSafeMatcher<Date> { @Override public void describeTo(final Description description) { description.appendText("a date with"); expectedMatching(description); } IsDate(final Integer year, final Integer month, final Integer day); static Matcher<Date> hasYear(final int year); static Matcher<Date> hasMonth(final int month); static Matcher<Date> hasDay(final int day); static Matcher<Date> hasYearAndMonth(final int year, final int month); static Matcher<Date> hasYearMonthAndDay(final int year, final int month, final int day); @Override void describeTo(final Description description);  }
@Test public void testDescribeTo() throws Exception { BaseMatcherTest.assertIsDescribedTo(format("a date with year <%d>", dateYear), IsDate.hasYear(dateYear)); BaseMatcherTest.assertIsDescribedTo(format("a date with id <%d>", dateMonth), IsDate.hasMonth(dateMonth)); BaseMatcherTest.assertIsDescribedTo(format("a date with day <%d>", dateDay), IsDate.hasDay(dateDay)); BaseMatcherTest.assertIsDescribedTo(format("a date with year <%d>, id <%d>", dateYear, dateMonth), IsDate.hasYearAndMonth(dateYear, dateMonth)); BaseMatcherTest.assertIsDescribedTo(format("a date with year <%d>, id <%d>, day <%d>", dateYear, dateMonth, dateDay), IsDate.hasYearMonthAndDay(dateYear, dateMonth, dateDay)); BaseMatcherTest.assertIsDescribedTo(format("a date with year <%d>, day <%d>", dateYear, dateDay), new IsDate(dateYear, null, dateDay)); BaseMatcherTest.assertIsDescribedTo(format("a date with id <%d>, day <%d>", dateMonth, dateDay), new IsDate(null, dateMonth, dateDay)); }