Constructor and Description |
---|
Dates(ComparisonStrategy comparisonStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
assertHasDayOfMonth(AssertionInfo info,
Date actual,
int dayOfMonth)
Verifies that the actual
Date day of month is equal to the given day of month. |
void |
assertHasDayOfWeek(AssertionInfo info,
Date actual,
int dayOfWeek)
Verifies that the actual
Date day of week is equal to the given day of week. |
void |
assertHasHourOfDay(AssertionInfo info,
Date actual,
int hourOfDay)
Verifies that the actual
Date hour od day is equal to the given hour of day (24-hour clock). |
void |
assertHasMillisecond(AssertionInfo info,
Date actual,
int millisecond)
Verifies that the actual
Date millisecond is equal to the given millisecond. |
void |
assertHasMinute(AssertionInfo info,
Date actual,
int minute)
Verifies that the actual
Date minute is equal to the given minute. |
void |
assertHasMonth(AssertionInfo info,
Date actual,
int month)
Verifies that the actual
Date month is equal to the given month, month value starting at 1 (January=1,
February=2, ...). |
void |
assertHasSameTime(AssertionInfo info,
Date actual,
Date expected)
Verifies that the actual
Date has same time as the given Date . |
void |
assertHasSecond(AssertionInfo info,
Date actual,
int second)
Verifies that the actual
Date second is equal to the given second. |
void |
assertHasTime(AssertionInfo info,
Date actual,
long timestamp)
Verifies that the actual
Date time is equal to the given timestamp. |
void |
assertHasYear(AssertionInfo info,
Date actual,
int year)
Verifies that the actual
Date year is equal to the given year. |
void |
assertIsAfter(AssertionInfo info,
Date actual,
Date other)
Verifies that the actual
Date is strictly after the given one. |
void |
assertIsAfterOrEqualsTo(AssertionInfo info,
Date actual,
Date other)
Verifies that the actual
Date is after or equal to the given one. |
void |
assertIsAfterYear(AssertionInfo info,
Date actual,
int year)
Verifies that the actual
Date is strictly after the given year. |
void |
assertIsBefore(AssertionInfo info,
Date actual,
Date other)
Verifies that the actual
Date is strictly before the given one. |
void |
assertIsBeforeOrEqualsTo(AssertionInfo info,
Date actual,
Date other)
Verifies that the actual
Date is before or equal to the given one. |
void |
assertIsBeforeYear(AssertionInfo info,
Date actual,
int year)
Verifies that the actual
Date is strictly before the given year. |
void |
assertIsBetween(AssertionInfo info,
Date actual,
Date start,
Date end,
boolean inclusiveStart,
boolean inclusiveEnd)
Verifies that the actual
Date is in start:end period.start date belongs to the period if inclusiveStart is true. end date belongs to the period if inclusiveEnd is true. |
void |
assertIsCloseTo(AssertionInfo info,
Date actual,
Date other,
long deltaInMilliseconds)
Verifies that the actual
Date is close to the other date by less than delta, if difference is equals to delta it is
ok.Note that delta expressed in milliseconds. Use handy TimeUnit to convert a duration in milliseconds, for example you can express a delta of 5 seconds with TimeUnit.SECONDS.toMillis(5) . |
void |
assertIsEqualWithPrecision(AssertionInfo info,
Date actual,
Date other,
TimeUnit precision)
Verifies that the actual
Date is equal to the given one with precision. |
void |
assertIsInSameDayAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are chronologically in the same day of month (and thus in the same month and
year). |
void |
assertIsInSameHourAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are in the same hour (and thus in the same day of month, month
and year). |
void |
assertIsInSameHourWindowAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are chronologically in the same hour, day of month, month and year. |
void |
assertIsInSameMinuteAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are in the same minute, hour, day of month, month and year. |
void |
assertIsInSameMinuteWindowAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are chronologically in the same minute. |
void |
assertIsInSameMonthAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are chronologically in the same month (and thus in the same year). |
void |
assertIsInSameSecondAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are in the same second, minute, hour, day of month, month and year. |
void |
assertIsInSameSecondWindowAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are chronologically in the same second. |
void |
assertIsInSameYearAs(AssertionInfo info,
Date actual,
Date other)
Verifies that actual and given
Date are in the same year. |
void |
assertIsInTheFuture(AssertionInfo info,
Date actual)
Verifies that the actual
Date is strictly in the future. |
void |
assertIsInThePast(AssertionInfo info,
Date actual)
Verifies that the actual
Date is strictly in the past. |
void |
assertIsNotBetween(AssertionInfo info,
Date actual,
Date start,
Date end,
boolean inclusiveStart,
boolean inclusiveEnd)
Verifies that the actual
Date is not in start:end period..start date belongs to the period if inclusiveStart is true. end date belongs to the period if inclusiveEnd is true. |
void |
assertIsToday(AssertionInfo info,
Date actual)
Verifies that the actual
Date is today, by comparing only year, month and day of actual to today (ie. |
Comparator<?> |
getComparator() |
void |
hasSameTimeAs(AssertionInfo info,
Date actual,
Date date)
Verifies that the actual
Date is equal to the given date by comparing their time. |
static Dates |
instance()
Returns the singleton instance of this class.
|
public Dates(ComparisonStrategy comparisonStrategy)
public static Dates instance()
public Comparator<?> getComparator()
public void assertIsBefore(AssertionInfo info, Date actual, Date other)
Date
is strictly before the given one.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the other date to compare actual with.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
is not strictly before the given one.public void assertIsBeforeOrEqualsTo(AssertionInfo info, Date actual, Date other)
Date
is before or equal to the given one.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the other date to compare actual with.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
is not before or equal to the given one.public void assertIsAfter(AssertionInfo info, Date actual, Date other)
Date
is strictly after the given one.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
is not strictly after the given one.public void assertIsAfterOrEqualsTo(AssertionInfo info, Date actual, Date other)
Date
is after or equal to the given one.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
is not after or equal to the given one.public void assertIsEqualWithPrecision(AssertionInfo info, Date actual, Date other, TimeUnit precision)
Date
is equal to the given one with precision.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date.precision
- maximum precision for the comparison.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
is not equal to the given one.public void assertIsBetween(AssertionInfo info, Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd)
Date
is in start:end period.info
- contains information about the assertion.actual
- the "actual" Date
.start
- the period start, expected not to be null.end
- the period end, expected not to be null.inclusiveStart
- whether to include start date in period.inclusiveEnd
- whether to include end date in period.AssertionError
- if actual
is null
.NullPointerException
- if start Date
is null
.NullPointerException
- if end Date
is null
.AssertionError
- if the actual Date
is not in start:end period.public void assertIsNotBetween(AssertionInfo info, Date actual, Date start, Date end, boolean inclusiveStart, boolean inclusiveEnd)
Date
is not in start:end period..info
- contains information about the assertion.actual
- the "actual" Date
.start
- the period start, expected not to be null.end
- the period end, expected not to be null.inclusiveStart
- whether to include start date in period.inclusiveEnd
- whether to include end date in period.AssertionError
- if actual
is null
.NullPointerException
- if start Date
is null
.NullPointerException
- if end Date
is null
.AssertionError
- if the actual Date
is in start:end period.public void assertIsInThePast(AssertionInfo info, Date actual)
Date
is strictly in the past.info
- contains information about the assertion.actual
- the "actual" Date
.AssertionError
- if actual
is null
.AssertionError
- if the actual Date
is not in the past.public void assertIsToday(AssertionInfo info, Date actual)
Date
is today, by comparing only year, month and day of actual to today (ie. we don't check
hours).info
- contains information about the assertion.actual
- the "actual" Date
.AssertionError
- if actual
is null
.AssertionError
- if the actual Date
is not today.public void assertIsInTheFuture(AssertionInfo info, Date actual)
Date
is strictly in the future.info
- contains information about the assertion.actual
- the "actual" Date
.AssertionError
- if actual
is null
.AssertionError
- if the actual Date
is not in the future.public void assertIsBeforeYear(AssertionInfo info, Date actual, int year)
Date
is strictly before the given year.info
- contains information about the assertion.actual
- the "actual" Date
.year
- the year to compare actual year toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
year is after or equal to the given year.public void assertIsAfterYear(AssertionInfo info, Date actual, int year)
Date
is strictly after the given year.info
- contains information about the assertion.actual
- the "actual" Date
.year
- the year to compare actual year toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
year is before or equal to the given year.public void assertHasYear(AssertionInfo info, Date actual, int year)
Date
year is equal to the given year.year
- the year to compare actual year toinfo
- contains information about the assertion.actual
- the "actual" Date
.AssertionError
- if actual
is null
.AssertionError
- if the actual Date
year is not equal to the given year.public void assertHasMonth(AssertionInfo info, Date actual, int month)
Date
month is equal to the given month, month value starting at 1 (January=1,
February=2, ...).info
- contains information about the assertion.actual
- the "actual" Date
.month
- the month to compare actual month to, see Calendar.MONTH
for valid valuesAssertionError
- if actual
is null
.AssertionError
- if the actual Date
month is not equal to the given month.public void assertHasDayOfMonth(AssertionInfo info, Date actual, int dayOfMonth)
Date
day of month is equal to the given day of month.info
- contains information about the assertion.actual
- the "actual" Date
.dayOfMonth
- the day of month to compare actual day of month toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
month is not equal to the given day of month.public void assertHasDayOfWeek(AssertionInfo info, Date actual, int dayOfWeek)
Date
day of week is equal to the given day of week.info
- contains information about the assertion.actual
- the "actual" Date
.dayOfWeek
- the day of week to compare actual day of week to, see Calendar.DAY_OF_WEEK
for valid valuesAssertionError
- if actual
is null
.AssertionError
- if the actual Date
week is not equal to the given day of week.public void assertHasHourOfDay(AssertionInfo info, Date actual, int hourOfDay)
Date
hour od day is equal to the given hour of day (24-hour clock).info
- contains information about the assertion.actual
- the "actual" Date
.hourOfDay
- the hour of day to compare actual hour of day to (24-hour clock)AssertionError
- if actual
is null
.AssertionError
- if the actual Date
hour is not equal to the given hour.public void assertHasMinute(AssertionInfo info, Date actual, int minute)
Date
minute is equal to the given minute.info
- contains information about the assertion.actual
- the "actual" Date
.minute
- the minute to compare actual minute toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
minute is not equal to the given minute.public void assertHasSecond(AssertionInfo info, Date actual, int second)
Date
second is equal to the given second.info
- contains information about the assertion.actual
- the "actual" Date
.second
- the second to compare actual second toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
second is not equal to the given second.public void assertHasMillisecond(AssertionInfo info, Date actual, int millisecond)
Date
millisecond is equal to the given millisecond.info
- contains information about the assertion.actual
- the "actual" Date
.millisecond
- the millisecond to compare actual millisecond toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
millisecond is not equal to the given millisecond.public void assertIsInSameYearAs(AssertionInfo info, Date actual, Date other)
Date
are in the same year.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not in the same year.public void assertIsInSameMonthAs(AssertionInfo info, Date actual, Date other)
Date
are chronologically in the same month (and thus in the same year).info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same month.public void assertIsInSameDayAs(AssertionInfo info, Date actual, Date other)
Date
are chronologically in the same day of month (and thus in the same month and
year).info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same day of month.public void assertIsInSameHourAs(AssertionInfo info, Date actual, Date other)
Date
are in the same hour (and thus in the same day of month, month
and year).info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same hour.public void assertIsInSameHourWindowAs(AssertionInfo info, Date actual, Date other)
Date
are chronologically in the same hour, day of month, month and year.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same hour.public void assertIsInSameMinuteAs(AssertionInfo info, Date actual, Date other)
Date
are in the same minute, hour, day of month, month and year.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same minute.public void assertIsInSameMinuteWindowAs(AssertionInfo info, Date actual, Date other)
Date
are chronologically in the same minute.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same minute.public void assertIsInSameSecondAs(AssertionInfo info, Date actual, Date other)
Date
are in the same second, minute, hour, day of month, month and year.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same second.public void assertIsInSameSecondWindowAs(AssertionInfo info, Date actual, Date other)
Date
are chronologically in the same second.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.AssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if actual and given Date
are not chronologically speaking in the same second.public void assertIsCloseTo(AssertionInfo info, Date actual, Date other, long deltaInMilliseconds)
Date
is close to the other date by less than delta, if difference is equals to delta it is
ok.TimeUnit.SECONDS.toMillis(5)
.info
- contains information about the assertion.actual
- the "actual" Date
.other
- the given Date
to compare actual Date
to.deltaInMilliseconds
- the delta used for date comparison, expressed in millisecondsAssertionError
- if actual
is null
.NullPointerException
- if other Date
is null
.AssertionError
- if the actual Date
week is not close to the given date by less than delta.public void assertHasTime(AssertionInfo info, Date actual, long timestamp)
Date
time is equal to the given timestamp.info
- contains information about the assertion.actual
- the "actual" Date
.timestamp
- the timestamp to compare actual time toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
time is not equal to the given timestamp.public void assertHasSameTime(AssertionInfo info, Date actual, Date expected)
Date
has same time as the given Date
.info
- contains information about the assertion.actual
- the "actual" Date
.expected
- the "expected" Date
to compare actual time toAssertionError
- if actual
is null
.AssertionError
- if expected
is null
.AssertionError
- if the actual Date
time is not equal to the given Date
.public void hasSameTimeAs(AssertionInfo info, Date actual, Date date)
Date
is equal to the given date by comparing their time.info
- contains information about the assertion.actual
- the "actual" Date
.date
- the date to compare actual time toAssertionError
- if actual
is null
.AssertionError
- if the actual Date
time is not equal to the given date time.NullPointerException
- if other Date
is null
.Copyright © 2014–2019 AssertJ. All rights reserved.