SELF
- the "self" type of this assertion class.public abstract class AbstractLocalDateAssert<SELF extends AbstractLocalDateAssert<SELF>> extends AbstractTemporalAssert<SELF,LocalDate>
LocalDate
type from new Date & Time API introduced in Java 8.Modifier and Type | Field and Description |
---|---|
static String |
NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE |
actual, info, myself, throwUnsupportedExceptionOnEquals
Modifier | Constructor and Description |
---|---|
protected |
AbstractLocalDateAssert(LocalDate actual,
Class<?> selfType)
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
SELF |
isAfter(LocalDate other)
Verifies that the actual
LocalDate is strictly after the given one. |
SELF |
isAfter(String localDateAsString)
Same assertion as
isAfter(LocalDate) but the LocalDate is built from given a String that
must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isAfterOrEqualTo(LocalDate other)
Verifies that the actual
LocalDate is after or equals to the given one. |
SELF |
isAfterOrEqualTo(String localDateAsString)
Same assertion as
isAfterOrEqualTo(LocalDate) but the LocalDate is built from given
String, which must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isBefore(LocalDate other)
Verifies that the actual
LocalDate is strictly before the given one. |
SELF |
isBefore(String localDateAsString)
Same assertion as
isBefore(LocalDate) but the LocalDate is built from given String, which
must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isBeforeOrEqualTo(LocalDate other)
Verifies that the actual
LocalDate is before or equals to the given one. |
SELF |
isBeforeOrEqualTo(String localDateAsString)
Same assertion as
isBeforeOrEqualTo(LocalDate) but the LocalDate is built from given
String, which must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isBetween(LocalDate startInclusive,
LocalDate endInclusive)
Verifies that the actual
LocalDate is in the [start, end] period (start and end included). |
SELF |
isBetween(String startInclusive,
String endInclusive)
Same assertion as
isBetween(LocalDate, LocalDate) but here you pass LocalDate String representations
which must follow ISO LocalDate format
to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isEqualTo(String localDateAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be LocalDate ) but here you
pass LocalDate String representation that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isIn(String... localDatesAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be LocalDate ) but here you
pass LocalDate String representations that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isNotEqualTo(String localDateAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be LocalDate ) but here you
pass LocalDate String representation that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isNotIn(String... localDatesAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be LocalDate ) but here you
pass LocalDate String representations that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isStrictlyBetween(LocalDate startExclusive,
LocalDate endExclusive)
Verifies that the actual
LocalDate is in the ]start, end[ period (start and end excluded). |
SELF |
isStrictlyBetween(String startExclusive,
String endExclusive)
Same assertion as
isStrictlyBetween(LocalDate, LocalDate) but here you pass LocalDate String representations
which must follow ISO LocalDate format
to allow calling LocalDate.parse(CharSequence) method. |
SELF |
isToday()
Verifies that the actual
LocalDate is today, that is matching current year, month and day. |
protected LocalDate |
parse(String localDateAsString)
Obtains an instance of
TEMPORAL from a string representation in ISO date format. |
getActual, isCloseTo, isCloseTo
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, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
public static final String NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE
protected AbstractLocalDateAssert(LocalDate actual, Class<?> selfType)
AbstractLocalDateAssert
.selfType
- the "self type"actual
- the actual value to verifypublic SELF isBefore(LocalDate other)
LocalDate
is strictly before the given one.
Example :
assertThat(parse("2000-01-01")).isBefore(parse("2000-01-02"));
other
- the given LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if other LocalDate
is null
.AssertionError
- if the actual LocalDate
is not strictly before the given one.public SELF isBefore(String localDateAsString)
isBefore(LocalDate)
but the LocalDate
is built from given String, which
must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01")).isBefore("2000-01-02");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not strictly before the LocalDate
built
from given String.public SELF isBeforeOrEqualTo(LocalDate other)
LocalDate
is before or equals to the given one.
Example :
assertThat(parse("2000-01-01")).isBeforeOrEqualTo(parse("2000-01-01"))
.isBeforeOrEqualTo(parse("2000-01-02"));
other
- the given LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if other LocalDate
is null
.AssertionError
- if the actual LocalDate
is not before or equals to the given one.public SELF isBeforeOrEqualTo(String localDateAsString)
isBeforeOrEqualTo(LocalDate)
but the LocalDate
is built from given
String, which must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01")).isBeforeOrEqualTo("2000-01-01")
.isBeforeOrEqualTo("2000-01-02");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not before or equals to the LocalDate
built from
given String.public SELF isAfterOrEqualTo(LocalDate other)
LocalDate
is after or equals to the given one.
Example :
assertThat(parse("2000-01-01")).isAfterOrEqualTo(parse("2000-01-01"))
.isAfterOrEqualTo(parse("1999-12-31"));
other
- the given LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if other LocalDate
is null
.AssertionError
- if the actual LocalDate
is not after or equals to the given one.public SELF isAfterOrEqualTo(String localDateAsString)
isAfterOrEqualTo(LocalDate)
but the LocalDate
is built from given
String, which must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01")).isAfterOrEqualTo("2000-01-01")
.isAfterOrEqualTo("1999-12-31");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not after or equals to the LocalDate
built from
given String.public SELF isAfter(LocalDate other)
LocalDate
is strictly after the given one.
Example :
assertThat(parse("2000-01-01")).isAfter(parse("1999-12-31"));
other
- the given LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if other LocalDate
is null
.AssertionError
- if the actual LocalDate
is not strictly after the given one.public SELF isAfter(String localDateAsString)
isAfter(LocalDate)
but the LocalDate
is built from given a String that
must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2000-01-01")).isAfter("1999-12-31");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not strictly after the LocalDate
built
from given String.public SELF isEqualTo(String localDateAsString)
AbstractAssert.isEqualTo(Object)
(where Object is expected to be LocalDate
) but here you
pass LocalDate
String representation that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01")).isEqualTo("2000-01-01");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not equal to the LocalDate
built from
given String.public SELF isNotEqualTo(String localDateAsString)
AbstractAssert.isNotEqualTo(Object)
(where Object is expected to be LocalDate
) but here you
pass LocalDate
String representation that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2000-01-01")).isNotEqualTo("2000-01-15");
localDateAsString
- String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is equal to the LocalDate
built from given
String.public SELF isIn(String... localDatesAsString)
AbstractAssert.isIn(Object...)
(where Objects are expected to be LocalDate
) but here you
pass LocalDate
String representations that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String based representation of LocalDate
assertThat(parse("2000-01-01")).isIn("1999-12-31", "2000-01-01");
localDatesAsString
- String array representing LocalDate
s.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is not in the LocalDate
s built from given
Strings.public SELF isNotIn(String... localDatesAsString)
AbstractAssert.isNotIn(Object...)
(where Objects are expected to be LocalDate
) but here you
pass LocalDate
String representations that must follow ISO LocalDate format to allow calling LocalDate.parse(CharSequence)
method.
Example :
// use String based representation of LocalDate
assertThat(parse("2000-01-01")).isNotIn("1999-12-31", "2000-01-02");
localDatesAsString
- Array of String representing a LocalDate
.AssertionError
- if the actual LocalDate
is null
.IllegalArgumentException
- if given String is null or can't be converted to a LocalDate
.AssertionError
- if the actual LocalDate
is in the LocalDate
s built from given
Strings.public SELF isToday()
LocalDate
is today, that is matching current year, month and day.
Example:
// assertion will pass
assertThat(LocalDate.now()).isToday();
// assertion will fail
assertThat(theFellowshipOfTheRing.getReleaseDate()).isToday();
AssertionError
- if the actual LocalDate
is null
.AssertionError
- if the actual LocalDate
is not today.public SELF isBetween(LocalDate startInclusive, LocalDate endInclusive)
LocalDate
is in the [start, end] period (start and end included).
Example:
LocalDate localDate = LocalDate.now();
// assertions succeed:
assertThat(localDate).isBetween(localDate.minusDays(1), localDate.plusDays(1))
.isBetween(localDate, localDate.plusDays(1))
.isBetween(localDate.minusDays(1), localDate)
.isBetween(localDate, localDate);
// assertions fail:
assertThat(localDate).isBetween(localDate.minusDays(10), localDate.minusDays(1));
assertThat(localDate).isBetween(localDate.plusDays(1), localDate.plusDays(10));
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in [start, end] period.public SELF isBetween(String startInclusive, String endInclusive)
isBetween(LocalDate, LocalDate)
but here you pass LocalDate
String representations
which must follow ISO LocalDate format
to allow calling LocalDate.parse(CharSequence)
method.
Example:
LocalDate firstOfJanuary2000 = LocalDate.parse("2000-01-01");
// assertions succeed:
assertThat(firstOfJanuary2000).isBetween("1999-01-01", "2001-01-01")
.isBetween("2000-01-01", "2001-01-01")
.isBetween("1999-01-01", "2000-01-01")
.isBetween("2000-01-01", "2000-01-01");
// assertion fails:
assertThat(firstOfJanuary2000).isBetween("1999-01-01", "1999-12-31");
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.DateTimeParseException
- if any of the given String can't be converted to a LocalDate
.AssertionError
- if the actual value is not in [start, end] period.public SELF isStrictlyBetween(LocalDate startExclusive, LocalDate endExclusive)
LocalDate
is in the ]start, end[ period (start and end excluded).
Example:
LocalDate localDate = LocalDate.now();
// assertion succeeds:
assertThat(localDate).isStrictlyBetween(localDate.minusDays(1), localDate.plusDays(1));
// assertions fail:
assertThat(localDate).isStrictlyBetween(localDate.minusDays(10), localDate.minusDays(1));
assertThat(localDate).isStrictlyBetween(localDate.plusDays(1), localDate.plusDays(10));
assertThat(localDate).isStrictlyBetween(localDate, localDate.plusDays(1));
assertThat(localDate).isStrictlyBetween(localDate.minusDays(1), localDate);
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in ]start, end[ period.public SELF isStrictlyBetween(String startExclusive, String endExclusive)
isStrictlyBetween(LocalDate, LocalDate)
but here you pass LocalDate
String representations
which must follow ISO LocalDate format
to allow calling LocalDate.parse(CharSequence)
method.
Example:
LocalDate firstOfJanuary2000 = LocalDate.parse("2000-01-01");
// assertion succeeds:
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01", "2001-01-01");
// assertions fail:
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01", "1999-12-31");
assertThat(firstOfJanuary2000).isStrictlyBetween("2000-01-01", "2001-01-01");
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01", "2000-01-01");
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.DateTimeParseException
- if any of the given String can't be converted to a LocalDate
.AssertionError
- if the actual value is not in ]start, end[ period.protected LocalDate parse(String localDateAsString)
TEMPORAL
from a string representation in ISO date format.parse
in class AbstractTemporalAssert<SELF extends AbstractLocalDateAssert<SELF>,LocalDate>
localDateAsString
- the string to parse, not nullTEMPORAL
, not nullCopyright © 2014–2019 AssertJ. All rights reserved.