IsDateInMonth extends TypeSafeMatcher<Date> { @Override protected boolean matchesSafely(final Date date) { final int monthFromDate = CalendarUtils.month(date); switch (month) { case JANUARY: return monthFromDate == Month.JANUARY.id; case FEBRUARY: return monthFromDate == Month.FEBRUARY.id; case MARCH: return monthFromDate == Month.MARCH.id; case APRIL: return monthFromDate == Month.APRIL.id; case MAY: return monthFromDate == Month.MAY.id; case JUNE: return monthFromDate == Month.JUNE.id; case JULY: return monthFromDate == Month.JULY.id; case AUGUST: return monthFromDate == Month.AUGUST.id; case SEPTEMBER: return monthFromDate == Month.SEPTEMBER.id; case OCTOBER: return monthFromDate == Month.OCTOBER.id; case NOVEMBER: return monthFromDate == Month.NOVEMBER.id; default: return monthFromDate == Month.DECEMBER.id; } } IsDateInMonth(final int month); static Matcher<Date> january(); static Matcher<Date> february(); static Matcher<Date> march(); static Matcher<Date> april(); static Matcher<Date> may(); static Matcher<Date> june(); static Matcher<Date> july(); static Matcher<Date> august(); static Matcher<Date> september(); static Matcher<Date> october(); static Matcher<Date> november(); static Matcher<Date> december(); @Override void describeTo(final Description description);  }
@Test public void testMatchesSafely() throws Exception { BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <JANUARY>", february), januaryMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <FEBRUARY>", january), februaryMatcher, january); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <MARCH>", february), marchMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <APRIL>", february), aprilMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <MAY>", february), mayMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <JUNE>", february), juneMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <JULY>", february), julyMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <AUGUST>", february), augustMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <SEPTEMBER>", february), septemberMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <OCTOBER>", february), octoberMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <NOVEMBER>", february), novemberMatcher, february); BaseMatcherTest.assertHasMismatchDescription(String.format("<%s> has not id <DECEMBER>", february), decemberMatcher, february); }