Package org.assertj.core.api
Class AbstractLocalDateAssert<SELF extends AbstractLocalDateAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,LocalDate>
org.assertj.core.api.AbstractTemporalAssert<SELF,LocalDate>
org.assertj.core.api.AbstractLocalDateAssert<SELF>
- Type Parameters:
SELF
- the "self" type of this assertion class.
- All Implemented Interfaces:
Assert<SELF,
,LocalDate> Descriptable<SELF>
,ExtensionPoints<SELF,
LocalDate>
- Direct Known Subclasses:
LocalDateAssert
public abstract class AbstractLocalDateAssert<SELF extends AbstractLocalDateAssert<SELF>>
extends AbstractTemporalAssert<SELF,LocalDate>
Assertions for
LocalDate
type from new Date & Time API introduced in Java 8.-
Field Summary
FieldsFields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractLocalDateAssert
(LocalDate actual, Class<?> selfType) Creates a new
.AbstractLocalDateAssert
-
Method Summary
Modifier and TypeMethodDescriptionhasDayOfMonth
(int day) Verifies that actualLocalDate
is on the given day.Verifies that actualLocalDate
is in the given month.hasMonthValue
(int month) Verifies that actualLocalDate
is in the given month.hasYear
(int year) Verifies that actualLocalDate
is in the given year.Same assertion asisAfter(LocalDate)
but theLocalDate
is built from given a String that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Verifies that the actualLocalDate
is strictly after the given one.isAfterOrEqualTo
(String localDateAsString) Same assertion asisAfterOrEqualTo(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.isAfterOrEqualTo
(LocalDate other) Verifies that the actualLocalDate
is after or equals to the given one.Same assertion asisBefore(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Verifies that the actualLocalDate
is strictly before the given one.isBeforeOrEqualTo
(String localDateAsString) Same assertion asisBeforeOrEqualTo(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.isBeforeOrEqualTo
(LocalDate other) Verifies that the actualLocalDate
is before or equals to the given one.Same assertion asisBetween(LocalDate, LocalDate)
but here you passLocalDate
String representations which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Verifies that the actualLocalDate
is in the [start, end] period (start and end included).Same assertion asAbstractAssert.isEqualTo(Object)
(where Object is expected to beLocalDate
) but here you passLocalDate
String representation that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Same assertion asAbstractAssert.isIn(Object...)
(where Objects are expected to beLocalDate
) but here you passLocalDate
String representations that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Verifies that the actualLocalDate
is strictly in the future.Verifies that the actualLocalDate
is strictly in the past.isNotEqualTo
(String localDateAsString) Same assertion asAbstractAssert.isNotEqualTo(Object)
(where Object is expected to beLocalDate
) but here you passLocalDate
String representation that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Same assertion asAbstractAssert.isNotIn(Object...)
(where Objects are expected to beLocalDate
) but here you passLocalDate
String representations that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.isStrictlyBetween
(String startExclusive, String endExclusive) Same assertion asisStrictlyBetween(LocalDate, LocalDate)
but here you passLocalDate
String representations which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.isStrictlyBetween
(LocalDate startExclusive, LocalDate endExclusive) Verifies that the actualLocalDate
is in the ]start, end[ period (start and end excluded).isToday()
Verifies that the actualLocalDate
is today, that is matching current year, month and day.protected LocalDate
Obtains an instance ofTEMPORAL
from a string representation in ISO date format.Methods inherited from class org.assertj.core.api.AbstractTemporalAssert
isCloseTo, isCloseTo, usingComparator, usingComparator, usingDefaultComparator
Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Field Details
-
NULL_LOCAL_DATE_TIME_PARAMETER_MESSAGE
- See Also:
-
-
Constructor Details
-
AbstractLocalDateAssert
Creates a new
.AbstractLocalDateAssert
- Parameters:
actual
- the actual value to verifyselfType
- the "self type"
-
-
Method Details
-
isBefore
Verifies that the actualLocalDate
is strictly before the given one.Example :
assertThat(parse("2000-01-01")).isBefore(parse("2000-01-02"));
- Parameters:
other
- the givenLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if otherLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not strictly before the given one.
-
isBefore
Same assertion asisBefore(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.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");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not strictly before theLocalDate
built from given String.
-
isBeforeOrEqualTo
Verifies that the actualLocalDate
is before or equals to the given one.Example :
assertThat(parse("2000-01-01")).isBeforeOrEqualTo(parse("2000-01-01")) .isBeforeOrEqualTo(parse("2000-01-02"));
- Parameters:
other
- the givenLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if otherLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not before or equals to the given one.
-
isBeforeOrEqualTo
Same assertion asisBeforeOrEqualTo(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01")).isBeforeOrEqualTo("2000-01-01") .isBeforeOrEqualTo("2000-01-02");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not before or equals to theLocalDate
built from given String.
-
isAfterOrEqualTo
Verifies that the actualLocalDate
is after or equals to the given one.Example :
assertThat(parse("2000-01-01")).isAfterOrEqualTo(parse("2000-01-01")) .isAfterOrEqualTo(parse("1999-12-31"));
- Parameters:
other
- the givenLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if otherLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not after or equals to the given one.
-
isAfterOrEqualTo
Same assertion asisAfterOrEqualTo(LocalDate)
but theLocalDate
is built from given String, which must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01")).isAfterOrEqualTo("2000-01-01") .isAfterOrEqualTo("1999-12-31");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not after or equals to theLocalDate
built from given String.
-
isAfter
Verifies that the actualLocalDate
is strictly after the given one.Example :
assertThat(parse("2000-01-01")).isAfter(parse("1999-12-31"));
- Parameters:
other
- the givenLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if otherLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not strictly after the given one.
-
isAfter
Same assertion asisAfter(LocalDate)
but theLocalDate
is built from given a String that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01")).isAfter("1999-12-31");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not strictly after theLocalDate
built from given String.
-
isEqualTo
Same assertion asAbstractAssert.isEqualTo(Object)
(where Object is expected to beLocalDate
) but here you passLocalDate
String representation that must follow ISO LocalDate format to allow callingLocalDate.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");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not equal to theLocalDate
built from given String.
-
isNotEqualTo
Same assertion asAbstractAssert.isNotEqualTo(Object)
(where Object is expected to beLocalDate
) but here you passLocalDate
String representation that must follow ISO LocalDate format to allow callingLocalDate.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");
- Parameters:
localDateAsString
- String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is equal to theLocalDate
built from given String.
-
isIn
Same assertion asAbstractAssert.isIn(Object...)
(where Objects are expected to beLocalDate
) but here you passLocalDate
String representations that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Example :
// use String based representation of LocalDate assertThat(parse("2000-01-01")).isIn("1999-12-31", "2000-01-01");
- Parameters:
localDatesAsString
- String array representingLocalDate
s.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is not in theLocalDate
s built from given Strings.
-
isNotIn
Same assertion asAbstractAssert.isNotIn(Object...)
(where Objects are expected to beLocalDate
) but here you passLocalDate
String representations that must follow ISO LocalDate format to allow callingLocalDate.parse(CharSequence)
method.Example :
// use String based representation of LocalDate assertThat(parse("2000-01-01")).isNotIn("1999-12-31", "2000-01-02");
- Parameters:
localDatesAsString
- Array of String representing aLocalDate
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.IllegalArgumentException
- if given String is null or can't be converted to aLocalDate
.AssertionError
- if the actualLocalDate
is in theLocalDate
s built from given Strings.
-
isInThePast
Verifies that the actualLocalDate
is strictly in the past.Example:
// assertion succeeds: assertThat(LocalDate.now().minusDays(1)).isInThePast();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not in the past.- Since:
- 3.25.0
-
isToday
Verifies that the actualLocalDate
is today, that is matching current year, month and day.Example:
// assertion succeeds: assertThat(LocalDate.now()).isToday(); // assertion will fail assertThat(theFellowshipOfTheRing.getReleaseDate()).isToday();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not today.
-
isInTheFuture
Verifies that the actualLocalDate
is strictly in the future.Example:
// assertion succeeds: assertThat(LocalDate.now().plusDays(1)).isInTheFuture();
- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not in the future.- Since:
- 3.25.0
-
isBetween
Verifies that the actualLocalDate
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));
- Parameters:
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual value isnull
.NullPointerException
- if start value isnull
.NullPointerException
- if end value isnull
.AssertionError
- if the actual value is not in [start, end] period.- Since:
- 3.7.1
-
isBetween
Same assertion asisBetween(LocalDate, LocalDate)
but here you passLocalDate
String representations which must follow ISO LocalDate format to allow callingLocalDate.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");
- Parameters:
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual value isnull
.NullPointerException
- if start value isnull
.NullPointerException
- if end value isnull
.DateTimeParseException
- if any of the given String can't be converted to aLocalDate
.AssertionError
- if the actual value is not in [start, end] period.- Since:
- 3.7.1
-
isStrictlyBetween
Verifies that the actualLocalDate
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);
- Parameters:
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual value isnull
.NullPointerException
- if start value isnull
.NullPointerException
- if end value isnull
.AssertionError
- if the actual value is not in ]start, end[ period.- Since:
- 3.7.1
-
isStrictlyBetween
Same assertion asisStrictlyBetween(LocalDate, LocalDate)
but here you passLocalDate
String representations which must follow ISO LocalDate format to allow callingLocalDate.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");
- Parameters:
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actual value isnull
.NullPointerException
- if start value isnull
.NullPointerException
- if end value isnull
.DateTimeParseException
- if any of the given String can't be converted to aLocalDate
.AssertionError
- if the actual value is not in ]start, end[ period.- Since:
- 3.7.1
-
hasYear
Verifies that actualLocalDate
is in the given year.Example:
// Assertion succeeds: assertThat(LocalDate.of(2000, 12, 31)).hasYear(2000); // Assertion fails: assertThat(LocalDate.of(2000, 12, 31)).hasYear(2001);
- Parameters:
year
- the given year.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not in the given year.- Since:
- 3.23.0
-
hasMonth
Verifies that actualLocalDate
is in the given month.Example:
// Assertion succeeds: assertThat(LocalDate.of(2000, 12, 31)).hasMonth(Month.DECEMBER); // Assertion fails: assertThat(LocalDate.of(2000, 12, 31)).hasMonth(Month.JANUARY);
- Parameters:
month
- the givenMonth
.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not in the given month.- Since:
- 3.23.0
-
hasMonthValue
Verifies that actualLocalDate
is in the given month.Example:
// Assertion succeeds: assertThat(LocalDate.of(2000, 12, 31)).hasMonthValue(12); // Assertion fails: assertThat(LocalDate.of(2000, 12, 31)).hasMonthValue(11);
- Parameters:
month
- the given month's value between 1 and 12 inclusive.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not in the given month.- Since:
- 3.23.0
-
hasDayOfMonth
Verifies that actualLocalDate
is on the given day.Example:
// Assertion succeeds: assertThat(LocalDate.of(2000, 12, 31)).hasDayOfMonth(31); // Assertion fails: assertThat(LocalDate.of(2000, 12, 31)).hasDayOfMonth(1);
- Parameters:
day
- the given numeric day.- Returns:
- this assertion object.
- Throws:
AssertionError
- if the actualLocalDate
isnull
.AssertionError
- if the actualLocalDate
is not on the given day.- Since:
- 3.23.0
-
parse
Obtains an instance ofTEMPORAL
from a string representation in ISO date format.- Specified by:
parse
in classAbstractTemporalAssert<SELF extends AbstractLocalDateAssert<SELF>,
LocalDate> - Parameters:
localDateAsString
- the string to parse, not null- Returns:
- the parsed
TEMPORAL
, not null
-