Skip to content

Commit

Permalink
Merge 8b76f98 into e32866c
Browse files Browse the repository at this point in the history
  • Loading branch information
stewbis committed Sep 22, 2019
2 parents e32866c + 8b76f98 commit 2e6981c
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsAfter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsAfter<>(converter, expected, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsAfter<>(converter, expected, functions, zone, locale);
}

}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsBefore.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsBefore<>(converter, expected, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsBefore<>(converter, expected, functions, zone, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsDayOfMonth<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsDayOfMonth<>(converter, expected, zone, locale);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsDayOfWeek<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsDayOfWeek<>(converter, expected, zone, locale);
}

private String describe(DayOfWeek actualValue) {
return actualValue.getDisplayName(TextStyle.FULL, locale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsFirstDayOfMonth<>(converter, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsFirstDayOfMonth<>(converter, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsHour.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsHour<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsHour<>(converter, expected, zone, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsLastDayOfMonth<>(converter, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsLastDayOfMonth<>(converter, zone, locale);
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsLeapYear.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsLeapYear<>(converter, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsLeapYear<>(converter, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsMaximum.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsMaximum<>(converter, field, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsMaximum<>(converter, field, zone, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsMillisecond<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsMillisecond<>(converter, expected, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsMinimum.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsMinimum<>(converter, field, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsMinimum<>(converter, field, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsMinute.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsMinute<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsMinute<>(converter, expected, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsMonth.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsMonth<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsMonth<>(converter, expected, zone, locale);
}

private String describe(Month actualValue) {
return actualValue.getDisplayName(TextStyle.FULL, locale);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsSame.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsSame<>(converter, expected, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsSame<>(converter, expected, functions, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsSameDay.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsSameDay<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsSameDay<>(converter, expected, zone, locale);
}

private String describe(LocalDate actualValue) {
return TemporalFunctions.LOCALDATE.describe(actualValue, locale);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsSameOrAfter<>(converter, expected, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsSameOrAfter<>(converter, expected, functions, zone, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsSameOrBefore<>(converter, expected, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsSameOrBefore<>(converter, expected, functions, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsSecond.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsSecond<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsSecond<>(converter, expected, zone, locale);
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsWithin.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsWithin<>(expectedInterval, converter, reference, functions, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsWithin<>(expectedInterval, converter, reference, functions, zone, locale);
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/exparity/hamcrest/date/core/IsYear.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public void describeTo(final Description description) {
public TemporalMatcher<T> atZone(ZoneId zone) {
return new IsYear<>(converter, expected, zone, locale);
}

@Override
public TemporalMatcher<T> atLocale(Locale locale) {
return new IsYear<>(converter, expected, zone, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Locale;

import org.hamcrest.TypeSafeDiagnosingMatcher;

Expand All @@ -17,11 +18,19 @@ public abstract class TemporalMatcher<T> extends TypeSafeDiagnosingMatcher<T> {
/**
* Creates a copy of this matcher using a specific time zone.
*
* @param zone the new time zone
* @param zone a {@link ZoneId}
* @return a copy of this matcher based on the new time zone
*/
public abstract TemporalMatcher<T> atZone(ZoneId zone);

/**
* Creates a copy of this matcher using a specific locale.
*
* @param locale a {@link Locale}
* @return a copy of this matcher using the new locale
*/
public abstract TemporalMatcher<T> atLocale(Locale locale);

/**
* Creates a copy of this matcher using a specific time offset.
*
Expand Down
37 changes: 37 additions & 0 deletions src/test/java/org/exparity/hamcrest/date/core/IsDayOfWeekTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static org.exparity.hamcrest.date.testutils.Dates.*;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Locale;

import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.LocalDateMatchers;
import org.exparity.hamcrest.date.LocalDateTimeMatchers;
Expand Down Expand Up @@ -467,6 +469,11 @@ public void isLocalDateNotMonday() {
assertThat(AUG_04_2015, LocalDateMatchers.isMonday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a lundi+?\\s but: the date is on a mardi+")
public void isLocalDateNotMondayInDifferentLocale() {
assertThat(AUG_04_2015, LocalDateMatchers.isMonday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateTuesday() {
assertThat(AUG_04_2015, LocalDateMatchers.isTuesday());
Expand All @@ -477,6 +484,11 @@ public void isLocalDateNotTuesday() {
assertThat(AUG_05_2015, LocalDateMatchers.isTuesday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a mardi+?\\s but: the date is on a mercredi+")
public void isLocalDateNotTuesdayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isTuesday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateWednesday() {
assertThat(AUG_05_2015, LocalDateMatchers.isWednesday());
Expand All @@ -487,6 +499,11 @@ public void isLocalDateNotWednesday() {
assertThat(AUG_06_2015, LocalDateMatchers.isWednesday());
}

@Test//(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = ASSERTION_PATTERN)
public void isLocalDateNotWednesdayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isWednesday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateThursday() {
assertThat(AUG_06_2015, LocalDateMatchers.isThursday());
Expand All @@ -497,6 +514,11 @@ public void isLocalDateNotThursday() {
assertThat(AUG_07_2015, LocalDateMatchers.isThursday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a jeudi+?\\s but: the date is on a mercredi+")
public void isLocalDateNotThursdayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isThursday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateFriday() {
assertThat(AUG_07_2015, LocalDateMatchers.isFriday());
Expand All @@ -507,6 +529,11 @@ public void isLocalDateNotFriday() {
assertThat(AUG_08_2015, LocalDateMatchers.isFriday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a vendredi+?\\s but: the date is on a mercredi+")
public void isLocalDateNotFridayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isFriday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateSaturday() {
assertThat(AUG_08_2015, LocalDateMatchers.isSaturday());
Expand All @@ -517,6 +544,11 @@ public void isLocalDateNotSaturday() {
assertThat(AUG_09_2015, LocalDateMatchers.isSaturday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a samedi+?\\s but: the date is on a mercredi+")
public void isLocalDateNotSaturdayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isSaturday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateSunday() {
assertThat(AUG_09_2015, LocalDateMatchers.isSunday());
Expand All @@ -527,6 +559,11 @@ public void isLocalDateNotSunday() {
assertThat(AUG_03_2015, LocalDateMatchers.isSunday());
}

@Test(expectedExceptions = AssertionError.class, expectedExceptionsMessageRegExp = "\\sExpected: the date is on a dimanche+?\\s but: the date is on a mercredi+")
public void isLocalDateNotSundayInDifferentLocale() {
assertThat(AUG_05_2015, LocalDateMatchers.isSunday().atLocale(Locale.FRENCH));
}

@Test
public void isLocalDateWeekday() {
assertThat(AUG_03_2015, LocalDateMatchers.isWeekday());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static org.exparity.hamcrest.date.testutils.ZoneIds.UTC;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.Locale;

import org.exparity.hamcrest.date.DateMatchers;
import org.exparity.hamcrest.date.DayMonthYear;
import org.exparity.hamcrest.date.LocalDateMatchers;
Expand Down Expand Up @@ -71,7 +73,7 @@ public void isDateSameDayEarlierLocalDate() {
public void isDateSameDayLaterLocalDate() {
assertThat(JUN_15_2012_11AM_UTC_AS_DATE, DateMatchers.sameDay(JUN_16_2012).atZone(UTC));
}

@Test
public void isDateSameDaySameLocalDate() {
assertThat(JUN_15_2012_11PM_UTC_AS_DATE, DateMatchers.sameDay(JUN_15_2012).atZone(UTC));
Expand Down Expand Up @@ -284,5 +286,4 @@ public void isOffsetDateTimeSameDayLaterDay() {
public void isOffsetDateTimeSameDayLaterSameDay() {
assertThat(AUG_04_2015_NOON_OFFSET_UTC, OffsetDateTimeMatchers.isDay(2015, AUGUST, 4, UTC).atZone(UTC));
}

}

0 comments on commit 2e6981c

Please sign in to comment.