Class AbstractYearMonthAssert<SELF extends AbstractYearMonthAssert<SELF>>
- Type Parameters:
SELF
- the "self" type of this assertion class.
- All Implemented Interfaces:
Assert<SELF,
,YearMonth> Descriptable<SELF>
,ExtensionPoints<SELF,
YearMonth>
- Direct Known Subclasses:
YearMonthAssert
YearMonth
type
from new Date & Time API introduced in Java 8.- Since:
- 3.26.0
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractTemporalAssert
comparables
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractYearMonthAssert
(YearMonth actual, Class<?> selfType) Creates a new
.AbstractYearMonthAssert
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
assertYearMonthAsStringParameterIsNotNull
(String otherYearMonthAsString) Check that theYearMonth
string representation to compare actualYearMonth
to is not null, otherwise throws aIllegalArgumentException
with an explicit message.private static void
Check that theYearMonth
to compare actualYearMonth
to is not null, in that case throws aIllegalArgumentException
with an explicit message.private static void
checkIsNotNullAndNotEmpty
(Object[] values) private static Object[]
convertToYearMonthArray
(String... yearMonthsAsString) Verifies that the actualYearMonth
is in the given month.hasMonthValue
(int month) Verifies that the actualYearMonth
is in the given month.hasYear
(int year) Verifies that the actualYearMonth
is in the given year.Verifies that the actualYearMonth
is strictly after the given one.Verifies that the actualYearMonth
is strictly after the given one.isAfterOrEqualTo
(String otherYearMonthAsString) Verifies that the actualYearMonth
is after or equal to the given one.isAfterOrEqualTo
(YearMonth other) Verifies that the actualYearMonth
is after or equal to the given one.Verifies that the actualYearMonth
is strictly before the given one.Verifies that the actualYearMonth
is strictly before the given one.isBeforeOrEqualTo
(String otherYearMonthAsString) Verifies that the actualYearMonth
is before or equal to the given one.isBeforeOrEqualTo
(YearMonth other) Verifies that the actualYearMonth
is before or equal to the given one.Verifies that the actualYearMonth
is in the [start, end] period (start and end included).Verifies that the actualYearMonth
is in the [start, end] period (start and end included).Verifies that the actualYearMonth
is the currentYearMonth
.Verifies that the actualYearMonth
is equal to the given one.Verifies that the actualYearMonth
is present in the given array of values.Verifies that the actualYearMonth
is strictly in the future.Verifies that the actualYearMonth
is strictly in the past.isNotEqualTo
(String otherYearMonthAsString) Verifies that the actualYearMonth
is not equal to the given one.Verifies that the actualYearMonth
is not present in the given array of values.isStrictlyBetween
(String startExclusive, String endExclusive) Verifies that the actualYearMonth
is in the ]start, end[ period (start and end excluded).isStrictlyBetween
(YearMonth startExclusive, YearMonth endExclusive) Verifies that the actualYearMonth
is in the ]start, end[ period (start and end excluded).protected YearMonth
Obtains an instance ofYearMonth
from a text string such as 2007-12.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, withAssertionState, 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
-
Constructor Details
-
AbstractYearMonthAssert
Creates a new
.AbstractYearMonthAssert
- Parameters:
actual
- the actual value to verify.selfType
- the "self-type".
-
-
Method Details
-
isBefore
Verifies that the actualYearMonth
is strictly before the given one.Example:
assertThat(YearMonth.of(2000, 1)).isBefore(YearMonth.of(2000, 2));
- Parameters:
other
- the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if otherYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not strictly before the given one.
-
isBefore
Verifies that the actualYearMonth
is strictly before the given one.Same assertion as
isBefore(YearMonth)
but theYearMonth
is built from the given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isBefore("2000-02");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not strictly before theYearMonth
built from given string.
-
isBeforeOrEqualTo
Verifies that the actualYearMonth
is before or equal to the given one.Example:
assertThat(YearMonth.of(2000, 1)).isBeforeOrEqualTo(YearMonth.of(2000, 1)) .isBeforeOrEqualTo(YearMonth.of(2000, 2));
- Parameters:
other
- the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if otherYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not before or equal to the given one.
-
isBeforeOrEqualTo
Verifies that the actualYearMonth
is before or equal to the given one.Same assertion as
isBeforeOrEqualTo(YearMonth)
but theYearMonth
is built from given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isBeforeOrEqualTo("2000-01") .isBeforeOrEqualTo("2000-02");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not before or equal to theYearMonth
built from given string.
-
isAfterOrEqualTo
Verifies that the actualYearMonth
is after or equal to the given one.Example:
assertThat(YearMonth.of(2000, 1)).isAfterOrEqualTo(YearMonth.of(2000, 1)) .isAfterOrEqualTo(parse("1999-12"));
- Parameters:
other
- the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if otherYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not after or equal to the given one.
-
isAfterOrEqualTo
Verifies that the actualYearMonth
is after or equal to the given one.Same assertion as
isAfterOrEqualTo(YearMonth)
but theYearMonth
is built from given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isAfterOrEqualTo("2000-01") .isAfterOrEqualTo("1999-12");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not after or equal to theYearMonth
built from given string.
-
isAfter
Verifies that the actualYearMonth
is strictly after the given one.Example:
assertThat(YearMonth.of(2000, 1)).isAfter(parse("1999-12"));
- Parameters:
other
- the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if otherYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not strictly after the given one.
-
isAfter
Verifies that the actualYearMonth
is strictly after the given one.Same assertion as
isAfter(YearMonth)
but theYearMonth
is built from given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isAfter("1999-12");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not strictly after theYearMonth
built from given string.
-
isEqualTo
Verifies that the actualYearMonth
is equal to the given one.Same assertion as
AbstractAssert.isEqualTo(Object)
but theYearMonth
is built from given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isEqualTo("2000-01");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not equal to theYearMonth
built from given string.
-
isNotEqualTo
Verifies that the actualYearMonth
is not equal to the given one.Same assertion as
AbstractAssert.isNotEqualTo(Object)
but theYearMonth
is built from given string, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isNotEqualTo("2000-02");
- Parameters:
otherYearMonthAsString
- string representation of the otherYearMonth
to compare to, not null.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if the given string isnull
.DateTimeParseException
- if the given string cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is equal to theYearMonth
built from given string.
-
isIn
Verifies that the actualYearMonth
is present in the given array of values.Same assertion as
AbstractAssert.isIn(Object...)
but theYearMonth
s are built from given strings, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isIn("1999-12", "2000-01");
- Parameters:
otherYearMonthsAsString
- string array representingYearMonth
s.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if any of the given strings isnull
.DateTimeParseException
- if any of the given strings cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is not in theYearMonth
s built from given strings.
-
isNotIn
Verifies that the actualYearMonth
is not present in the given array of values.Same assertion as
AbstractAssert.isNotIn(Object...)
but theYearMonth
s are built from given strings, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
// use string representation of YearMonth assertThat(YearMonth.of(2000, 1)).isNotIn("1999-12", "2000-02");
- Parameters:
otherYearMonthsAsString
- Array of string representing aYearMonth
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.IllegalArgumentException
- if any of the given strings isnull
.DateTimeParseException
- if any of the given strings cannot be parsed to aYearMonth
.AssertionError
- if the actualYearMonth
is in theYearMonth
s built from given strings.
-
isInThePast
Verifies that the actualYearMonth
is strictly in the past.Example:
// assertion succeeds: assertThat(YearMonth.now().minusMonths(1)).isInThePast();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not in the past.
-
isCurrentYearMonth
Verifies that the actualYearMonth
is the currentYearMonth
.Example:
// assertion succeeds: assertThat(YearMonth.now()).isCurrentYearMonth(); // assertion fails: assertThat(theFellowshipOfTheRing.getReleaseDate()).isCurrentYearMonth();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not the currentYearMonth
.
-
isInTheFuture
Verifies that the actualYearMonth
is strictly in the future.Example:
// assertion succeeds: assertThat(YearMonth.now().plusMonths(1)).isInTheFuture();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not in the future.
-
isBetween
Verifies that the actualYearMonth
is in the [start, end] period (start and end included).Example:
YearMonth yearMonth = YearMonth.now(); // assertions succeed: assertThat(yearMonth).isBetween(yearMonth.minusMonths(1), yearMonth.plusMonths(1)) .isBetween(yearMonth, yearMonth.plusMonths(1)) .isBetween(yearMonth.minusMonths(1), yearMonth) .isBetween(yearMonth, yearMonth); // assertions fail: assertThat(yearMonth).isBetween(yearMonth.minusMonths(10), yearMonth.minusMonths(1)); assertThat(yearMonth).isBetween(yearMonth.plusMonths(1), yearMonth.plusMonths(10));
- Parameters:
startInclusive
- the start value (inclusive), not null.endInclusive
- the end value (inclusive), not 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.
-
isBetween
Verifies that the actualYearMonth
is in the [start, end] period (start and end included).Same assertion as
isBetween(YearMonth, YearMonth)
but theYearMonth
s are built from given strings, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
YearMonth january2000 = YearMonth.parse("2000-01"); // assertions succeed: assertThat(january2000).isBetween("1999-01", "2001-01") .isBetween("2000-01", "2001-01") .isBetween("1999-01", "2000-01") .isBetween("2000-01", "2000-01"); // assertion fails: assertThat(january2000).isBetween("1999-01", "1999-12");
- Parameters:
startInclusive
- the start value (inclusive), not null.endInclusive
- the end value (inclusive), not 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 aYearMonth
.AssertionError
- if the actual value is not in [start, end] period.
-
isStrictlyBetween
Verifies that the actualYearMonth
is in the ]start, end[ period (start and end excluded).Example:
YearMonth yearMonth = YearMonth.now(); // assertion succeeds: assertThat(yearMonth).isStrictlyBetween(yearMonth.minusMonths(1), yearMonth.plusMonths(1)); // assertions fail: assertThat(yearMonth).isStrictlyBetween(yearMonth.minusMonths(10), yearMonth.minusMonths(1)); assertThat(yearMonth).isStrictlyBetween(yearMonth.plusMonths(1), yearMonth.plusMonths(10)); assertThat(yearMonth).isStrictlyBetween(yearMonth, yearMonth.plusMonths(1)); assertThat(yearMonth).isStrictlyBetween(yearMonth.minusMonths(1), yearMonth);
- Parameters:
startExclusive
- the start value (exclusive), not null.endExclusive
- the end value (exclusive), not 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.
-
isStrictlyBetween
Verifies that the actualYearMonth
is in the ]start, end[ period (start and end excluded).Same assertion as
isStrictlyBetween(YearMonth, YearMonth)
but theYearMonth
s are built from given strings, which must follow theDateTimeFormatter
patternuuuu-MM
to allow callingYearMonth.parse(CharSequence)
method.Example:
YearMonth january2000 = YearMonth.parse("2000-01"); // assertion succeeds: assertThat(january2000).isStrictlyBetween("1999-01", "2001-01"); // assertions fail: assertThat(january2000).isStrictlyBetween("1999-01", "1999-12"); assertThat(january2000).isStrictlyBetween("2000-01", "2001-01"); assertThat(january2000).isStrictlyBetween("1999-01", "2000-01");
- Parameters:
startExclusive
- the start value (exclusive), not null.endExclusive
- the end value (exclusive), not 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 aYearMonth
.AssertionError
- if the actual value is not in ]start, end[ period.
-
hasYear
Verifies that the actualYearMonth
is in the given year.Example:
// assertion succeeds: assertThat(YearMonth.of(2000, 12)).hasYear(2000); // assertion fails: assertThat(YearMonth.of(2000, 12)).hasYear(2001);
- Parameters:
year
- the given year.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not in the given year.
-
hasMonth
Verifies that the actualYearMonth
is in the given month.Example:
// assertion succeeds: assertThat(YearMonth.of(2000, 12)).hasMonth(Month.DECEMBER); // assertion fails: assertThat(YearMonth.of(2000, 12)).hasMonth(Month.JANUARY);
- Parameters:
month
- the givenMonth
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not in the given month.
-
hasMonthValue
Verifies that the actualYearMonth
is in the given month.Example:
// assertion succeeds: assertThat(YearMonth.of(2000, 12)).hasMonthValue(12); // assertion fails: assertThat(YearMonth.of(2000, 12)).hasMonthValue(11);
- Parameters:
month
- the given month's value between 1 and 12 inclusive.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualYearMonth
isnull
.AssertionError
- if the actualYearMonth
is not in the given month.
-
parse
Obtains an instance ofYearMonth
from a text string such as 2007-12.- Specified by:
parse
in classAbstractTemporalAssert<SELF extends AbstractYearMonthAssert<SELF>,
YearMonth> - Parameters:
yearMonthAsString
- the string to parse, not null- Returns:
- the parsed
TEMPORAL
, not null - See Also:
-
assertYearMonthParameterIsNotNull
Check that theYearMonth
to compare actualYearMonth
to is not null, in that case throws aIllegalArgumentException
with an explicit message.- Parameters:
other
- theYearMonth
to check.- Throws:
IllegalArgumentException
- with an explicit message if the givenYearMonth
is null.
-
assertYearMonthAsStringParameterIsNotNull
Check that theYearMonth
string representation to compare actualYearMonth
to is not null, otherwise throws aIllegalArgumentException
with an explicit message.- Parameters:
otherYearMonthAsString
- string representing theYearMonth
to compare actual with.- Throws:
IllegalArgumentException
- with an explicit message if the givenString
is null.
-
checkIsNotNullAndNotEmpty
-
convertToYearMonthArray
-