IsDateWithTime extends TypeSafeMatcher<Date> { @Override public void describeTo(final Description description) { description.appendText("a date with"); expectedMatching(description); } IsDateWithTime(final Integer hour, final Integer min, final Integer sec, final Integer millis);  IsDateWithTime(final Integer hour, final ClockPeriod clockPeriod, final Integer min, final Integer sec,
                          final Integer millis); static Matcher<Date> hasHour(final int hour); static Matcher<Date> hasHour(final int hour, final ClockPeriod clockPeriod); static Matcher<Date> hasMinute(final int minute); static Matcher<Date> hasSecond(final int second); static Matcher<Date> hasMillisecond(final int millisecond); static Matcher<Date> hasHourAndMin(final int hour, final int minute); static Matcher<Date> hasHourAndMin(final int hour, final ClockPeriod clockPeriod, final int minute); static Matcher<Date> hasHourMinAndSec(final int hour, final int minute, final int second); static Matcher<Date> hasHourMinAndSec(final int hour, final ClockPeriod clockPeriod, final int minute,
                                                 final int second); static Matcher<Date> hasHourMinSecAndMillis(final int hour, final int minute, final int second,
                                                       final int millisecond); static Matcher<Date> hasHourMinSecAndMillis(final int hour, final ClockPeriod clockPeriod, final int minute,
                                                       final int second, final int millisecond); @Override void describeTo(final Description description);  }
@Test public void testDescribeTo() throws Exception { BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d>", morningDateHour), IsDateWithTime.hasHour(morningDateHour)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d AM>", morningDateHour), IsDateWithTime.hasHour(morningDateHour, AM)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d PM>", eveningDateHour - LENGTH_12_HOUR_CLOCK), IsDateWithTime.hasHour(eveningDateHour - LENGTH_12_HOUR_CLOCK, PM)); BaseMatcherTest.assertIsDescribedTo(format("a date with minute <%d>", morningDateMinute), IsDateWithTime.hasMinute(morningDateMinute)); BaseMatcherTest.assertIsDescribedTo(format("a date with second <%d>", morningDateSecond), IsDateWithTime.hasSecond(morningDateSecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with millisecond <%d>", morningDateMillisecond), IsDateWithTime.hasMillisecond(morningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d>, minute <%d>", morningDateHour, morningDateMinute), IsDateWithTime.hasHourAndMin(morningDateHour, morningDateMinute)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d AM>, minute <%d>", morningDateHour, morningDateMinute), IsDateWithTime.hasHourAndMin(morningDateHour, AM, morningDateMinute)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d PM>, minute <%d>", eveningDateHour - LENGTH_12_HOUR_CLOCK, eveningDateMinute), IsDateWithTime.hasHourAndMin(eveningDateHour - LENGTH_12_HOUR_CLOCK, PM, eveningDateMinute)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d>, minute <%d>, second <%d>", morningDateHour, morningDateMinute, morningDateSecond), IsDateWithTime.hasHourMinAndSec(morningDateHour, morningDateMinute, morningDateSecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d AM>, minute <%d>, second <%d>", morningDateHour, morningDateMinute, morningDateSecond), IsDateWithTime.hasHourMinAndSec(morningDateHour, AM, morningDateMinute, morningDateSecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d PM>, minute <%d>, second <%d>", eveningDateHour - LENGTH_12_HOUR_CLOCK, eveningDateMinute, eveningDateSecond), IsDateWithTime.hasHourMinAndSec(eveningDateHour - LENGTH_12_HOUR_CLOCK, PM, eveningDateMinute, eveningDateSecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with hour <%d>, minute <%d>, second <%d>, millisecond <%d>", morningDateHour, morningDateMinute, morningDateSecond, morningDateMillisecond), IsDateWithTime.hasHourMinSecAndMillis(morningDateHour, morningDateMinute, morningDateSecond, morningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format( "a date with hour <%d AM>, minute <%d>, second <%d>, millisecond <%d>", morningDateHour, morningDateMinute, morningDateSecond, morningDateMillisecond), IsDateWithTime.hasHourMinSecAndMillis(morningDateHour, AM, morningDateMinute, morningDateSecond, morningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format( "a date with hour <%d PM>, minute <%d>, second <%d>, millisecond <%d>", eveningDateHour - LENGTH_12_HOUR_CLOCK, eveningDateMinute, eveningDateSecond, eveningDateMillisecond), IsDateWithTime.hasHourMinSecAndMillis(eveningDateHour - LENGTH_12_HOUR_CLOCK, PM, eveningDateMinute, eveningDateSecond, eveningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with minute <%d>, second <%d>, millisecond <%d>", morningDateMinute, morningDateSecond, morningDateMillisecond), new IsDateWithTime(null, morningDateMinute, morningDateSecond, morningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with second <%d>, millisecond <%d>", morningDateSecond, morningDateMillisecond), new IsDateWithTime(null, null, morningDateSecond, morningDateMillisecond)); BaseMatcherTest.assertIsDescribedTo(format("a date with minute <%d>, millisecond <%d>", morningDateMinute, morningDateMillisecond), new IsDateWithTime(null, morningDateMinute, null, morningDateMillisecond)); }