public class DateTimeAssert extends org.assertj.core.api.AbstractAssert<DateTimeAssert,org.joda.time.DateTime>
DateTime type.| Modifier and Type | Field and Description |
|---|---|
static String |
NULL_DATE_TIME_PARAMETER_MESSAGE |
| Modifier | Constructor and Description |
|---|---|
protected |
DateTimeAssert(Class<DateTimeAssert> selfType,
org.joda.time.DateTime actual)
Creates a new
. |
| Modifier and Type | Method and Description |
|---|---|
protected org.joda.time.DateTime |
getActual() |
DateTimeAssert |
isAfter(org.joda.time.DateTime other)
Verifies that the actual
DateTime is strictly after the given one. |
DateTimeAssert |
isAfter(String dateTimeAsString)
Same assertion as
isAfter(DateTime) but the DateTime is built from given String, which must follow
ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isAfterOrEqualTo(org.joda.time.DateTime other)
Verifies that the actual
DateTime is after or equals to the given one. |
DateTimeAssert |
isAfterOrEqualTo(String dateTimeAsString)
Same assertion as
isAfterOrEqualTo(DateTime) but the DateTime is built from given String, which
must follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isBefore(org.joda.time.DateTime other)
Verifies that the actual
DateTime is strictly before the given one. |
DateTimeAssert |
isBefore(String dateTimeAsString)
Same assertion as
isBefore(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isBeforeOrEqualTo(org.joda.time.DateTime other)
Verifies that the actual
DateTime is before or equals to the given one. |
DateTimeAssert |
isBeforeOrEqualTo(String dateTimeAsString)
Same assertion as
isBeforeOrEqualTo(DateTime) but the DateTime is built from given String, which
must follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isEqualTo(org.joda.time.DateTime expected)
Verifies that the actual
DateTime is equal to the given one in the actual's DateTimeZone. |
DateTimeAssert |
isEqualTo(String dateTimeAsString)
Same assertion as
isEqualTo(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isEqualToIgnoringHours(org.joda.time.DateTime other)
Verifies that actual and given
DateTime have same year, month and day fields (hour, minute, second and
millisecond fields are ignored in comparison). |
DateTimeAssert |
isEqualToIgnoringMillis(org.joda.time.DateTime other)
Verifies that actual and given
DateTime have same year, month, day, hour, minute and second fields,
(millisecond fields are ignored in comparison). |
DateTimeAssert |
isEqualToIgnoringMinutes(org.joda.time.DateTime other)
Verifies that actual and given
DateTime have same year, month, day and hour fields (minute, second and
millisecond fields are ignored in comparison). |
DateTimeAssert |
isEqualToIgnoringSeconds(org.joda.time.DateTime other)
Verifies that actual and given
DateTime have same year, month, day, hour and minute fields (second and
millisecond fields are ignored in comparison). |
DateTimeAssert |
isIn(org.joda.time.DateTime... expected)
Verifies that the actual
DateTime is equal to one of the given DateTime in the actual DateTime's
DateTimeZone. |
DateTimeAssert |
isIn(String... dateTimesAsString)
Same assertion as
isIn(DateTime...) but the DateTime are built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isNotEqualTo(org.joda.time.DateTime expected)
Verifies that the actual value is not equal to the given one in the actual DateTime's DateTimeZone.
|
DateTimeAssert |
isNotEqualTo(String dateTimeAsString)
Same assertion as
isNotEqualTo(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor. |
DateTimeAssert |
isNotIn(org.joda.time.DateTime... expected)
Verifies that the actual
DateTime is equal to one of the given DateTime in the actual DateTime's
DateTimeZone. |
DateTimeAssert |
isNotIn(String... dateTimesAsString)
Same assertion as
isNotIn(org.joda.time.DateTime...) but the DateTime is built from given String,
which must follow ISO DateTime format to allow calling DateTime(Object) constructor. |
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparatorpublic static final String NULL_DATE_TIME_PARAMETER_MESSAGE
protected DateTimeAssert(Class<DateTimeAssert> selfType, org.joda.time.DateTime actual)
DateTimeAssert.selfType - the "self type"actual - the actual value to verifyprotected org.joda.time.DateTime getActual()
public DateTimeAssert isBefore(org.joda.time.DateTime other)
DateTime is strictly before the given one.
Example :
assertThat(new DateTime("2000-01-01")).isBefore(new DateTime("2000-01-02"));
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is not strictly before the given one.public DateTimeAssert isBefore(String dateTimeAsString)
isBefore(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check..
Example :
// use directly String in comparison to avoid a conversion
assertThat(new DateTime("2000-01-01")).isBefore("2000-01-02");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not strictly before the DateTime built from given
String.public DateTimeAssert isBeforeOrEqualTo(org.joda.time.DateTime other)
DateTime is before or equals to the given one.
Example :
assertThat(new DateTime("2000-01-01")).isBeforeOrEqualTo(new DateTime("2000-01-01"))
.isBeforeOrEqualTo(new DateTime("2000-01-02"));
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is not before or equals to the given one.public DateTimeAssert isBeforeOrEqualTo(String dateTimeAsString)
isBeforeOrEqualTo(DateTime) but the DateTime is built from given String, which
must follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check..
Example :
// use String in comparison to avoid conversion
assertThat(new DateTime("2000-01-01")).isBeforeOrEqualTo("2000-01-01")
.isBeforeOrEqualTo("2000-01-02");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not before or equals to the DateTime built from
given String.public DateTimeAssert isAfterOrEqualTo(org.joda.time.DateTime other)
DateTime is after or equals to the given one.
Example :
assertThat(new DateTime("2000-01-01")).isAfterOrEqualTo(new DateTime("2000-01-01"))
.isAfterOrEqualTo(new DateTime("1999-12-31"));
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is not after or equals to the given one.public DateTimeAssert isAfterOrEqualTo(String dateTimeAsString)
isAfterOrEqualTo(DateTime) but the DateTime is built from given String, which
must follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check.
Example :
// use String in comparison to avoid conversion
assertThat(new DateTime("2000-01-01")).isAfterOrEqualTo("2000-01-01")
.isAfterOrEqualTo("1999-12-31");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not after or equals to the DateTime built from
given String.public DateTimeAssert isAfter(org.joda.time.DateTime other)
DateTime is strictly after the given one.
Example :
assertThat(new DateTime("2000-01-01")).isAfter(new DateTime("1999-12-31"));
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is not strictly after the given one.public DateTimeAssert isAfter(String dateTimeAsString)
isAfter(DateTime) but the DateTime is built from given String, which must follow
ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check.
Example :
// use String in comparison to avoid conversion
assertThat(new DateTime("2000-01-01")).isAfter("1999-12-31");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not strictly after the DateTime built from given
String.public DateTimeAssert isEqualToIgnoringMillis(org.joda.time.DateTime other)
DateTime have same year, month, day, hour, minute and second fields,
(millisecond fields are ignored in comparison).
Note that given DateTime is converted in the actual's DateTimeZone before comparison.
Assertion can fail with dateTimes in same chronological millisecond time window, e.g :
2000-01-01T00:00:01.000 and 2000-01-01T00:00:00.999.
Assertion fails as second fields differ even if time difference is only 1ms.
Code example :
// successfull assertions DateTime dateTime1 = new DateTime(2000, 1, 1, 0, 0, 1, 0); DateTime dateTime2 = new DateTime(2000, 1, 1, 0, 0, 1, 456); assertThat(dateTime1).isEqualToIgnoringMillis(dateTime2); // failing assertions (even if time difference is only 1ms) DateTime dateTimeA = new DateTime(2000, 1, 1, 0, 0, 1, 0); DateTime dateTimeB = new DateTime(2000, 1, 1, 0, 0, 0, 999); assertThat(dateTimeA).isEqualToIgnoringMillis(dateTimeB);
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is are not equal with milliseconds ignored.public DateTimeAssert isEqualToIgnoringSeconds(org.joda.time.DateTime other)
DateTime have same year, month, day, hour and minute fields (second and
millisecond fields are ignored in comparison).
Note that given DateTime is converted in the actual's DateTimeZone before comparison.
Assertion can fail with DateTimes in same chronological second time window, e.g :
2000-01-01T00:01:00.000 and 2000-01-01T00:00:59.000.
Assertion fails as minute fields differ even if time difference is only 1s.
Code example :
// successfull assertions DateTime dateTime1 = new DateTime(2000, 1, 1, 23, 50, 0, 0); DateTime dateTime2 = new DateTime(2000, 1, 1, 23, 50, 10, 456); assertThat(dateTime1).isEqualToIgnoringSeconds(dateTime2); // failing assertions (even if time difference is only 1ms) DateTime dateTimeA = new DateTime(2000, 1, 1, 23, 50, 00, 000); DateTime dateTimeB = new DateTime(2000, 1, 1, 23, 49, 59, 999); assertThat(dateTimeA).isEqualToIgnoringSeconds(dateTimeB);
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is are not equal with second and millisecond fields ignored.public DateTimeAssert isEqualToIgnoringMinutes(org.joda.time.DateTime other)
DateTime have same year, month, day and hour fields (minute, second and
millisecond fields are ignored in comparison).
Note that given DateTime is converted in the actual's DateTimeZone before comparison.
Assertion can fail with dateTimes in same chronological second time window, e.g :
2000-01-01T01:00:00.000 and 2000-01-01T00:59:59.000.
Time difference is only 1s but hour fields differ.
Code example :
// successfull assertions DateTime dateTime1 = new DateTime(2000, 1, 1, 23, 50, 0, 0); DateTime dateTime2 = new DateTime(2000, 1, 1, 23, 00, 2, 7); assertThat(dateTime1).isEqualToIgnoringMinutes(dateTime2); // failing assertions (even if time difference is only 1ms) DateTime dateTimeA = new DateTime(2000, 1, 1, 01, 00, 00, 000); DateTime dateTimeB = new DateTime(2000, 1, 1, 00, 59, 59, 999); assertThat(dateTimeA).isEqualToIgnoringMinutes(dateTimeB);
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is are not equal ignoring minute, second and millisecond
fields.public DateTimeAssert isEqualToIgnoringHours(org.joda.time.DateTime other)
DateTime have same year, month and day fields (hour, minute, second and
millisecond fields are ignored in comparison).
Note that given DateTime is converted in the actual's DateTimeZone before comparison.
Assertion can fail with dateTimes in same chronological minute time window, e.g :
2000-01-01T23:59:00.000 and 2000-01-02T00:00:00.000.
Time difference is only 1min but day fields differ.
Code example :
// successfull assertions DateTime dateTime1 = new DateTime(2000, 1, 1, 23, 59, 59, 999); DateTime dateTime2 = new DateTime(2000, 1, 1, 00, 00, 00, 000); assertThat(dateTime1).isEqualToIgnoringHours(dateTime2); // failing assertions (even if time difference is only 1ms) DateTime dateTimeA = new DateTime(2000, 1, 2, 00, 00, 00, 000); DateTime dateTimeB = new DateTime(2000, 1, 1, 23, 59, 59, 999); assertThat(dateTimeA).isEqualToIgnoringHours(dateTimeB);
other - the given DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if other DateTime is null.AssertionError - if the actual DateTime is are not equal with second and millisecond fields ignored.public DateTimeAssert isEqualTo(org.joda.time.DateTime expected)
DateTime is equal to the given one in the actual's DateTimeZone.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new DateTime("2000-01-01")).isEqualTo(new DateTime("2000-01-01"));
expected - the given value to compare the actual value to.this assertion object.AssertionError - if the actual DateTime is not equal to the DateTime in the actual DateTime's
DateTimeZone.public DateTimeAssert isEqualTo(String dateTimeAsString)
isEqualTo(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new DateTime("2000-01-01")).isEqualTo("2000-01-01");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not equal to the DateTime built from given String.public DateTimeAssert isNotEqualTo(org.joda.time.DateTime expected)
Example :
assertThat(new DateTime("2000-01-01")).isNotEqualTo(new DateTime("2000-01-15"));
expected - the given value to compare the actual value to.this assertion object.AssertionError - if the actual DateTime is equal to the DateTime in the actual DateTime's
DateTimeZone.public DateTimeAssert isNotEqualTo(String dateTimeAsString)
isNotEqualTo(DateTime) but the DateTime is built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTime created from the given String is built in the DateTimeZone of the
DateTime to check.. DateTime.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new DateTime("2000-01-01")).isNotEqualTo("2000-01-15");
dateTimeAsString - String representing a DateTime.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is equal to the DateTime built from given String.public DateTimeAssert isIn(org.joda.time.DateTime... expected)
DateTime is equal to one of the given DateTime in the actual DateTime's
DateTimeZone.
Example :
assertThat(new DateTime("2000-01-01")).isIn(new DateTime("1999-12-31"), new DateTime("2000-01-01"));
expected - the given DateTimes to compare the actual value to.this assertion object.AssertionError - if the actual DateTime is null.AssertionError - if the actual DateTime is not in the given DateTimes.public DateTimeAssert isIn(String... dateTimesAsString)
isIn(DateTime...) but the DateTime are built from given String, which must
follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTimes created from the given Strings are built in the DateTimeZone of the
DateTime to check..
Example :
// use String based representation of LocalDateTime
assertThat(new DateTime("2000-01-01")).isIn("1999-12-31", "2000-01-01");
dateTimesAsString - String array representing DateTimes.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not in the DateTimes built from given Strings.public DateTimeAssert isNotIn(org.joda.time.DateTime... expected)
DateTime is equal to one of the given DateTime in the actual DateTime's
DateTimeZone.
Example :
assertThat(new DateTime("2000-01-01")).isNotIn(new DateTime("1999-12-31"), new DateTime("2000-01-02"));
expected - the given DateTimes to compare the actual value to.this assertion object.AssertionError - if the actual DateTime is null.AssertionError - if the actual DateTime is not in the given DateTimes.public DateTimeAssert isNotIn(String... dateTimesAsString)
isNotIn(org.joda.time.DateTime...) but the DateTime is built from given String,
which must follow ISO DateTime format to allow calling DateTime(Object) constructor.
Note that the DateTimes created from the given Strings are built in the DateTimeZone of the
DateTime to check..
Example :
// use String based representation of DateTime
assertThat(new DateTime("2000-01-01")).isNotIn("1999-12-31", "2000-01-02");
dateTimesAsString - String array representing DateTimes.AssertionError - if the actual DateTime is null.IllegalArgumentException - if given String is null or can't be converted to a DateTime.AssertionError - if the actual DateTime is not equal to the DateTime built from given String.Copyright © 2013 AssertJ. All Rights Reserved.