public class LocalDateTimeAssert extends org.assertj.core.api.AbstractAssert<LocalDateTimeAssert,org.joda.time.LocalDateTime>
LocalDateTime
type.Modifier and Type | Field and Description |
---|---|
static String |
NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE |
Modifier | Constructor and Description |
---|---|
protected |
LocalDateTimeAssert(Class<LocalDateTimeAssert> selfType,
org.joda.time.LocalDateTime actual)
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
protected org.joda.time.LocalDateTime |
getActual() |
LocalDateTimeAssert |
hasDayOfMonth(int expectedDayOfMonth)
Verifies that the day of month of the actual
LocalDateTime is equal to the given day of month |
LocalDateTimeAssert |
hasHourOfDay(int expectedHourOfDay)
Verifies that the hour of the actual
DateTime is equal to the given hour |
LocalDateTimeAssert |
hasMillisOfSecond(int expectedMillisOfSecond)
Verifies that the milliseconds of the actual
LocalDateTime is equal to the given milliseconds |
LocalDateTimeAssert |
hasMinuteOfHour(int expectedMinuteOfHour)
Verifies that the minute of the actual
LocalDateTime is equal to the given minute |
LocalDateTimeAssert |
hasMonthOfYear(int expectedMonthOfYear)
Verifies that the month of the actual
LocalDateTime is equal to the given month |
LocalDateTimeAssert |
hasSecondOfMinute(int expectedSecondOfMinute)
Verifies that the seconds of the actual
LocalDateTime is equal to the given seconds |
LocalDateTimeAssert |
hasYear(int expectedYear)
Verifies that the year of the actual
LocalDateTime is equal to the given year |
LocalDateTimeAssert |
isAfter(org.joda.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is strictly after the given one. |
LocalDateTimeAssert |
isAfter(String localDateTimeAsString)
Same assertion as
isAfter(LocalDateTime) but the LocalDateTime is built from given a String that
must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isAfterOrEqualTo(org.joda.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is after or equals to the given one. |
LocalDateTimeAssert |
isAfterOrEqualTo(String localDateTimeAsString)
Same assertion as
isAfterOrEqualTo(LocalDateTime) but the LocalDateTime is built from given
String, which must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isBefore(org.joda.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is strictly before the given one. |
LocalDateTimeAssert |
isBefore(String localDateTimeAsString)
Same assertion as
isBefore(LocalDateTime) but the LocalDateTime is built from given String, which
must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isBeforeOrEqualTo(org.joda.time.LocalDateTime other)
Verifies that the actual
LocalDateTime is before or equals to the given one. |
LocalDateTimeAssert |
isBeforeOrEqualTo(String localDateTimeAsString)
Same assertion as
isBeforeOrEqualTo(LocalDateTime) but the LocalDateTime is built from given
String, which must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isEqualTo(String dateTimeAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be LocalDateTime ) but here you
pass LocalDateTime String representation that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isEqualToIgnoringHours(org.joda.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month and day fields (hour, minute, second and
millisecond fields are ignored in comparison). |
LocalDateTimeAssert |
isEqualToIgnoringMillis(org.joda.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day, hour, minute and second fields,
(millisecond fields are ignored in comparison). |
LocalDateTimeAssert |
isEqualToIgnoringMinutes(org.joda.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day and hour fields (minute, second and
millisecond fields are ignored in comparison). |
LocalDateTimeAssert |
isEqualToIgnoringSeconds(org.joda.time.LocalDateTime other)
Verifies that actual and given
LocalDateTime have same year, month, day, hour and minute fields (second and
millisecond fields are ignored in comparison). |
LocalDateTimeAssert |
isIn(String... dateTimesAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be LocalDateTime ) but here you
pass LocalDateTime String representations that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isNotEqualTo(String dateTimeAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be LocalDateTime ) but here you
pass LocalDateTime String representation that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
LocalDateTimeAssert |
isNotIn(String... dateTimesAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be LocalDateTime ) but here you
pass LocalDateTime String representations that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor. |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
public static final String NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE
protected LocalDateTimeAssert(Class<LocalDateTimeAssert> selfType, org.joda.time.LocalDateTime actual)
LocalDateTimeAssert
.selfType
- the "self type"actual
- the actual value to verifyprotected org.joda.time.LocalDateTime getActual()
public LocalDateTimeAssert hasYear(int expectedYear)
LocalDateTime
is equal to the given year
Example :
assertThat(new DateTime("2000-01-01")).hasYear(1);
expectedYear
- the given year.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the year of the actual DateTime
is not equal to the given year.public LocalDateTimeAssert hasMonthOfYear(int expectedMonthOfYear)
LocalDateTime
is equal to the given month
Example :
assertThat(new DateTime("2000-01-01")).hasMonthOfYear(1);
expectedMonthOfYear
- the given month.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the month of the actual LocalDateTime
is not equal to the given month.public LocalDateTimeAssert hasDayOfMonth(int expectedDayOfMonth)
LocalDateTime
is equal to the given day of month
Example :
assertThat(new LocalDateTime("2000-01-01")).hasDayOfMonth(1);
expectedDayOfMonth
- the given day of month.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the day of month of the actual LocalDateTime
is not equal to the given day of month.public LocalDateTimeAssert hasHourOfDay(int expectedHourOfDay)
DateTime
is equal to the given hour
Example :
assertThat(new LocalDateTime("2000-01-01T11:00:00")).hasHourOfDay(11);
expectedHourOfDay
- the given hour.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the hour of the actual LocalDateTime
is not equal to the given hour.public LocalDateTimeAssert hasMinuteOfHour(int expectedMinuteOfHour)
LocalDateTime
is equal to the given minute
Example :
assertThat(new LocalDateTime("2000-01-01T11:09:00")).hasMinuteOfHour(9);
expectedMinuteOfHour
- the given minute.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the minute of the actual LocalDateTime
is not equal to the given minute.public LocalDateTimeAssert hasSecondOfMinute(int expectedSecondOfMinute)
LocalDateTime
is equal to the given seconds
Example :
assertThat(new LocalDateTime("2000-01-01T11:09:39")).hasSecondOfMinute(39);
expectedSecondOfMinute
- the given seconds.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the seconds of the actual DateTime
is not equal to the given seconds.public LocalDateTimeAssert hasMillisOfSecond(int expectedMillisOfSecond)
LocalDateTime
is equal to the given milliseconds
Example :
assertThat(new LocalDateTime("2000-01-01T11:09:39.145")).hasMillisOfSecond(145);
expectedMillisOfSecond
- the given milliseconds.AssertionError
- if the actual LocalDateTime
is null
.AssertionError
- if the milliseconds of the actual LocalDateTime
is not equal to the given milliseconds.public LocalDateTimeAssert isBefore(org.joda.time.LocalDateTime other)
LocalDateTime
is strictly before the given one.
Example :
assertThat(new LocalDateTime("2000-01-01")).isBefore(new LocalDateTime("2000-01-02"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not strictly before the given one.public LocalDateTimeAssert isBefore(String localDateTimeAsString)
isBefore(LocalDateTime)
but the LocalDateTime
is built from given String, which
must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new LocalDateTime("2000-01-01")).isBefore("2000-01-02");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not strictly before the LocalDateTime
built
from given String.public LocalDateTimeAssert isBeforeOrEqualTo(org.joda.time.LocalDateTime other)
LocalDateTime
is before or equals to the given one.
Example :
assertThat(new LocalDateTime("2000-01-01")).isBeforeOrEqualTo(new LocalDateTime("2000-01-01"))
.isBeforeOrEqualTo(new LocalDateTime("2000-01-02"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not before or equals to the given one.public LocalDateTimeAssert isBeforeOrEqualTo(String localDateTimeAsString)
isBeforeOrEqualTo(LocalDateTime)
but the LocalDateTime
is built from given
String, which must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use String in comparison to avoid conversion
assertThat(new LocalDateTime("2000-01-01")).isBeforeOrEqualTo("2000-01-01")
.isBeforeOrEqualTo("2000-01-02");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not before or equals to the LocalDateTime
built from given String.public LocalDateTimeAssert isAfterOrEqualTo(org.joda.time.LocalDateTime other)
LocalDateTime
is after or equals to the given one.
Example :
assertThat(new LocalDateTime("2000-01-01")).isAfterOrEqualTo(new LocalDateTime("2000-01-01"))
.isAfterOrEqualTo(new LocalDateTime("1999-12-31"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not after or equals to the given one.public LocalDateTimeAssert isAfterOrEqualTo(String localDateTimeAsString)
isAfterOrEqualTo(LocalDateTime)
but the LocalDateTime
is built from given
String, which must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use String in comparison to avoid conversion
assertThat(new LocalDateTime("2000-01-01")).isAfterOrEqualTo("2000-01-01")
.isAfterOrEqualTo("1999-12-31");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not after or equals to the LocalDateTime
built from given String.public LocalDateTimeAssert isAfter(org.joda.time.LocalDateTime other)
LocalDateTime
is strictly after the given one.
Example :
assertThat(new LocalDateTime("2000-01-01")).isAfter(new LocalDateTime("1999-12-31"));
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is not strictly after the given one.public LocalDateTimeAssert isAfter(String localDateTimeAsString)
isAfter(LocalDateTime)
but the LocalDateTime
is built from given a String that
must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use String in comparison to avoid conversion
assertThat(new LocalDateTime("2000-01-01")).isAfter("1999-12-31");
localDateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not strictly after the LocalDateTime
built
from given String.public LocalDateTimeAssert isEqualTo(String dateTimeAsString)
AbstractAssert.isEqualTo(Object)
(where Object is expected to be LocalDateTime
) but here you
pass LocalDateTime
String representation that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new LocalDateTime("2000-01-01")).isEqualTo("2000-01-01");
dateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not equal to the LocalDateTime
built from
given String.public LocalDateTimeAssert isNotEqualTo(String dateTimeAsString)
AbstractAssert.isNotEqualTo(Object)
(where Object is expected to be LocalDateTime
) but here you
pass LocalDateTime
String representation that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use directly String in comparison to avoid a conversion
assertThat(new LocalDateTime("2000-01-01")).isNotEqualTo("2000-01-15");
dateTimeAsString
- String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is equal to the LocalDateTime
built from given
String.public LocalDateTimeAssert isIn(String... dateTimesAsString)
AbstractAssert.isIn(Object...)
(where Objects are expected to be LocalDateTime
) but here you
pass LocalDateTime
String representations that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use String based representation of LocalDateTime
assertThat(new LocalDateTime("2000-01-01")).isIn("1999-12-31", "2000-01-01");
dateTimesAsString
- String array representing LocalDateTime
s.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is not in the LocalDateTime
s built from given
Strings.public LocalDateTimeAssert isNotIn(String... dateTimesAsString)
AbstractAssert.isNotIn(Object...)
(where Objects are expected to be LocalDateTime
) but here you
pass LocalDateTime
String representations that must follow ISO DateTime format to allow calling LocalDateTime(Object)
constructor.
Example :
// use String based representation of LocalDateTime
assertThat(new LocalDateTime("2000-01-01")).isNotIn("1999-12-31", "2000-01-02");
dateTimesAsString
- Array of String representing a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDateTime
.AssertionError
- if the actual LocalDateTime
is in the LocalDateTime
s built from given
Strings.public LocalDateTimeAssert isEqualToIgnoringMillis(org.joda.time.LocalDateTime other)
LocalDateTime
have same year, month, day, hour, minute and second fields,
(millisecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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
LocalDateTime localDateTime1 = new LocalDateTime(2000, 1, 1, 0, 0, 1, 0);
LocalDateTime localDateTime2 = new LocalDateTime(2000, 1, 1, 0, 0, 1, 456);
assertThat(localDateTime1).isEqualToIgnoringMillis(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = new LocalDateTime(2000, 1, 1, 0, 0, 1, 0);
LocalDateTime localDateTimeB = new LocalDateTime(2000, 1, 1, 0, 0, 0, 999);
assertThat(localDateTimeA).isEqualToIgnoringMillis(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with milliseconds ignored.public LocalDateTimeAssert isEqualToIgnoringSeconds(org.joda.time.LocalDateTime other)
LocalDateTime
have same year, month, day, hour and minute fields (second and
millisecond fields are ignored in comparison).
Assertion can fail with LocalDateTimes 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
LocalDateTime localDateTime1 = new LocalDateTime(2000, 1, 1, 23, 50, 0, 0);
LocalDateTime localDateTime2 = new LocalDateTime(2000, 1, 1, 23, 50, 10, 456);
assertThat(localDateTime1).isEqualToIgnoringSeconds(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = new LocalDateTime(2000, 1, 1, 23, 50, 00, 000);
LocalDateTime localDateTimeB = new LocalDateTime(2000, 1, 1, 23, 49, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringSeconds(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with second and millisecond fields
ignored.public LocalDateTimeAssert isEqualToIgnoringMinutes(org.joda.time.LocalDateTime other)
LocalDateTime
have same year, month, day and hour fields (minute, second and
millisecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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
LocalDateTime localDateTime1 = new LocalDateTime(2000, 1, 1, 23, 50, 0, 0);
LocalDateTime localDateTime2 = new LocalDateTime(2000, 1, 1, 23, 00, 2, 7);
assertThat(localDateTime1).isEqualToIgnoringMinutes(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = new LocalDateTime(2000, 1, 1, 01, 00, 00, 000);
LocalDateTime localDateTimeB = new LocalDateTime(2000, 1, 1, 00, 59, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringMinutes(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal ignoring minute, second and millisecond
fields.public LocalDateTimeAssert isEqualToIgnoringHours(org.joda.time.LocalDateTime other)
LocalDateTime
have same year, month and day fields (hour, minute, second and
millisecond fields are ignored in comparison).
Assertion can fail with localDateTimes 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
LocalDateTime localDateTime1 = new LocalDateTime(2000, 1, 1, 23, 59, 59, 999);
LocalDateTime localDateTime2 = new LocalDateTime(2000, 1, 1, 00, 00, 00, 000);
assertThat(localDateTime1).isEqualToIgnoringHours(localDateTime2);
// failing assertions (even if time difference is only 1ms)
LocalDateTime localDateTimeA = new LocalDateTime(2000, 1, 2, 00, 00, 00, 000);
LocalDateTime localDateTimeB = new LocalDateTime(2000, 1, 1, 23, 59, 59, 999);
assertThat(localDateTimeA).isEqualToIgnoringHours(localDateTimeB);
other
- the given LocalDateTime
.AssertionError
- if the actual LocalDateTime
is null
.IllegalArgumentException
- if other LocalDateTime
is null
.AssertionError
- if the actual LocalDateTime
is are not equal with second and millisecond fields
ignored.Copyright © 2018 AssertJ. All rights reserved.