diff --git a/src/main/java/org/exparity/hamcrest/date/OffsetDateTimeMatchers.java b/src/main/java/org/exparity/hamcrest/date/OffsetDateTimeMatchers.java
new file mode 100644
index 0000000..195609d
--- /dev/null
+++ b/src/main/java/org/exparity/hamcrest/date/OffsetDateTimeMatchers.java
@@ -0,0 +1,990 @@
+package org.exparity.hamcrest.date;
+
+import static java.time.DayOfWeek.*;
+import static java.time.Month.*;
+import static org.exparity.hamcrest.date.core.TemporalConverters.*;
+import static org.exparity.hamcrest.date.core.TemporalFunctions.OFFSETDATETIME;
+import static org.exparity.hamcrest.date.core.TemporalProviders.*;
+
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.Month;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.OffsetDateTime;
+import java.time.temporal.ChronoField;
+import java.time.temporal.ChronoUnit;
+
+import org.exparity.hamcrest.date.core.DateMatcher;
+import org.exparity.hamcrest.date.core.IsAfter;
+import org.exparity.hamcrest.date.core.IsBefore;
+import org.exparity.hamcrest.date.core.IsDayOfMonth;
+import org.exparity.hamcrest.date.core.IsDayOfWeek;
+import org.exparity.hamcrest.date.core.IsFirstDayOfMonth;
+import org.exparity.hamcrest.date.core.IsHour;
+import org.exparity.hamcrest.date.core.IsLastDayOfMonth;
+import org.exparity.hamcrest.date.core.IsLeapYear;
+import org.exparity.hamcrest.date.core.IsMaximum;
+import org.exparity.hamcrest.date.core.IsMinimum;
+import org.exparity.hamcrest.date.core.IsMinute;
+import org.exparity.hamcrest.date.core.IsMonth;
+import org.exparity.hamcrest.date.core.IsSame;
+import org.exparity.hamcrest.date.core.IsSameDay;
+import org.exparity.hamcrest.date.core.IsSameOrAfter;
+import org.exparity.hamcrest.date.core.IsSameOrBefore;
+import org.exparity.hamcrest.date.core.IsSecond;
+import org.exparity.hamcrest.date.core.IsWithin;
+import org.exparity.hamcrest.date.core.IsYear;
+import org.exparity.hamcrest.date.core.types.Interval;
+import org.hamcrest.Factory;
+
+/**
+ * Static factory for creating {@link org.hamcrest.Matcher} instances for comparing {@link OffsetDateTime} instances
+ *
+ * @author Stewart Bissett
+ */
+public abstract class OffsetDateTimeMatchers {
+
+ /**
+ * Creates a matcher that matches when the examined date is after the reference date
+ *
+ * For example:
+ *
+ *
+ * MatcherAssert.assertThat(myDate, after(OffsetDateTime.now()));
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher after(final OffsetDateTime date) {
+ return new IsAfter<>(OFFSETDATETIME_AS_OFFSETDATETIME, offsetDateTime(date), OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is after the end of the reference year
+ *
+ * For example:
+ *
+ *
+ * MatcherAssert.assertThat(myDate, after(2012, Month.MAY, 12));
+ *
+ *
+ * @param year the year against which the examined date is checked
+ * @param month the month against which the examined date is checked
+ * @param dayOfMonth the day of the month against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanos of the second
+ */
+ public static DateMatcher after(final int year,
+ final Month month,
+ final int dayOfMonth,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return after(OffsetDateTime.of(year, month.getValue(), dayOfMonth, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is before the reference date
+ *
+ * For example:
+ *
+ *
+ * MatcherAssert.assertThat(myDate, before(OffsetDateTime.now()));
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher before(final OffsetDateTime date) {
+ return new IsBefore<>(OFFSETDATETIME_AS_OFFSETDATETIME, offsetDateTime(date), OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is before the end of the reference year
+ *
+ * For example:
+ *
+ *
+ * MatcherAssert.assertThat(myDate, before(2012, Month.MAY, 12));
+ *
+ *
+ * @param year the year against which the examined date is checked
+ * @param month the month against which the examined date is checked
+ * @param dayOfMonth the day of the month against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanos of the second
+ */
+ public static DateMatcher before(final int year,
+ final Month month,
+ final int dayOfMonth,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return before(OffsetDateTime.of(year, month.getValue(), dayOfMonth, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the year as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDay(OffsetDateTime.now()));
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameDay(final OffsetDateTime date) {
+ return new IsSameDay<>(OFFSETDATETIME_AS_LOCALDATE, localDate(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the year as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDay(LocalDate.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher isDay(LocalDate date) {
+ return new IsSameDay<>(OFFSETDATETIME_AS_LOCALDATE, localDate(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the year as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDay(2012, Month.JAN, 1))
+ *
+ *
+ * @param dayOfMonth the reference day of the month against which the examined date is checked
+ * @param month the reference month against which the examined date is checked
+ * @param year the reference year against which the examined date is checked
+ */
+ public static DateMatcher isDay(final int year, final Month month, final int dayOfMonth) {
+ return isDay(LocalDate.of(year, month, dayOfMonth));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the year as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDay(2012, Month.JAN, 1))
+ *
+ *
+ * @param dayOfMonth the reference day of the month against which the examined date is checked
+ * @param month the reference month against which the examined date is checked
+ * @param year the reference year against which the examined date is checked
+ */
+ public static DateMatcher isDay(final int year, final Month month, final int dayOfMonth, final ZoneId zone) {
+ return isDay(LocalDate.of(year, month, dayOfMonth)).atZone(zone);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is at the same instant as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameInstant(OffsetDateTime.now()));
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameInstant(final OffsetDateTime date) {
+ return new IsSame<>(OFFSETDATETIME_AS_OFFSETDATETIME, offsetDateTime(date), OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is at the same specified instance down to the second
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameInstant(2012, Month.JAN, 1, 3, 15, 0))
+ *
+ *
+ * @param dayOfMonth the reference day of the month against which the examined date is checked
+ * @param month the reference month against which the examined date is checked
+ * @param year the reference year against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanosecond of the second
+ * @param tz the timezone
+ */
+ public static DateMatcher isInstant(final int year,
+ final Month month,
+ final int dayOfMonth,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return sameInstant(OffsetDateTime.of(year, month.getValue(), dayOfMonth, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is at the same instant or before the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameOrBefore(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameOrBefore(final OffsetDateTime date) {
+ return new IsSameOrBefore<>(OFFSETDATETIME_AS_OFFSETDATETIME, offsetDateTime(date), OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day or before the start of the reference
+ * date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameOrBefore(2012, Months.MAY, 12, 11, 59, 59, ZoneId.systemDefault()));
+ *
+ *
+ * @param year the year against which the examined date is checked
+ * @param month the month against which the examined date is checked
+ * @param day the day of the month against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanosecond of the second
+ * @param tz the time zone of the date to check against
+ */
+ @Factory
+ public static DateMatcher sameOrBefore(final int year,
+ final Month month,
+ final int day,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return sameOrBefore(OffsetDateTime.of(year, month.getValue(), day, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is at the same instant or after the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameOrAfter(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameOrAfter(final OffsetDateTime date) {
+ return new IsSameOrAfter<>(OFFSETDATETIME_AS_OFFSETDATETIME, offsetDateTime(date), OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day or before the start of the reference
+ * date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameOrAfter(2012, Months.MAY, 12, 11, 59, 59, ZoneId.systemDefault()));
+ *
+ *
+ * @param year the year against which the examined date is checked
+ * @param month the month against which the examined date is checked
+ * @param day the day of the month against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanosecond of the second
+ * @param tz the time zone of the date to check against
+ */
+ @Factory
+ public static DateMatcher sameOrAfter(final int year,
+ final Month month,
+ final int day,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return sameOrAfter(OffsetDateTime.of(year, month.getValue(), day, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same month as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameMonth(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameMonthOfYear(final OffsetDateTime date) {
+ return new IsMonth<>(OFFSETDATETIME_AS_MONTH, month(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the month as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDayOfMonth(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameDayOfMonth(final OffsetDateTime date) {
+ return new IsDayOfMonth<>(OFFSETDATETIME_AS_DAYOFMONTH, dayOfMonth(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the expected day of the month
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isDayOfMonth(4))
+ *
+ *
+ * @param dayOfMonth the expected day of the month
+ */
+ public static DateMatcher isDayOfMonth(final int dayOfMonth) {
+ return new IsDayOfMonth<>(OFFSETDATETIME_AS_DAYOFMONTH, dayOfMonth(dayOfMonth));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same year as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameYear(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameYear(final OffsetDateTime date) {
+ return isYear(date.getYear());
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same year as the reference year
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameYear(2013))
+ *
+ *
+ * @param year the reference year against which the examined date is checked
+ */
+ public static DateMatcher isYear(final int year) {
+ return new IsYear<>(OFFSETDATETIME_AS_YEAR, year(year));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is within a defined period the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, within(10, TimeUnit.DAYS, Moments.today()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher within(final long period,
+ final ChronoUnit unit,
+ final OffsetDateTime date) {
+ return new IsWithin<>(Interval.of(period, unit),
+ OFFSETDATETIME_AS_OFFSETDATETIME,
+ offsetDateTime(date),
+ OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is within a given period of the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, within(5, TimeUnit.DAYS, 2012, Months.MAY, 12));
+ *
+ *
+ * @param period the timeunit interval the examined date should be with
+ * @param unit the timeunit to define the length of the period
+ * @param year the year against which the examined date is checked
+ * @param month the month against which the examined date is checked
+ * @param dayofMonth the day of the month against which the examined date is checked
+ * @param hour the hour of the day
+ * @param minute the minute of the hour
+ * @param second the second of the minute
+ * @param nanos the nanoseconds of the second
+ * @param tz the time zone of the reference date
+ */
+ public static DateMatcher within(final long period,
+ final ChronoUnit unit,
+ final int year,
+ final Month month,
+ final int dayofMonth,
+ final int hour,
+ final int minute,
+ final int second,
+ final int nanos,
+ final ZoneOffset tz) {
+ return within(period,
+ unit,
+ OffsetDateTime.of(year, month.getValue(), dayofMonth, hour, minute, second, nanos, tz));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is yesterday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isToday());
+ *
+ */
+ public static DateMatcher isYesterday() {
+ return sameDay(OffsetDateTime.now().plusDays(-1));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is today
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isToday());
+ *
+ */
+ public static DateMatcher isToday() {
+ return sameDay(OffsetDateTime.now());
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is tomorrow
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isTomorrow());
+ *
+ */
+ public static DateMatcher isTomorrow() {
+ return sameDay(OffsetDateTime.now().plusDays(1));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the week as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameDayOfWeek(LocalDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameDayOfWeek(final OffsetDateTime date) {
+ return isDayOfWeek(DayOfWeek.from(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the week as the supplied day
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMonday());
+ *
+ */
+ public static DateMatcher isDayOfWeek(final DayOfWeek dayOfWeek) {
+ return new IsDayOfWeek<>(OFFSETDATETIME_AS_DAYOFWEEK, daysOfWeek(dayOfWeek));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same day of the week as any of the supplied days
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMonday());
+ *
+ */
+ public static DateMatcher isDayOfWeek(final DayOfWeek... daysOfWeek) {
+ return new IsDayOfWeek<>(OFFSETDATETIME_AS_DAYOFWEEK, daysOfWeek(daysOfWeek));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a monday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMonday());
+ *
+ */
+ public static DateMatcher isMonday() {
+ return isDayOfWeek(MONDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a tuesday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isTuesday());
+ *
+ */
+ public static DateMatcher isTuesday() {
+ return isDayOfWeek(TUESDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a wednesday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isWednesday());
+ *
+ */
+ public static DateMatcher isWednesday() {
+ return isDayOfWeek(WEDNESDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a thursday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isThursday());
+ *
+ */
+ public static DateMatcher isThursday() {
+ return isDayOfWeek(THURSDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a friday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isFriday());
+ *
+ */
+ public static DateMatcher isFriday() {
+ return isDayOfWeek(FRIDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a saturday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isSaturday());
+ *
+ */
+ public static DateMatcher isSaturday() {
+ return isDayOfWeek(SATURDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a sunday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isSunday());
+ *
+ */
+ public static DateMatcher isSunday() {
+ return isDayOfWeek(SUNDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a weekday
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isWeekday());
+ *
+ */
+ public static DateMatcher isWeekday() {
+ return isDayOfWeek(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on a weekend
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isWeekend());
+ *
+ */
+ public static DateMatcher isWeekend() {
+ return isDayOfWeek(SATURDAY, SUNDAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the first day of the month
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isFirstDayOfMonth());
+ *
+ */
+ public static DateMatcher isFirstDayOfMonth() {
+ return new IsFirstDayOfMonth<>(OFFSETDATETIME_AS_OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the maximum value of the given date part in its
+ * period
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMaximumDayOfMonth(ChronoField.DAY_OF_MONTH));
+ *
+ *
+ * @param field the temporal field to check
+ */
+ public static DateMatcher isMinimum(final ChronoField field) {
+ return new IsMinimum<>(OFFSETDATETIME_AS_OFFSETDATETIME, field);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the first day of the month
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isFirstDayOfMonth());
+ *
+ */
+ public static DateMatcher isLastDayOfMonth() {
+ return new IsLastDayOfMonth<>(OFFSETDATETIME_AS_OFFSETDATETIME);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the maximum value of the given date part in its
+ * period
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMaximum(ChronoField.DAY_OF_MONTH));
+ *
+ *
+ * @param field the temporal field to check
+ */
+ public static DateMatcher isMaximum(final ChronoField field) {
+ return new IsMaximum<>(OFFSETDATETIME_AS_OFFSETDATETIME, field);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in the expected month
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMonth(Month.AUGUST));
+ *
+ */
+ public static DateMatcher isMonth(final Month month) {
+ return new IsMonth<>(OFFSETDATETIME_AS_MONTH, month(month));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in January
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isJanuary());
+ *
+ */
+ public static DateMatcher isJanuary() {
+ return isMonth(JANUARY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in February
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isFebruary());
+ *
+ */
+ public static DateMatcher isFebruary() {
+ return isMonth(FEBRUARY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in March
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMarch());
+ *
+ */
+ public static DateMatcher isMarch() {
+ return isMonth(MARCH);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in April
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isApril());
+ *
+ */
+ public static DateMatcher isApril() {
+ return isMonth(APRIL);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in May
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMay());
+ *
+ */
+ public static DateMatcher isMay() {
+ return isMonth(MAY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in June
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isJune());
+ *
+ */
+ public static DateMatcher isJune() {
+ return isMonth(JUNE);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in July
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isJuly());
+ *
+ */
+ public static DateMatcher isJuly() {
+ return isMonth(JULY);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in August
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isAugust());
+ *
+ */
+ public static DateMatcher isAugust() {
+ return isMonth(AUGUST);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in September
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isSeptember());
+ *
+ */
+ public static DateMatcher isSeptember() {
+ return isMonth(SEPTEMBER);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in October
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isOctober());
+ *
+ */
+ public static DateMatcher isOctober() {
+ return isMonth(OCTOBER);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in November
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isNovember());
+ *
+ */
+ public static DateMatcher isNovember() {
+ return isMonth(NOVEMBER);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is in December
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isDecember());
+ *
+ */
+ public static DateMatcher isDecember() {
+ return isMonth(DECEMBER);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is a leap year
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isLeapYear());
+ *
+ */
+ public static DateMatcher isLeapYear() {
+ return new IsLeapYear<>(OFFSETDATETIME_AS_YEAR);
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the expected hour (0-23)
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isHour(12));
+ *
+ *
+ * @param hour the hour of the day (0-23)
+ */
+ public static DateMatcher isHour(final int hour) {
+ return new IsHour<>(OFFSETDATETIME_AS_HOUR, hour(hour));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same hour as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameHourOfDay(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameHourOfDay(final OffsetDateTime date) {
+ return new IsHour<>(OFFSETDATETIME_AS_HOUR, hour(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the expected minute (0-59)
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isMinute(12));
+ *
+ *
+ * @param minute the minute of the day (0-59)
+ */
+ public static DateMatcher isMinute(final int minute) {
+ return new IsMinute<>(OFFSETDATETIME_AS_MINUTE, minute(minute));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same minute as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameMinuteOfHour(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameMinuteOfHour(final OffsetDateTime date) {
+ return new IsMinute<>(OFFSETDATETIME_AS_MINUTE, minute(date));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the expected second (0-59)
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, isSecond(12));
+ *
+ *
+ * @param second the second of the day (0-59)
+ */
+ public static DateMatcher isSecond(final int second) {
+ return new IsSecond<>(OFFSETDATETIME_AS_SECOND, second(second));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined date is on the same second as the reference date
+ *
+ * For example:
+ *
+ *
+ * assertThat(myDate, sameSecondOfMinute(OffsetDateTime.now()))
+ *
+ *
+ * @param date the reference date against which the examined date is checked
+ */
+ public static DateMatcher sameSecondOfMinute(final OffsetDateTime date) {
+ return new IsSecond<>(OFFSETDATETIME_AS_SECOND, second(date));
+ }
+}
diff --git a/src/main/java/org/exparity/hamcrest/date/core/DateMatcher.java b/src/main/java/org/exparity/hamcrest/date/core/DateMatcher.java
index f8478b4..e78a613 100644
--- a/src/main/java/org/exparity/hamcrest/date/core/DateMatcher.java
+++ b/src/main/java/org/exparity/hamcrest/date/core/DateMatcher.java
@@ -1,6 +1,7 @@
package org.exparity.hamcrest.date.core;
import java.time.ZoneId;
+import java.time.ZoneOffset;
import org.hamcrest.TypeSafeDiagnosingMatcher;
@@ -21,4 +22,14 @@ public abstract class DateMatcher extends TypeSafeDiagnosingMatcher {
*/
public abstract DateMatcher atZone(ZoneId zone);
+ /**
+ * Creates a copy of this matcher using a specific time offset.
+ *
+ * @param offset the new time offset
+ * @return a copy of this matcher based on the new time offset
+ */
+ public DateMatcher atOffset(ZoneOffset offset) {
+ return atZone(ZoneId.of(offset.getId()));
+ }
+
}
diff --git a/src/main/java/org/exparity/hamcrest/date/core/TemporalConverters.java b/src/main/java/org/exparity/hamcrest/date/core/TemporalConverters.java
index c084889..66ae0c2 100644
--- a/src/main/java/org/exparity/hamcrest/date/core/TemporalConverters.java
+++ b/src/main/java/org/exparity/hamcrest/date/core/TemporalConverters.java
@@ -6,6 +6,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
+import java.time.OffsetDateTime;
import java.time.Year;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAccessor;
@@ -124,7 +125,7 @@ public class TemporalConverters {
public static TemporalConverter LOCALDATETIME_AS_SECOND = (date, zone) -> Second.from(date);
/**
- * LocalDateTime Converters
+ * ZonedDateTime Converters
*/
public static TemporalConverter ZONEDDATETIME_AS_ZONEDDATETIME = (date, zone) -> date.withZoneSameInstant(zone);
public static TemporalConverter ZONEDDATETIME_AS_LOCALDATE = (date, zone) -> ZONEDDATETIME_AS_ZONEDDATETIME.apply(date, zone).toLocalDate();
@@ -140,4 +141,17 @@ public class TemporalConverters {
* DayOfWeek Converters
*/
public static TemporalConverter DAYOFWEEK_TO_DAYOFWEEK = (date, zone) -> date;
+
+ /**
+ * {@link OffsetDateTime} Converters
+ */
+ public static TemporalConverter OFFSETDATETIME_AS_OFFSETDATETIME = (date, zone) -> date.withOffsetSameInstant(zone.getRules().getOffset(date.toLocalDateTime()));
+ public static TemporalConverter OFFSETDATETIME_AS_LOCALDATE = (date, zone) -> OFFSETDATETIME_AS_OFFSETDATETIME.apply(date, zone).toLocalDate();
+ public static TemporalConverter OFFSETDATETIME_AS_YEAR = (date, zone) -> Year.from(OFFSETDATETIME_AS_LOCALDATE.apply(date, zone));
+ public static TemporalConverter OFFSETDATETIME_AS_MONTH = (date, zone) -> OFFSETDATETIME_AS_LOCALDATE.apply(date, zone).getMonth();
+ public static TemporalConverter OFFSETDATETIME_AS_DAYOFMONTH = (date, zone) -> DayOfMonth.from(OFFSETDATETIME_AS_LOCALDATE.apply(date, zone));
+ public static TemporalConverter OFFSETDATETIME_AS_DAYOFWEEK = (date, zone) -> OFFSETDATETIME_AS_LOCALDATE.apply(date, zone).getDayOfWeek();
+ public static TemporalConverter OFFSETDATETIME_AS_HOUR = (date, zone) -> Hour.from(OFFSETDATETIME_AS_OFFSETDATETIME.apply(date, zone));
+ public static TemporalConverter OFFSETDATETIME_AS_MINUTE = (date, zone) -> Minute.from(OFFSETDATETIME_AS_OFFSETDATETIME.apply(date, zone));
+ public static TemporalConverter OFFSETDATETIME_AS_SECOND = (date, zone) -> Second.from(OFFSETDATETIME_AS_OFFSETDATETIME.apply(date, zone));
}
diff --git a/src/main/java/org/exparity/hamcrest/date/core/TemporalFunctions.java b/src/main/java/org/exparity/hamcrest/date/core/TemporalFunctions.java
index 5b9b2d3..877a16b 100644
--- a/src/main/java/org/exparity/hamcrest/date/core/TemporalFunctions.java
+++ b/src/main/java/org/exparity/hamcrest/date/core/TemporalFunctions.java
@@ -4,6 +4,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.Date;
@@ -12,6 +13,7 @@
import org.exparity.hamcrest.date.core.function.LocalDateFunction;
import org.exparity.hamcrest.date.core.function.LocalDateTimeFunction;
import org.exparity.hamcrest.date.core.function.LocalTimeFunction;
+import org.exparity.hamcrest.date.core.function.OffsetDateTimeFunction;
import org.exparity.hamcrest.date.core.function.SqlDateFunction;
import org.exparity.hamcrest.date.core.function.ZonedDateTimeFunction;
@@ -30,5 +32,6 @@ private TemporalFunctions() {}
public static TemporalFunction LOCALTIME = new LocalTimeFunction();
public static TemporalFunction LOCALDATETIME = new LocalDateTimeFunction();
public static TemporalFunction ZONEDDATETIME = new ZonedDateTimeFunction();
+ public static TemporalFunction OFFSETDATETIME = new OffsetDateTimeFunction();
public static TemporalFunction INSTANT = new InstantFunction();
}
diff --git a/src/main/java/org/exparity/hamcrest/date/core/TemporalProviders.java b/src/main/java/org/exparity/hamcrest/date/core/TemporalProviders.java
index f13b0c4..0cba5c5 100644
--- a/src/main/java/org/exparity/hamcrest/date/core/TemporalProviders.java
+++ b/src/main/java/org/exparity/hamcrest/date/core/TemporalProviders.java
@@ -8,6 +8,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
+import java.time.OffsetDateTime;
import java.time.Year;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -96,14 +97,21 @@ public static TemporalProvider localDate(LocalDate date) {
* Factory to create a {@link TemporalProvider} for a {@link LocalDate}
*/
public static TemporalProvider localDate(ZonedDateTime date) {
- return (zone) -> date.toLocalDate();
+ return (zone) -> zonedDateTime(date).apply(zone).toLocalDate();
}
+
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link LocalDate}
+ */
+ public static TemporalProvider localDate(OffsetDateTime date) {
+ return (zone) -> offsetDateTime(date).apply(zone).toLocalDate();
+ }
/**
* Factory to create a {@link TemporalProvider} for a {@link LocalDate}
*/
public static TemporalProvider localDate(LocalDateTime date) {
- return (zone) -> date.toLocalDate();
+ return (zone) -> localDateTime(date).apply(zone).toLocalDate();
}
/**
@@ -138,7 +146,7 @@ public static TemporalProvider zonedDateTime(Date date) {
if (date instanceof java.sql.Date) {
return zonedDateTime((java.sql.Date) date);
} else {
- return (zone) -> ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()).withZoneSameInstant(zone);
+ return (zone) -> zonedDateTime(ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())).apply(zone);
}
}
@@ -149,6 +157,31 @@ public static TemporalProvider zonedDateTime(java.sql.Date date)
throw new TemporalConversionException(UNSUPPORTED_SQL_DATE_UNIT);
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link OffsetDateTime}
+ */
+ public static TemporalProvider offsetDateTime(OffsetDateTime date) {
+ return (zone) -> date.withOffsetSameInstant(zone.getRules().getOffset(date.toLocalDateTime()));
+ }
+
+ /**
+ * Factory to create a {@link TemporalProvider} for an {@link OffsetDateTime}
+ */
+ public static TemporalProvider offsetDateTime(Date date) {
+ if (date instanceof java.sql.Date) {
+ return offsetDateTime((java.sql.Date) date);
+ } else {
+ return (zone) -> offsetDateTime(OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault())).apply(zone);
+ }
+ }
+
+ /**
+ * Factory to create a {@link TemporalProvider} for an {@link ZonedDateTime}
+ */
+ public static TemporalProvider offsetDateTime(java.sql.Date date) {
+ throw new TemporalConversionException(UNSUPPORTED_SQL_DATE_UNIT);
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link LocalTime}
*/
@@ -160,9 +193,16 @@ public static TemporalProvider localTime(LocalTime time) {
* Factory to create a {@link TemporalProvider} for a {@link Year}
*/
public static TemporalProvider year(ZonedDateTime date) {
- return (zone) -> Year.from(date.withZoneSameInstant(zone));
+ return (zone) -> Year.from(zonedDateTime(date).apply(zone));
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link Year}
+ */
+ public static TemporalProvider year(OffsetDateTime date) {
+ return (zone) -> Year.from(offsetDateTime(date).apply(zone));
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link Year}
*/
@@ -191,11 +231,18 @@ public static TemporalProvider year(Date date) {
return (zone) -> Year.from(localDate(date).apply(zone));
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link Month}
+ */
+ public static TemporalProvider month(OffsetDateTime date) {
+ return (zone) -> offsetDateTime(date).apply(zone).getMonth();
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link Month}
*/
public static TemporalProvider month(ZonedDateTime date) {
- return (zone) -> date.withZoneSameInstant(zone).getMonth();
+ return (zone) -> zonedDateTime(date).apply(zone).getMonth();
}
/**
@@ -230,7 +277,7 @@ public static TemporalProvider month(Date date) {
* Factory to create a {@link TemporalProvider} for a {@link DayOfWeek}
*/
public static TemporalProvider> dayOfWeek(ZonedDateTime date) {
- return (zone) -> Arrays.asList(date.withZoneSameInstant(zone).getDayOfWeek());
+ return (zone) -> Arrays.asList(zonedDateTime(date).apply(zone).getDayOfWeek());
}
/**
@@ -272,9 +319,16 @@ public static TemporalProvider> daysOfWeek(Date date) {
* Factory to create a {@link TemporalProvider} for a {@link DayOfMonth}
*/
public static TemporalProvider dayOfMonth(ZonedDateTime date) {
- return (zone) -> DayOfMonth.from(date.withZoneSameInstant(zone));
+ return (zone) -> DayOfMonth.from(zonedDateTime(date).apply(zone));
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link DayOfMonth}
+ */
+ public static TemporalProvider dayOfMonth(OffsetDateTime date) {
+ return (zone) -> DayOfMonth.from(offsetDateTime(date).apply(zone));
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link DayOfMonth}
*/
@@ -328,8 +382,16 @@ public static TemporalProvider hour(LocalDateTime date) {
* Factory to create a {@link TemporalProvider} for a {@link Hour}
*/
public static TemporalProvider hour(ZonedDateTime date) {
- return (zone) -> Hour.from(date.withZoneSameInstant(zone));
+ return (zone) -> Hour.from(zonedDateTime(date).apply(zone));
}
+
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link Hour}
+ */
+ public static TemporalProvider hour(OffsetDateTime date) {
+ return (zone) -> Hour.from(offsetDateTime(date).apply(zone));
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link Hour}
@@ -363,9 +425,16 @@ public static TemporalProvider minute(LocalDateTime date) {
* Factory to create a {@link TemporalProvider} for a {@link Minute}
*/
public static TemporalProvider minute(ZonedDateTime date) {
- return (zone) -> Minute.from(date.withZoneSameInstant(zone));
+ return (zone) -> Minute.from(zonedDateTime(date).apply(zone));
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link Minute}
+ */
+ public static TemporalProvider minute(OffsetDateTime date) {
+ return (zone) -> Minute.from(offsetDateTime(date).apply(zone));
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link Minute}
*/
@@ -405,9 +474,16 @@ public static TemporalProvider second(LocalDateTime date) {
* Factory to create a {@link TemporalProvider} for a {@link Second}
*/
public static TemporalProvider second(ZonedDateTime date) {
- return (zone) -> Second.from(date.withZoneSameInstant(zone));
+ return (zone) -> Second.from(zonedDateTime(date).apply(zone));
}
+ /**
+ * Factory to create a {@link TemporalProvider} for a {@link Second}
+ */
+ public static TemporalProvider second(OffsetDateTime date) {
+ return (zone) -> Second.from(offsetDateTime(date).apply(zone));
+ }
+
/**
* Factory to create a {@link TemporalProvider} for a {@link Millisecond}
*/
diff --git a/src/main/java/org/exparity/hamcrest/date/core/function/OffsetDateTimeFunction.java b/src/main/java/org/exparity/hamcrest/date/core/function/OffsetDateTimeFunction.java
new file mode 100644
index 0000000..d47bcd9
--- /dev/null
+++ b/src/main/java/org/exparity/hamcrest/date/core/function/OffsetDateTimeFunction.java
@@ -0,0 +1,45 @@
+package org.exparity.hamcrest.date.core.function;
+
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.Locale;
+
+import org.exparity.hamcrest.date.core.TemporalFunction;
+import org.exparity.hamcrest.date.core.TemporalFunctions;
+import org.exparity.hamcrest.date.core.types.Interval;
+
+/**
+ * Implementation of {@link TemporalFunctions} for {@link OffsetDateTime} objects.
+ *
+ * @author Stewart Bissett
+ */
+public class OffsetDateTimeFunction implements TemporalFunction {
+
+ private static final String DATE_TIME_PATTERN = "EEE, dd MMM yyyy hh:mm:ss.SSS a Z";
+
+ @Override
+ public boolean isAfter(final OffsetDateTime expected, final OffsetDateTime actual) {
+ return expected.isAfter(actual);
+ }
+
+ @Override
+ public boolean isBefore(final OffsetDateTime expected, final OffsetDateTime actual) {
+ return expected.isBefore(actual);
+ }
+
+ @Override
+ public boolean isSame(final OffsetDateTime expected, final OffsetDateTime actual) {
+ return expected.equals(actual);
+ }
+
+ @Override
+ public Interval interval(OffsetDateTime expected, OffsetDateTime other, ChronoUnit unit) {
+ return Interval.of(expected.until(other, unit), unit);
+ }
+
+ @Override
+ public String describe(final OffsetDateTime temporal, final Locale locale) {
+ return temporal.format(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN, locale));
+ }
+}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsAfterTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsAfterTest.java
index d59aeff..8c5ccd4 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsAfterTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsAfterTest.java
@@ -14,9 +14,11 @@
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
+import org.exparity.hamcrest.date.testutils.ZoneOffsets;
import org.testng.annotations.Test;
/**
@@ -27,337 +29,397 @@
@SuppressWarnings("deprecation")
public class IsAfterTest {
- private static final String ASSERTION_PATTERN = "\\sExpected: the date is after (?s:.)+?\\s but: date is (?s:.)+";
-
- // Date Matchers
-
- @Test
- public void isDateAfterEarlierDate() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11AM_UTC_AS_DATE).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterDate() {
- assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11PM_UTC_AS_DATE).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameDate() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11PM_UTC_AS_DATE).atZone(UTC));
- }
-
- @Test
- public void isDateAfterSameDateDifferentTimeZone() {
- assertThat(JAN_01_2012_11AM_PST_AS_DATE, DateMatchers.after(JAN_01_2012_11AM_GMT_AS_DATE).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterSameDateDifferentTimeZone() {
- assertThat(JAN_01_2012_11AM_GMT_AS_DATE, DateMatchers.after(JAN_01_2012_11AM_PST_AS_DATE).atZone(UTC));
- }
-
- @Test
- public void isDateAfterEarlierLocalDate() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_14_2012).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterLocalDate() {
- assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(JUN_16_2012).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameLocalDate() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012).atZone(UTC));
- }
-
- @Test
- public void isDateAfterEarlierDeprecatedDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 14).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterDeprecatedDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 16).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameDeprecatedDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15).atZone(UTC));
- }
-
- @Test
- public void isDateAfterEarlierDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 14).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 16).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameDateValues() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 15).atZone(UTC));
- }
-
- @Test
- public void isDateAfterEarlierDayMonthYear() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
- DateMatchers.after(new DayMonthYear(14, Months.JUNE, 2012)).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterDayMonthYear() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
- DateMatchers.after(new DayMonthYear(16, Months.JUNE, 2012)).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameDayMonthYear() {
- assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
- DateMatchers.after(new DayMonthYear(15, Months.JUNE, 2012)).atZone(UTC));
- }
-
- @Test
- public void isDateAfterEarlierDateTime() {
- assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 10, 59, 59).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterLaterDateTime() {
- assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 11, 0, 1).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateAfterSameDateTime() {
- assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 11, 0, 0).atZone(UTC));
- }
-
- @Test
- public void isSqlDateAfterEarlierDate() {
- assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_03_2015_NOON_UTC_AS_DATE));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterDate() {
- assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_05_2015_NOON_UTC_AS_DATE));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterSameDate() {
- assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_04_2015_NOON_UTC_AS_DATE));
- }
-
- // java.sql.Date Matchers
-
- @Test
- public void isSqlDateAfterEarlierSqlDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015_AS_SQL));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterSqlDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015_AS_SQL));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterSameSqlDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015_AS_SQL));
- }
-
- @Test
- public void isSqlDateAfterEarlierJavaDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015_NOON_UTC_AS_DATE));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterJavaDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015_NOON_UTC_AS_DATE));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterSameJavaDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015_NOON_UTC_AS_DATE));
- }
-
- @Test
- public void isSqlDateAfterEarlierLocalDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterLocalDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterSameLocalDate() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015));
- }
-
- @Test
- public void isSqlDateAfterEarlierDay() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 3));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterDay() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 5));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateAfterLaterSameDay() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 4));
- }
-
- // LocalDate Matchers
-
- @Test
- public void isLocalDateAfterEarlierLocalDate() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_03_2015));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateAfterLaterLocalDate() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_05_2015));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateAfterSameLocalDate() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_04_2015));
- }
-
- @Test
- public void isLocalDateAfterEarlierDay() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 3));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateAfterLaterDay() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 5));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateAfterLaterSameDay() {
- assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 4));
- }
-
- // LocalDateTime Matchers
-
- @Test
- public void isLocalDateTimeAfterEarlierLocalDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_1159));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateTimeAfterLaterLocalDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_1201));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateTimeAfterSameLocalDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_NOON));
- }
-
- @Test
- public void isLocalDateTimeAfterEarlierDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 11, 59, 0));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateTimeAfterLaterDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 1));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateTimeAfterLaterSameDateTime() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0));
- }
-
- // ZonedDateTime Matchers
-
- @Test
- public void isZonedDateTimeAfterEarlierZonedDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_11AM_UTC).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterLaterZonedDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_01PM_UTC).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterSameZonedDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_UTC).atZone(UTC));
- }
-
- @Test
- public void isZonedDateTimeAfterZonedDateTimeEarlierZone() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_CET).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterZonedDateTimeLaterZone() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_EST).atZone(UTC));
- }
-
- @Test
- public void isZonedDateTimeAfterEarlierDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 11, 59, 0, 0, UTC).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterLaterDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 1, 0, UTC).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterLaterSameDateTime() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, UTC).atZone(UTC));
- }
-
- @Test
- public void isZonedDateTimeAfterDateTimeEarlierZone() {
- assertThat(AUG_04_2015_NOON_UTC,
- ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneIds.CET).atZone(UTC));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeAfterDateTimeLaterZone() {
- assertThat(AUG_04_2015_NOON_UTC,
- ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneIds.EST).atZone(UTC));
- }
-
- // LocalTime Matchers
-
- @Test
- public void isLocalTimeAfterEarlierLocalTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON.minusSeconds(1)));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalTimeAfterSameLocalTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalTimeAfterLaterLocalTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON.plusSeconds(1)));
- }
-
- @Test
- public void isLocalTimeAfterEarlierTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(11, 59, 59));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalTimeAfterSameTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(12, 0, 0));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalTimeAfterLaterTime() {
- assertThat(LocalTime.NOON, LocalTimeMatchers.after(12, 0, 1));
- }
+ private static final String ASSERTION_PATTERN = "\\sExpected: the date is after (?s:.)+?\\s but: date is (?s:.)+";
+
+ // Date Matchers
+
+ @Test
+ public void isDateAfterEarlierDate() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11AM_UTC_AS_DATE).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterDate() {
+ assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11PM_UTC_AS_DATE).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameDate() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012_11PM_UTC_AS_DATE).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterSameDateDifferentTimeZone() {
+ assertThat(JAN_01_2012_11AM_PST_AS_DATE, DateMatchers.after(JAN_01_2012_11AM_GMT_AS_DATE).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterSameDateDifferentTimeZone() {
+ assertThat(JAN_01_2012_11AM_GMT_AS_DATE, DateMatchers.after(JAN_01_2012_11AM_PST_AS_DATE).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterEarlierLocalDate() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_14_2012).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterLocalDate() {
+ assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(JUN_16_2012).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameLocalDate() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(JUN_15_2012).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterEarlierDeprecatedDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 14).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterDeprecatedDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 16).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameDeprecatedDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterEarlierDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 14).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 16).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameDateValues() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.after(2012, Month.JUNE, 15).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterEarlierDayMonthYear() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
+ DateMatchers.after(new DayMonthYear(14, Months.JUNE, 2012)).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterDayMonthYear() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
+ DateMatchers.after(new DayMonthYear(16, Months.JUNE, 2012)).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameDayMonthYear() {
+ assertThat(JUN_15_2012_11PM_UTC_AS_DATE,
+ DateMatchers.after(new DayMonthYear(15, Months.JUNE, 2012)).atZone(UTC));
+ }
+
+ @Test
+ public void isDateAfterEarlierDateTime() {
+ assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 10, 59, 59).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterLaterDateTime() {
+ assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 11, 0, 1).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateAfterSameDateTime() {
+ assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.after(2012, Months.JUNE, 15, 11, 0, 0).atZone(UTC));
+ }
+
+ @Test
+ public void isSqlDateAfterEarlierDate() {
+ assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_03_2015_NOON_UTC_AS_DATE));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterDate() {
+ assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_05_2015_NOON_UTC_AS_DATE));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterSameDate() {
+ assertThat(AUG_04_2015_AS_SQL, DateMatchers.after(AUG_04_2015_NOON_UTC_AS_DATE));
+ }
+
+ // java.sql.Date Matchers
+
+ @Test
+ public void isSqlDateAfterEarlierSqlDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015_AS_SQL));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterSqlDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015_AS_SQL));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterSameSqlDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015_AS_SQL));
+ }
+
+ @Test
+ public void isSqlDateAfterEarlierJavaDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015_NOON_UTC_AS_DATE));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterJavaDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015_NOON_UTC_AS_DATE));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterSameJavaDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015_NOON_UTC_AS_DATE));
+ }
+
+ @Test
+ public void isSqlDateAfterEarlierLocalDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_03_2015));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterLocalDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_05_2015));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterSameLocalDate() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(AUG_04_2015));
+ }
+
+ @Test
+ public void isSqlDateAfterEarlierDay() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 3));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterDay() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 5));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateAfterLaterSameDay() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.after(2015, AUGUST, 4));
+ }
+
+ // LocalDate Matchers
+
+ @Test
+ public void isLocalDateAfterEarlierLocalDate() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_03_2015));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateAfterLaterLocalDate() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_05_2015));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateAfterSameLocalDate() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(AUG_04_2015));
+ }
+
+ @Test
+ public void isLocalDateAfterEarlierDay() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 3));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateAfterLaterDay() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 5));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateAfterLaterSameDay() {
+ assertThat(AUG_04_2015, LocalDateMatchers.after(2015, AUGUST, 4));
+ }
+
+ // LocalDateTime Matchers
+
+ @Test
+ public void isLocalDateTimeAfterEarlierLocalDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_1159));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateTimeAfterLaterLocalDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_1201));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateTimeAfterSameLocalDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(AUG_04_2015_NOON));
+ }
+
+ @Test
+ public void isLocalDateTimeAfterEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 11, 59, 0));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateTimeAfterLaterDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 1));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateTimeAfterLaterSameDateTime() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0));
+ }
+
+ // ZonedDateTime Matchers
+
+ @Test
+ public void isZonedDateTimeAfterEarlierZonedDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_11AM_UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterLaterZonedDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_01PM_UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterSameZonedDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isZonedDateTimeAfterZonedDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_CET).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterZonedDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(AUG_04_2015_NOON_EST).atZone(UTC));
+ }
+
+ @Test
+ public void isZonedDateTimeAfterEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 11, 59, 0, 0, UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 1, 0, UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterLaterSameDateTime() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isZonedDateTimeAfterDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_UTC,
+ ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneIds.CET).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeAfterDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_UTC,
+ ZonedDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneIds.EST).atZone(UTC));
+ }
+
+ // LocalTime Matchers
+
+ @Test
+ public void isLocalTimeAfterEarlierLocalTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON.minusSeconds(1)));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalTimeAfterSameLocalTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalTimeAfterLaterLocalTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(LocalTime.NOON.plusSeconds(1)));
+ }
+
+ @Test
+ public void isLocalTimeAfterEarlierTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(11, 59, 59));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalTimeAfterSameTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(12, 0, 0));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalTimeAfterLaterTime() {
+ assertThat(LocalTime.NOON, LocalTimeMatchers.after(12, 0, 1));
+ }
+
+ // OffsetDateTime Matchers
+
+ @Test
+ public void isOffsetDateTimeAfterEarlierOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(AUG_04_2015_11AM_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(AUG_04_2015_01PM_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(AUG_04_2015_NOON_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeAfterOffsetDateTimePositiveOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(AUG_04_2015_NOON_OFFSET_CET).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterOffsetDateTimeNegativeOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(AUG_04_2015_NOON_OFFSET_EST).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeAfterEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(2015, AUGUST, 4, 11, 59, 0, 0, ZoneOffsets.UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 1, 0, ZoneOffsets.UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterLaterSameDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeAfterDateTimePositiveOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.CET).atOffset(ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterDateTimeEquivalentOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.after(2015, AUGUST, 4, 7, 0, 0, 0, ZoneOffsets.EST));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeAfterDateTimeNegativeOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.after(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.EST).atOffset(ZoneOffsets.UTC));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsBeforeTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsBeforeTest.java
index 0015e28..c5a975d 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsBeforeTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsBeforeTest.java
@@ -1,7 +1,6 @@
package org.exparity.hamcrest.date.core;
import static java.time.Month.AUGUST;
-import static org.exparity.hamcrest.date.ZonedDateTimeMatchers.before;
import static org.exparity.hamcrest.date.testutils.Dates.*;
import static org.exparity.hamcrest.date.testutils.ZoneIds.UTC;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -15,9 +14,11 @@
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
+import org.exparity.hamcrest.date.testutils.ZoneOffsets;
import org.testng.annotations.Test;
/**
@@ -292,12 +293,12 @@ public void isZonedDateTimeBeforeLaterSameZonedDateTime() {
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
public void isZonedDateTimeBeforeZonedDateTimeEarlierZone() {
- assertThat(AUG_04_2015_NOON_UTC, before(AUG_04_2015_NOON_CET));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.before(AUG_04_2015_NOON_CET));
}
@Test
public void isZonedDateTimeBeforeZonedDateTimeLaterZone() {
- assertThat(AUG_04_2015_NOON_UTC, before(AUG_04_2015_NOON_EST));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.before(AUG_04_2015_NOON_EST));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
@@ -356,4 +357,61 @@ public void isLocalTimeBeforeSameTime() {
public void isLocalTimeBeforeLaterTime() {
assertThat(LocalTime.NOON, LocalTimeMatchers.before(12, 0, 1));
}
+
+ // OffsetDateTime Matchers
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(AUG_04_2015_11AM_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeBeforeEarlierOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(AUG_04_2015_01PM_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeLaterSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeOffsetDateTimePositiveOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(AUG_04_2015_NOON_OFFSET_CET));
+ }
+
+ @Test
+ public void isOffsetDateTimeBeforeOffsetDateTimeNegativeOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(AUG_04_2015_NOON_OFFSET_EST));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 11, 59, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeBeforeEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 12, 0, 1, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeSameDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeDateTimePositiveOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeBeforeDateTimeEquivalentOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 7, 0, 0, 0, ZoneOffsets.CET));
+ }
+
+ @Test
+ public void isOffsetDateTimeBeforeDateTimeNegativeOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.before(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.EST));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsDayOfMonthTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsDayOfMonthTest.java
index 53e7897..d6ee319 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsDayOfMonthTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsDayOfMonthTest.java
@@ -6,6 +6,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -142,4 +143,25 @@ public void isZonedDateTimeNotLastDayOfMonth() {
assertThat(AUG_01_2015_NOON_UTC, ZonedDateTimeMatchers.isDayOfMonth(31));
}
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeFirstDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfMonth(1));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotFirstDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfMonth(1));
+ }
+
+ @Test
+ public void isOffsetDateTimeLastDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfMonth(31));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotLastDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfMonth(31));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsDayOfWeekTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsDayOfWeekTest.java
index 1c6cc71..633e08e 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsDayOfWeekTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsDayOfWeekTest.java
@@ -9,6 +9,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.Weekdays;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
@@ -708,6 +709,7 @@ public void isLocalDateTimeNotWeekendOnFriday() {
}
// ZonedDateTime Matchers
+
@Test
public void isZonedDateTimeDayOfWeek() {
assertThat(AUG_03_2015_NOON_UTC, ZonedDateTimeMatchers.isDayOfWeek(MONDAY));
@@ -837,4 +839,135 @@ public void isZonedDateTimeNotWeekendOnThursday() {
public void isZonedDateTimeNotWeekendOnFriday() {
assertThat(AUG_07_2015_NOON_UTC, ZonedDateTimeMatchers.isWeekend());
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeDayOfWeek() {
+ assertThat(AUG_03_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfWeek(MONDAY));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotDayOfWeek() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDayOfWeek(MONDAY));
+ }
+
+ @Test
+ public void isOffsetDateTimeMonday() {
+ assertThat(AUG_03_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMonday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotMonday() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMonday());
+ }
+
+ @Test
+ public void isOffsetDateTimeTuesday() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isTuesday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotTuesday() {
+ assertThat(AUG_05_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isTuesday());
+ }
+
+ @Test
+ public void isOffsetDateTimeWednesday() {
+ assertThat(AUG_05_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWednesday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotWednesday() {
+ assertThat(AUG_06_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWednesday());
+ }
+
+ @Test
+ public void isOffsetDateTimeThursday() {
+ assertThat(AUG_06_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isThursday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotThursday() {
+ assertThat(AUG_07_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isThursday());
+ }
+
+ @Test
+ public void isOffsetDateTimeFriday() {
+ assertThat(AUG_07_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFriday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotFriday() {
+ assertThat(AUG_08_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFriday());
+ }
+
+ @Test
+ public void isOffsetDateTimeSaturday() {
+ assertThat(AUG_08_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSaturday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSaturday() {
+ assertThat(AUG_09_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSaturday());
+ }
+
+ @Test
+ public void isOffsetDateTimeSunday() {
+ assertThat(AUG_09_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSunday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSunday() {
+ assertThat(AUG_03_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSunday());
+ }
+
+ @Test
+ public void isOffsetDateTimeWeekday() {
+ assertThat(AUG_03_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ assertThat(AUG_05_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ assertThat(AUG_06_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ assertThat(AUG_07_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekdayOnSaturday() {
+ assertThat(AUG_08_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekdayOnSunday() {
+ assertThat(AUG_09_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekday());
+ }
+
+ @Test
+ public void isOffsetDateTimeWeekend() {
+ assertThat(AUG_08_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ assertThat(AUG_09_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekendOnMonday() {
+ assertThat(AUG_03_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekendOnTuesday() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekendOnWednesday() {
+ assertThat(AUG_05_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekendOnThursday() {
+ assertThat(AUG_06_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN_MULTIPLE_DAYS)
+ public void isOffsetDateTimeNotWeekendOnFriday() {
+ assertThat(AUG_07_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isWeekend());
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsDayTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsDayTest.java
index eb63b60..1d63219 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsDayTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsDayTest.java
@@ -6,6 +6,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
@@ -13,6 +14,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -209,4 +211,34 @@ public void isZonedDateTimeNotTomorrow() {
assertThat(ZonedDateTime.now(), ZonedDateTimeMatchers.isTomorrow());
}
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeToday() {
+ assertThat(OffsetDateTime.now(), OffsetDateTimeMatchers.isToday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotToday() {
+ assertThat(OffsetDateTime.now().plusDays(1), OffsetDateTimeMatchers.isToday());
+ }
+
+ @Test
+ public void isOffsetDateTimeYesterday() {
+ assertThat(OffsetDateTime.now().minusDays(1), OffsetDateTimeMatchers.isYesterday());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotYesterday() {
+ assertThat(OffsetDateTime.now(), OffsetDateTimeMatchers.isYesterday());
+ }
+
+ @Test
+ public void isOffsetDateTimeTomorrow() {
+ assertThat(OffsetDateTime.now().plusDays(1), OffsetDateTimeMatchers.isTomorrow());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotTomorrow() {
+ assertThat(OffsetDateTime.now(), OffsetDateTimeMatchers.isTomorrow());
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsFirstDayOfMonthTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsFirstDayOfMonthTest.java
index c5cc38d..fbd1829 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsFirstDayOfMonthTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsFirstDayOfMonthTest.java
@@ -6,6 +6,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -82,4 +83,15 @@ public void isZonedDateTimeFirstDayOfMonth() {
public void isZonedDateTimeNotFirstDayOfMonth() {
assertThat(AUG_31_2015_NOON_UTC, ZonedDateTimeMatchers.isFirstDayOfMonth());
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeFirstDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFirstDayOfMonth());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotFirstDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFirstDayOfMonth());
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsHourTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsHourTest.java
index 144d6ee..8e3e9a7 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsHourTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsHourTest.java
@@ -9,6 +9,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
import org.testng.annotations.Test;
@@ -77,6 +78,7 @@ public void isLocalTimeNotHour() {
}
// ZonedDateTime Matchers
+
@Test
public void isZonedDateTimeHour() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isHour(12).atZone(ZoneIds.UTC));
@@ -97,4 +99,26 @@ public void isZonedDateTimeNotHour() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isHour(11).atZone(ZoneIds.UTC));
}
+ // OffsetDateTime Matchers
+
+ @Test
+ public void isOffsetDateTimeHour() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isHour(12).atZone(ZoneIds.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeHourOtherZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isHour(8).atZone(ZoneIds.EST));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotHourOtherZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isHour(12).atZone(ZoneIds.CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotHour() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isHour(11).atZone(ZoneIds.UTC));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsLastDayOfMonthTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsLastDayOfMonthTest.java
index 2323fe1..a260316 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsLastDayOfMonthTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsLastDayOfMonthTest.java
@@ -6,6 +6,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -70,6 +71,7 @@ public void isLocalDateTimeNotLastDayOfMonth() {
}
// ZonedDateTime Matchers
+
@Test
public void isZonedDateTimeLastDayOfMonth() {
assertThat(AUG_31_2015_NOON_UTC, ZonedDateTimeMatchers.isLastDayOfMonth());
@@ -79,4 +81,16 @@ public void isZonedDateTimeLastDayOfMonth() {
public void isZonedDateTimeNotLastDayOfMonth() {
assertThat(AUG_01_2015_NOON_UTC, ZonedDateTimeMatchers.isLastDayOfMonth());
}
+
+ // OffsetDateTime Matchers
+
+ @Test
+ public void isOffsetDateTimeLastDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isLastDayOfMonth());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotLastDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isLastDayOfMonth());
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsLeapYearTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsLeapYearTest.java
index 5497c14..35e6b8f 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsLeapYearTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsLeapYearTest.java
@@ -7,6 +7,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
@@ -97,13 +98,33 @@ public void isZonedDateTimeNotLeapYear() {
}
@Test
- public void isZonedDateLeapYearStartOfYearSameZone() {
+ public void isZonedDateTimeLeapYearStartOfYearSameZone() {
assertThat(JAN_01_2012_MIDNIGHT_CET, ZonedDateTimeMatchers.isLeapYear().atZone(ZoneIds.CET));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateNotLeapYearStartOfYearLaterZone() {
+ public void isZonedDateTimeNotLeapYearStartOfYearLaterZone() {
assertThat(JAN_01_2012_MIDNIGHT_CET, ZonedDateTimeMatchers.isLeapYear().atZone(ZoneIds.UTC));
}
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeLeapYear() {
+ assertThat(AUG_04_2016_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isLeapYear());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotLeapYear() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isLeapYear());
+ }
+
+ @Test
+ public void isOffsetDateTimeLeapYearStartOfYearSameZone() {
+ assertThat(JAN_01_2012_MIDNIGHT_OFFSET_CET, OffsetDateTimeMatchers.isLeapYear().atZone(ZoneIds.CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void issOffsetDateTimeNotLeapYearStartOfYearLaterZone() {
+ assertThat(JAN_01_2012_MIDNIGHT_OFFSET_CET, OffsetDateTimeMatchers.isLeapYear().atZone(ZoneIds.UTC));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsMaximumTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsMaximumTest.java
index c530530..27c8294 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsMaximumTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsMaximumTest.java
@@ -10,6 +10,7 @@
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -96,4 +97,16 @@ public void isLocalTimeLastHourOfDay() {
public void isLocalTimeNotLastHourOfDay() {
assertThat(LocalTime.of(22, 0, 0), LocalTimeMatchers.isMaximum(ChronoField.HOUR_OF_DAY));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeLastDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMaximum(ChronoField.DAY_OF_MONTH));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotLastDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMaximum(ChronoField.DAY_OF_MONTH));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsMinimumTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsMinimumTest.java
index 30f8422..677d14f 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsMinimumTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsMinimumTest.java
@@ -10,6 +10,7 @@
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -96,4 +97,15 @@ public void isLocalTimeFirstHourOfDay() {
public void isLocalTimeNotFirstHourOfDay() {
assertThat(LocalTime.of(1, 0, 0), LocalTimeMatchers.isMinimum(ChronoField.HOUR_OF_DAY));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeFirstDayOfMonth() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMinimum(ChronoField.DAY_OF_MONTH));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotFirstDayOfMonth() {
+ assertThat(AUG_31_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMinimum(ChronoField.DAY_OF_MONTH));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsMinuteTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsMinuteTest.java
index 9a65e13..a1d6b63 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsMinuteTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsMinuteTest.java
@@ -8,6 +8,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -85,4 +86,14 @@ public void isZonedDateTimeNotMinute() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isMinute(1));
}
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeMinute() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMinute(0));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotMinute() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMinute(1));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsMonthTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsMonthTest.java
index ecf2c51..f9048dc 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsMonthTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsMonthTest.java
@@ -8,6 +8,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -805,5 +806,135 @@ public void isZonedDateTimeDecember() {
public void isZonedDateTimeNotDecember() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isDecember());
}
-
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeMonth() {
+ assertThat(JAN_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMonth(Month.JANUARY));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotMonth() {
+ assertThat(JAN_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMonth(Month.FEBRUARY));
+ }
+
+ @Test
+ public void isOffsetDateTimeJanuary() {
+ assertThat(JAN_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJanuary());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotJanuary() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJanuary());
+ }
+
+ @Test
+ public void isOffsetDateTimeFebruary() {
+ assertThat(FEB_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFebruary());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotFebruary() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isFebruary());
+ }
+
+ @Test
+ public void isOffsetDateTimeMarch() {
+ assertThat(MAR_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMarch());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotMarch() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMarch());
+ }
+
+ @Test
+ public void isOffsetDateTimeApril() {
+ assertThat(APR_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isApril());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotApril() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isApril());
+ }
+
+ @Test
+ public void isOffsetDateTimeMay() {
+ assertThat(MAY_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMay());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotMay() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isMay());
+ }
+
+ @Test
+ public void isOffsetDateTimeJune() {
+ assertThat(JUN_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJune());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotJune() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJune());
+ }
+
+ @Test
+ public void isOffsetDateTimeJuly() {
+ assertThat(JUL_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJuly());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotJuly() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isJuly());
+ }
+
+ @Test
+ public void isOffsetDateTimeAugust() {
+ assertThat(AUG_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isAugust());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotAugust() {
+ assertThat(SEP_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isAugust());
+ }
+
+ @Test
+ public void isOffsetDateTimeSeptember() {
+ assertThat(SEP_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSeptember());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSeptember() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSeptember());
+ }
+
+ @Test
+ public void isOffsetDateTimeOctober() {
+ assertThat(OCT_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isOctober());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotOctober() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isOctober());
+ }
+
+ @Test
+ public void isOffsetDateTimeNovember() {
+ assertThat(NOV_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isNovember());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotNovember() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isNovember());
+ }
+
+ @Test
+ public void isOffsetDateTimeDecember() {
+ assertThat(DEC_01_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDecember());
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotDecember() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDecember());
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfMonthTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfMonthTest.java
index 749da0b..8d689d4 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfMonthTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfMonthTest.java
@@ -6,6 +6,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -111,4 +112,21 @@ public void isZonedDateTimeNotSameDayOfMonth() {
public void isZonedDateTimeSameDayOfMonthDifferentMonth() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.sameDayOfMonth(SEP_04_2015_NOON_UTC));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameDayOfMonth() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfMonth(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameDayOfMonth() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfMonth(AUG_01_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDayOfMonthDifferentMonth() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfMonth(SEP_04_2015_NOON_OFFSET_UTC));
+
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfWeekTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfWeekTest.java
index cbafd93..bfae608 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfWeekTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayOfWeekTest.java
@@ -6,6 +6,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -141,4 +142,21 @@ public void isZonedDateTimeNotSameDayOfWeek() {
public void isZonedDateTimeSameDayOfWeekDifferentMonth() {
assertThat(AUG_07_2015_NOON_UTC, ZonedDateTimeMatchers.sameDayOfWeek(SEP_04_2015_NOON_UTC));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameDayOfWeek() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfWeek(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameDayOfWeek() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfWeek(AUG_01_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDayOfWeekDifferentMonth() {
+ assertThat(AUG_07_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDayOfWeek(SEP_04_2015_NOON_OFFSET_UTC));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayTest.java
index f26391e..f34dad0 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameDayTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameDayTest.java
@@ -10,6 +10,7 @@
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
import org.testng.annotations.Test;
@@ -242,4 +243,46 @@ public void isZonedDateTimeSameDayLaterDay() {
public void isZonedDateTimeSameDayLaterSameDay() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isDay(2015, AUGUST, 4, UTC).atZone(UTC));
}
+
+ // OffsetDateTime Matchers
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameDayEarlierOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDay(AUG_03_2015_NOON_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameDayLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDay(AUG_05_2015_NOON_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDaySameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDay(AUG_04_2015_NOON_OFFSET_UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDayOffsetDateTimePositiveOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDay(AUG_04_2015_NOON_OFFSET_CET).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDayOffsetDateTimeNegativeOffset() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameDay(AUG_04_2015_NOON_OFFSET_EST).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameDayEarlierDay() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDay(2015, AUGUST, 3, UTC).atZone(UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameDayLaterDay() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDay(2015, AUGUST, 5, UTC).atZone(UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameDayLaterSameDay() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDay(2015, AUGUST, 4, UTC).atZone(UTC));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameHourOfDayTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameHourOfDayTest.java
index 74d0ea5..65b20e9 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameHourOfDayTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameHourOfDayTest.java
@@ -7,14 +7,14 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
-import java.time.ZonedDateTime;
+import java.time.OffsetDateTime;
import java.util.Calendar;
import java.util.Date;
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
-import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
import org.testng.annotations.Test;
@@ -127,22 +127,24 @@ public void isLocalTimeNotSameHourOfDay() {
assertThat(other, LocalTimeMatchers.sameHourOfDay(date));
}
- // ZonedDateTime Matchers
+ // OffsetDateTime Matchers
@Test
- public void isZonedDateTimeSameHourOfDay() {
- ZonedDateTime date = ZonedDateTime.now(), other = date;
- assertThat(other, ZonedDateTimeMatchers.sameHourOfDay(date));
+ public void isOffsetDateTimeSameHourOfDay() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date;
+ assertThat(other, OffsetDateTimeMatchers.sameHourOfDay(date));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeNotSameHourOfDay() {
- ZonedDateTime date = ZonedDateTime.now(), other = date.plusHours(1);
- assertThat(other, ZonedDateTimeMatchers.sameHourOfDay(date));
+ public void isOffsetDateTimeNotSameHourOfDay() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusHours(1);
+ assertThat(other, OffsetDateTimeMatchers.sameHourOfDay(date));
}
@Test
- public void isZonedDateTimeSameHourOfDayDifferentDay() {
- ZonedDateTime date = ZonedDateTime.now(), other = date.plusDays(1);
- assertThat(other, ZonedDateTimeMatchers.sameHourOfDay(date));
+ public void isOffsetDateTimeSameHourOfDayDifferentDay() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusDays(1);
+ assertThat(other, OffsetDateTimeMatchers.sameHourOfDay(date));
}
+
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameInstantTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameInstantTest.java
index e01c706..56c7709 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameInstantTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameInstantTest.java
@@ -10,8 +10,10 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
+import org.exparity.hamcrest.date.testutils.ZoneOffsets;
import org.testng.annotations.Test;
/**
@@ -211,4 +213,57 @@ public void isZonedDateTimeSameInstantDateTimeEarlierZone() {
public void isZonedDateTimeSameInstantDateTimeLaterZone() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isInstant(2015, AUGUST, 4, 12, 0, 0, 0, ZoneIds.EST));
}
+
+ // OffsetDateTime Matchers
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantEarlierOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameInstant(AUG_04_2015_11AM_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameInstant(AUG_04_2015_01PM_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameInstantSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameInstant(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantOffsetDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameInstant(AUG_04_2015_NOON_OFFSET_CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantOffsetDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameInstant(AUG_04_2015_NOON_OFFSET_EST));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isInstant(2015, AUGUST, 4, 11, 59, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isInstant(2015, AUGUST, 4, 12, 0, 1, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameInstantLaterSameDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isInstant(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isInstant(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameInstantDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isInstant(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.EST));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameMinuteOfHourTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameMinuteOfHourTest.java
index 45dc8fe..51c33aa 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameMinuteOfHourTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameMinuteOfHourTest.java
@@ -5,6 +5,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
@@ -12,6 +13,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -144,4 +146,24 @@ public void isZonedDateTimeSameMinuteOfHourDifferentHour() {
ZonedDateTime date = ZonedDateTime.now(), other = date.plusHours(1);
assertThat(other, ZonedDateTimeMatchers.sameMinuteOfHour(date));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameMinuteOfHour() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date;
+ assertThat(other, OffsetDateTimeMatchers.sameMinuteOfHour(date));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameMinuteOfHour() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusMinutes(1);
+ assertThat(other, OffsetDateTimeMatchers.sameMinuteOfHour(date));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameMinuteOfHourDifferentHour() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusHours(1);
+ assertThat(other, OffsetDateTimeMatchers.sameMinuteOfHour(date));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameMonthOfYearTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameMonthOfYearTest.java
index 269fe96..34eafc0 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameMonthOfYearTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameMonthOfYearTest.java
@@ -1,15 +1,17 @@
package org.exparity.hamcrest.date.core;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.exparity.hamcrest.date.testutils.Dates.*;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -230,4 +232,24 @@ public void isZonedDateTimeSameMonthOfYearDifferentYear() {
ZonedDateTime date = ZonedDateTime.now(), other = date.plusYears(1);
assertThat(other, ZonedDateTimeMatchers.sameMonthOfYear(date));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameMonthOfYear() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date;
+ assertThat(other, OffsetDateTimeMatchers.sameMonthOfYear(date));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameMonthOfYear() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusMonths(1);
+ assertThat(other, OffsetDateTimeMatchers.sameMonthOfYear(date));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameMonthOfYearDifferentYear() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusYears(1);
+ assertThat(other, OffsetDateTimeMatchers.sameMonthOfYear(date));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameOrAfterTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameOrAfterTest.java
index c71e6b9..202437e 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameOrAfterTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameOrAfterTest.java
@@ -1,7 +1,6 @@
package org.exparity.hamcrest.date.core;
import static java.time.Month.AUGUST;
-import static org.exparity.hamcrest.date.ZonedDateTimeMatchers.sameOrAfter;
import static org.exparity.hamcrest.date.testutils.Dates.*;
import static org.exparity.hamcrest.date.testutils.ZoneIds.UTC;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -14,8 +13,10 @@
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
+import org.exparity.hamcrest.date.testutils.ZoneOffsets;
import org.testng.annotations.Test;
/**
@@ -276,12 +277,12 @@ public void isZonedDateTimeSameOrAfterSameZonedDateTime() {
@Test
public void isZonedDateTimeSameOrAfterZonedDateTimeEarlierZone() {
- assertThat(AUG_04_2015_NOON_UTC, sameOrAfter(AUG_04_2015_NOON_CET));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.sameOrAfter(AUG_04_2015_NOON_CET));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
public void isZonedDateTimeSameOrAfterZonedDateTimeLaterZone() {
- assertThat(AUG_04_2015_NOON_UTC, sameOrAfter(AUG_04_2015_NOON_EST));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.sameOrAfter(AUG_04_2015_NOON_EST));
}
@Test
@@ -340,4 +341,56 @@ public void isLocalTimeSameOrAfterSameTime() {
public void isLocalTimeSameOrAfterLaterTime() {
assertThat(LocalTime.NOON, LocalTimeMatchers.sameOrAfter(12, 0, 1));
}
+
+ // OffsetDateTime Matchers
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterEarlierOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(AUG_04_2015_11AM_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrAfterLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(AUG_04_2015_01PM_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterOffsetDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(AUG_04_2015_NOON_OFFSET_CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrAfterOffsetDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(AUG_04_2015_NOON_OFFSET_EST));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterEarlierDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(2015, AUGUST, 4, 11, 59, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrAfterLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(2015, AUGUST, 4, 12, 0, 1, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterSameDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrAfterDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.CET));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrAfterDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrAfter(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.EST));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameOrBeforeTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameOrBeforeTest.java
index bebcdbe..3bae6de 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameOrBeforeTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameOrBeforeTest.java
@@ -1,7 +1,6 @@
package org.exparity.hamcrest.date.core;
import static java.time.Month.AUGUST;
-import static org.exparity.hamcrest.date.ZonedDateTimeMatchers.sameOrBefore;
import static org.exparity.hamcrest.date.testutils.Dates.*;
import static org.exparity.hamcrest.date.testutils.ZoneIds.UTC;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -14,8 +13,10 @@
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
import org.exparity.hamcrest.date.Months;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
+import org.exparity.hamcrest.date.testutils.ZoneOffsets;
import org.testng.annotations.Test;
/**
@@ -275,12 +276,12 @@ public void isZonedDateTimeSameOrBeforeSameZonedDateTime() {
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
public void isZonedDateTimeSameOrBeforeZonedDateTimeEarlierZone() {
- assertThat(AUG_04_2015_NOON_UTC, sameOrBefore(AUG_04_2015_NOON_CET));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.sameOrBefore(AUG_04_2015_NOON_CET));
}
@Test
public void isZonedDateTimeSameOrBeforeLaterZonedDateTimeLaterZone() {
- assertThat(AUG_04_2015_NOON_UTC, sameOrBefore(AUG_04_2015_NOON_EST));
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.sameOrBefore(AUG_04_2015_NOON_EST));
}
@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
@@ -340,4 +341,58 @@ public void isLocalTimeSameOrBeforeSameTime() {
public void isLocalTimeSameOrBeforeLaterTime() {
assertThat(LocalTime.NOON, LocalTimeMatchers.sameOrBefore(12, 0, 1));
}
+
+ // OffsetDateTime Matchers
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrBeforeLaterOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(AUG_04_2015_11AM_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(AUG_04_2015_01PM_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrBeforeOffsetDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(AUG_04_2015_NOON_OFFSET_CET));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeLaterOffsetDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(AUG_04_2015_NOON_OFFSET_EST));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrBeforeLaterDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.sameOrBefore(2015, AUGUST, 4, 11, 59, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(2015, AUGUST, 4, 12, 0, 1, 0, ZoneOffsets.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeSameDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeSameOrBeforeDateTimeEarlierZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.CET));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameOrBeforeDateTimeLaterZone() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.sameOrBefore(2015, AUGUST, 4, 12, 0, 0, 0, ZoneOffsets.EST));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameSecondOfMinuteTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameSecondOfMinuteTest.java
index a4b5e84..c4e8432 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameSecondOfMinuteTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameSecondOfMinuteTest.java
@@ -5,6 +5,7 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
@@ -12,6 +13,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -144,4 +146,24 @@ public void isZonedDateTimeSameSecondOfMinuteDifferentMinute() {
ZonedDateTime date = ZonedDateTime.now(), other = date.plusMinutes(1);
assertThat(other, ZonedDateTimeMatchers.sameSecondOfMinute(date));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameSecondOfMinute() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date;
+ assertThat(other, OffsetDateTimeMatchers.sameSecondOfMinute(date));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameSecondOfMinute() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusSeconds(1);
+ assertThat(other, OffsetDateTimeMatchers.sameSecondOfMinute(date));
+ }
+
+ @Test
+ public void isOffsetDateTimeSameSecondOfMinuteDifferentMinute() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusMinutes(1);
+ assertThat(other, OffsetDateTimeMatchers.sameSecondOfMinute(date));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSameYearTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSameYearTest.java
index 79bf7da..0e33d59 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSameYearTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSameYearTest.java
@@ -1,15 +1,17 @@
package org.exparity.hamcrest.date.core;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.exparity.hamcrest.date.testutils.Dates.*;
+import static org.hamcrest.MatcherAssert.assertThat;
import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -121,4 +123,17 @@ public void isZonedDateTimeNotSameYear() {
ZonedDateTime date = ZonedDateTime.now(), other = date.plusYears(1);
assertThat(other, ZonedDateTimeMatchers.sameYear(date));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSameYear() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date;
+ assertThat(other, OffsetDateTimeMatchers.sameYear(date));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSameYear() {
+ OffsetDateTime date = OffsetDateTime.now(), other = date.plusYears(1);
+ assertThat(other, OffsetDateTimeMatchers.sameYear(date));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsSecondTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsSecondTest.java
index 5cf430e..7c2e9f2 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsSecondTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsSecondTest.java
@@ -8,6 +8,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -85,4 +86,15 @@ public void isZonedDateTimeNotSecond() {
assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isSecond(1));
}
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeSecond() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSecond(0));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotSecond() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isSecond(1));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsWithinTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsWithinTest.java
index bfa88f4..c8da255 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsWithinTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsWithinTest.java
@@ -6,12 +6,14 @@
import java.time.LocalTime;
import java.time.Month;
+import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
import org.exparity.hamcrest.date.LocalTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.exparity.hamcrest.date.testutils.ZoneIds;
@@ -467,4 +469,50 @@ public void isLocalTimeWithSameTimeEqualLimit() {
public void isLocalTimeWithSameTimeOutsideLimit() {
assertThat(LocalTime.NOON, LocalTimeMatchers.within(2, ChronoUnit.SECONDS, 12, 0, 3));
}
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeWithinSameOffsetDateTime() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.within(2, ChronoUnit.DAYS, AUG_04_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeWithinOffsetDateTimeInsideLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.within(2, ChronoUnit.DAYS, AUG_05_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeWithinOffsetDateTimeEqualLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.within(2, ChronoUnit.DAYS, AUG_06_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeWithinOffsetDateTimeOutsideLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.within(2, ChronoUnit.DAYS, AUG_07_2015_NOON_OFFSET_UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeWithinSameDayMonthYear() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.within(2, ChronoUnit.NANOS, 2015, Month.AUGUST, 4, 12, 0, 0, 0, ZoneOffset.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeWithinDayMonthYearInsideLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.within(2, ChronoUnit.NANOS, 2015, Month.AUGUST, 4, 12, 0, 0, 1, ZoneOffset.UTC));
+ }
+
+ @Test
+ public void isOffsetDateTimeWithinDayMonthYearEqualLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.within(2, ChronoUnit.NANOS, 2015, Month.AUGUST, 4, 12, 0, 0, 2, ZoneOffset.UTC));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeWithinDayMonthYearOutsideLimit() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC,
+ OffsetDateTimeMatchers.within(2, ChronoUnit.NANOS, 2015, Month.AUGUST, 4, 12, 0, 0, 3, ZoneOffset.UTC));
+ }
+
}
diff --git a/src/test/java/org/exparity/hamcrest/date/core/IsYearTest.java b/src/test/java/org/exparity/hamcrest/date/core/IsYearTest.java
index e1329e8..16a1f9d 100644
--- a/src/test/java/org/exparity/hamcrest/date/core/IsYearTest.java
+++ b/src/test/java/org/exparity/hamcrest/date/core/IsYearTest.java
@@ -7,6 +7,7 @@
import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
+import org.exparity.hamcrest.date.OffsetDateTimeMatchers;
import org.exparity.hamcrest.date.SqlDateMatchers;
import org.exparity.hamcrest.date.ZonedDateTimeMatchers;
import org.testng.annotations.Test;
@@ -20,69 +21,79 @@ public class IsYearTest {
private static final String ASSERTION_PATTERN = "\\sExpected: the date has the year [0-9]+?\\s but: the date has the year [0-9]+";
- // Date Matchers
- @Test
- public void isDateYear() {
- assertThat(AUG_04_2016_MIDNIGHT_UTC_AS_DATE, DateMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isDateNotYear() {
- assertThat(AUG_04_2015_NOON_UTC_AS_DATE, DateMatchers.isYear(2016));
- }
-
- // java.sql.Date Matchers
- @Test
- public void isSqlDateYear() {
- assertThat(AUG_04_2016_AS_SQL, SqlDateMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateNotYear() {
- assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.isYear(2016));
- }
-
- @Test
- public void isSqlDateYearUsingDateMatchers() {
- assertThat(AUG_04_2016_AS_SQL, DateMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isSqlDateNotYearUsingDateMatchers() {
- assertThat(AUG_04_2015_AS_SQL, DateMatchers.isYear(2016));
- }
-
- // LocalDate Matchers
- @Test
- public void isLocalDateYear() {
- assertThat(AUG_04_2016, LocalDateMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateNotYear() {
- assertThat(AUG_04_2015, LocalDateMatchers.isYear(2016));
- }
-
- // LocalDateTime Matchers
- @Test
- public void isLocalDateTimeYear() {
- assertThat(AUG_04_2016_NOON, LocalDateTimeMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isLocalDateTimeNotYear() {
- assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.isYear(2016));
- }
-
- // ZonedDateTime Matchers
- @Test
- public void isZonedDateTimeYear() {
- assertThat(AUG_04_2016_NOON_UTC, ZonedDateTimeMatchers.isYear(2016));
- }
-
- @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
- public void isZonedDateTimeNotYear() {
- assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isYear(2016));
- }
-
+ // Date Matchers
+ @Test
+ public void isDateYear() {
+ assertThat(AUG_04_2016_MIDNIGHT_UTC_AS_DATE, DateMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isDateNotYear() {
+ assertThat(AUG_04_2015_NOON_UTC_AS_DATE, DateMatchers.isYear(2016));
+ }
+
+ // java.sql.Date Matchers
+ @Test
+ public void isSqlDateYear() {
+ assertThat(AUG_04_2016_AS_SQL, SqlDateMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateNotYear() {
+ assertThat(AUG_04_2015_AS_SQL, SqlDateMatchers.isYear(2016));
+ }
+
+ @Test
+ public void isSqlDateYearUsingDateMatchers() {
+ assertThat(AUG_04_2016_AS_SQL, DateMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isSqlDateNotYearUsingDateMatchers() {
+ assertThat(AUG_04_2015_AS_SQL, DateMatchers.isYear(2016));
+ }
+
+ // LocalDate Matchers
+ @Test
+ public void isLocalDateYear() {
+ assertThat(AUG_04_2016, LocalDateMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateNotYear() {
+ assertThat(AUG_04_2015, LocalDateMatchers.isYear(2016));
+ }
+
+ // LocalDateTime Matchers
+ @Test
+ public void isLocalDateTimeYear() {
+ assertThat(AUG_04_2016_NOON, LocalDateTimeMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isLocalDateTimeNotYear() {
+ assertThat(AUG_04_2015_NOON, LocalDateTimeMatchers.isYear(2016));
+ }
+
+ // ZonedDateTime Matchers
+ @Test
+ public void isZonedDateTimeYear() {
+ assertThat(AUG_04_2016_NOON_UTC, ZonedDateTimeMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isZonedDateTimeNotYear() {
+ assertThat(AUG_04_2015_NOON_UTC, ZonedDateTimeMatchers.isYear(2016));
+ }
+
+ // OffsetDateTime Matchers
+ @Test
+ public void isOffsetDateTimeYear() {
+ assertThat(AUG_04_2016_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isYear(2016));
+ }
+
+ @Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
+ public void isOffsetDateTimeNotYear() {
+ assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isYear(2016));
+ }
}
diff --git a/src/test/java/org/exparity/hamcrest/date/testutils/Dates.java b/src/test/java/org/exparity/hamcrest/date/testutils/Dates.java
index cac4d9c..40bbdea 100644
--- a/src/test/java/org/exparity/hamcrest/date/testutils/Dates.java
+++ b/src/test/java/org/exparity/hamcrest/date/testutils/Dates.java
@@ -128,6 +128,7 @@ public abstract class Dates {
public static final LocalDateTime AUG_03_2015_11PM = LocalDateTime.of(AUG_03_2015, LocalTime.of(23, 0, 0));
public static final LocalDateTime AUG_04_2015_1159 = LocalDateTime.of(AUG_04_2015, LocalTime.of(11, 59, 0));
public static final LocalDateTime AUG_04_2015_NOON = LocalDateTime.of(AUG_04_2015, NOON);
+ public static final LocalDateTime AUG_04_2015_MIDNIGHT = LocalDateTime.of(AUG_04_2015, MIDNIGHT);
public static final LocalDateTime AUG_04_2015_1201 = LocalDateTime.of(AUG_04_2015, LocalTime.of(12, 1, 0));
public static final LocalDateTime AUG_05_2015_01AM = LocalDateTime.of(AUG_05_2015, LocalTime.of(1, 0, 0));
public static final LocalDateTime AUG_05_2015_NOON = LocalDateTime.of(AUG_05_2015, NOON);
@@ -176,6 +177,41 @@ public abstract class Dates {
public static final ZonedDateTime AUG_04_2015_01PM_EST = ZonedDateTime.of(AUG_04_2015_NOON, ZoneIds.EST);
public static final ZonedDateTime AUG_04_2015_NOON_CET = ZonedDateTime.of(AUG_04_2015_NOON, ZoneIds.CET);
public static final ZonedDateTime AUG_05_2015_01AM_CET = ZonedDateTime.of(AUG_05_2015_01AM, ZoneIds.CET);
+
+ public static final OffsetDateTime JAN_01_2012_MIDNIGHT_OFFSET_CET = OffsetDateTime.of(JAN_01_2012_MIDNIGHT, ZoneOffsets.CET);
+ public static final OffsetDateTime JUN_14_2012_NOON_OFFSET_UTC = OffsetDateTime.of(JUN_14_2012_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime JUN_15_2012_11AM_OFFSET_UTC = OffsetDateTime.of(JUN_15_2012_11AM, ZoneOffsets.UTC);
+ public static final OffsetDateTime JUN_15_2012_NOON_OFFSET_UTC = OffsetDateTime.of(JUN_15_2012_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime JAN_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(JAN_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime FEB_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(FEB_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime MAR_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(MAR_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime APR_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(APR_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime MAY_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(MAY_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime JUN_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(JUN_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime JUL_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(JUL_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_03_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_03_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_04_2015_11AM_OFFSET_UTC = OffsetDateTime.of(AUG_04_2015_1159, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_04_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_04_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_04_2015_MIDNIGHT_OFFSET_UTC = OffsetDateTime.of(AUG_04_2015_MIDNIGHT, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_04_2015_01PM_OFFSET_UTC = OffsetDateTime.of(AUG_04_2015_1201, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_05_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_05_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_06_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_06_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_07_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_07_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_08_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_08_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_09_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_09_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_31_2015_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_31_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime SEP_04_2015_NOON_OFFSET_UTC = OffsetDateTime.of(SEP_04_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime SEP_30_2015_NOON_OFFSET_UTC = OffsetDateTime.of(SEP_30_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime OCT_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(OCT_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime NOV_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(NOV_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime DEC_01_2015_NOON_OFFSET_UTC = OffsetDateTime.of(DEC_01_2015_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_04_2016_NOON_OFFSET_UTC = OffsetDateTime.of(AUG_04_2016_NOON, ZoneOffsets.UTC);
+ public static final OffsetDateTime AUG_03_2015_11PM_OFFSET_EST = OffsetDateTime.of(AUG_03_2015_11PM, ZoneOffsets.EST);
+ public static final OffsetDateTime AUG_04_2015_NOON_OFFSET_EST = OffsetDateTime.of(AUG_04_2015_NOON, ZoneOffsets.EST);
+ public static final OffsetDateTime AUG_04_2015_01PM_OFFSET_EST = OffsetDateTime.of(AUG_04_2015_NOON, ZoneOffsets.EST);
+ public static final OffsetDateTime AUG_04_2015_NOON_OFFSET_CET = OffsetDateTime.of(AUG_04_2015_NOON, ZoneOffsets.CET);
+ public static final OffsetDateTime AUG_05_2015_01AM_OFFSET_CET = OffsetDateTime.of(AUG_05_2015_01AM, ZoneOffsets.CET);
// SQL Date
public static final java.sql.Date JAN_01_2012_AS_SQL = java.sql.Date.valueOf(LocalDate.of(2012, 1, 1));
diff --git a/src/test/java/org/exparity/hamcrest/date/testutils/ZoneOffsets.java b/src/test/java/org/exparity/hamcrest/date/testutils/ZoneOffsets.java
new file mode 100644
index 0000000..401486a
--- /dev/null
+++ b/src/test/java/org/exparity/hamcrest/date/testutils/ZoneOffsets.java
@@ -0,0 +1,17 @@
+package org.exparity.hamcrest.date.testutils;
+
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+
+/**
+ * Static repository of {@link ZoneId}
+ *
+ * @author Stewart Bissett
+ */
+public abstract class ZoneOffsets {
+
+ public static final ZoneOffset UTC = ZoneOffset.UTC; // 00:00
+ public static final ZoneOffset CET = ZoneOffset.ofHours(1); // +01:00
+ public static final ZoneOffset EST = ZoneOffset.ofHours(-5); // -05:00
+
+}