IsDateWithTime extends TypeSafeMatcher<Date> { public static Matcher<Date> hasHour(final int hour) { return new IsDateWithTime(hour, null, null, 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 testGivenValidHourWhenMatchesIsCalledThenTrueIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(morningDateHour); final boolean dateMatches = isWithTimeMatcher.matches(morningDate); BaseMatcherTest.assertMatches(dateMatches); }
@Test public void testGivenValidHourAMWhenMatchesIsCalledThenTrueIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(morningDateHour, AM); final boolean dateMatches = isWithTimeMatcher.matches(morningDate); BaseMatcherTest.assertMatches(dateMatches); }
@Test public void testGivenValidHourPMWhenMatchesIsCalledThenTrueIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(eveningDateHour - LENGTH_12_HOUR_CLOCK, PM); final boolean dateMatches = isWithTimeMatcher.matches(eveningDate); BaseMatcherTest.assertMatches(dateMatches); }
@Test public void testGivenNonValidHourWhenMatchesIsCalledThenFalseIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(morningDateHour); final boolean dateMatches = isWithTimeMatcher.matches(eveningDate); assertThat(format("Date %s should not match", eveningDate), dateMatches, is(false)); }
@Test public void testGivenNonValidHourAMWhenMatchesIsCalledThenFalseIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(morningDateHour, AM); final boolean dateMatches = isWithTimeMatcher.matches(eveningDate); assertThat(format("Date %s should not match", eveningDate), dateMatches, is(false)); }
@Test public void testGivenNonValidHourPMWhenMatchesIsCalledThenFalseIsReturned() throws Exception { isWithTimeMatcher = IsDateWithTime.hasHour(morningDateHour, PM); final boolean dateMatches = isWithTimeMatcher.matches(morningDate); assertThat(format("Date %s should not match", eveningDate), dateMatches, is(false)); }