IsDateWithTime extends TypeSafeMatcher<Date> { public static Matcher<Date> hasSecond(final int second) { return new IsDateWithTime(null, null, second, null); } 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 testGivenValidSecondWhenMatchesIsCalledThenTrueIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasSecond(morningDateSecond); final boolean dateMatches = isWithTimeMatcher.matches(morningDate); assertThat(format("Date %s should match", morningDate), dateMatches, is(true)); }
@Test public void testGivenNonValidSecondWhenMatchesIsCalledThenFalseIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasSecond(morningDateSecond); final boolean dateMatches = isWithTimeMatcher.matches(eveningDate); assertThat(format("Date %s should not match", eveningDate), dateMatches, is(false)); }