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.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractYearMonthAssert(YearMonth actual, Class<?> selfType) Creates a new.AbstractYearMonthAssert -
Method Summary
Modifier and TypeMethodDescriptionVerifies that the actualYearMonthis in the given month.hasMonthValue(int month) Verifies that the actualYearMonthis in the given month.hasYear(int year) Verifies that the actualYearMonthis in the given year.Verifies that the actualYearMonthis strictly after the given one.Verifies that the actualYearMonthis strictly after the given one.isAfterOrEqualTo(String otherYearMonthAsString) Verifies that the actualYearMonthis after or equal to the given one.isAfterOrEqualTo(YearMonth other) Verifies that the actualYearMonthis after or equal to the given one.Verifies that the actualYearMonthis strictly before the given one.Verifies that the actualYearMonthis strictly before the given one.isBeforeOrEqualTo(String otherYearMonthAsString) Verifies that the actualYearMonthis before or equal to the given one.isBeforeOrEqualTo(YearMonth other) Verifies that the actualYearMonthis before or equal to the given one.Verifies that the actualYearMonthis in the [start, end] period (start and end included).Verifies that the actualYearMonthis in the [start, end] period (start and end included).Verifies that the actualYearMonthis the currentYearMonth.Verifies that the actualYearMonthis equal to the given one.Verifies that the actualYearMonthis present in the given array of values.Verifies that the actualYearMonthis strictly in the future.Verifies that the actualYearMonthis strictly in the past.isNotEqualTo(String otherYearMonthAsString) Verifies that the actualYearMonthis not equal to the given one.Verifies that the actualYearMonthis not present in the given array of values.isStrictlyBetween(String startExclusive, String endExclusive) Verifies that the actualYearMonthis in the ]start, end[ period (start and end excluded).isStrictlyBetween(YearMonth startExclusive, YearMonth endExclusive) Verifies that the actualYearMonthis in the ]start, end[ period (start and end excluded).protected YearMonthObtains an instance ofYearMonthfrom a text string such as 2007-12.Methods inherited from class org.assertj.core.api.AbstractTemporalAssert
isCloseTo, isCloseTo, usingComparator, usingComparator, usingDefaultComparatorMethods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, 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, usingEquals, usingEquals, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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 actualYearMonthis strictly before the given one.Example:
assertThat(YearMonth.of(2000, 1)).isBefore(YearMonth.of(2000, 2));- Parameters:
other- the otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if otherYearMonthisnull.AssertionError- if the actualYearMonthis not strictly before the given one.
-
isBefore
Verifies that the actualYearMonthis strictly before the given one.Same assertion as
isBefore(YearMonth)but theYearMonthis built from the given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not strictly before theYearMonthbuilt from given string.
-
isBeforeOrEqualTo
Verifies that the actualYearMonthis 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if otherYearMonthisnull.AssertionError- if the actualYearMonthis not before or equal to the given one.
-
isBeforeOrEqualTo
Verifies that the actualYearMonthis before or equal to the given one.Same assertion as
isBeforeOrEqualTo(YearMonth)but theYearMonthis built from given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not before or equal to theYearMonthbuilt from given string.
-
isAfterOrEqualTo
Verifies that the actualYearMonthis 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if otherYearMonthisnull.AssertionError- if the actualYearMonthis not after or equal to the given one.
-
isAfterOrEqualTo
Verifies that the actualYearMonthis after or equal to the given one.Same assertion as
isAfterOrEqualTo(YearMonth)but theYearMonthis built from given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not after or equal to theYearMonthbuilt from given string.
-
isAfter
Verifies that the actualYearMonthis strictly after the given one.Example:
assertThat(YearMonth.of(2000, 1)).isAfter(parse("1999-12"));- Parameters:
other- the otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if otherYearMonthisnull.AssertionError- if the actualYearMonthis not strictly after the given one.
-
isAfter
Verifies that the actualYearMonthis strictly after the given one.Same assertion as
isAfter(YearMonth)but theYearMonthis built from given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not strictly after theYearMonthbuilt from given string.
-
isEqualTo
Verifies that the actualYearMonthis equal to the given one.Same assertion as
AbstractAssert.isEqualTo(Object)but theYearMonthis built from given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not equal to theYearMonthbuilt from given string.
-
isNotEqualTo
Verifies that the actualYearMonthis not equal to the given one.Same assertion as
AbstractAssert.isNotEqualTo(Object)but theYearMonthis built from given string, which must follow theDateTimeFormatterpatternuuuu-MMto 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 otherYearMonthto compare to, not null.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if the given string isnull.DateTimeParseException- if the given string cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis equal to theYearMonthbuilt from given string.
-
isIn
Verifies that the actualYearMonthis present in the given array of values.Same assertion as
AbstractAssert.isIn(Object...)but theYearMonths are built from given strings, which must follow theDateTimeFormatterpatternuuuu-MMto 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 representingYearMonths.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if any of the given strings isnull.DateTimeParseException- if any of the given strings cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis not in theYearMonths built from given strings.
-
isNotIn
Verifies that the actualYearMonthis not present in the given array of values.Same assertion as
AbstractAssert.isNotIn(Object...)but theYearMonths are built from given strings, which must follow theDateTimeFormatterpatternuuuu-MMto 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:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.IllegalArgumentException- if any of the given strings isnull.DateTimeParseException- if any of the given strings cannot be parsed to aYearMonth.AssertionError- if the actualYearMonthis in theYearMonths built from given strings.
-
isInThePast
Verifies that the actualYearMonthis strictly in the past.Example:
// assertion succeeds: assertThat(YearMonth.now().minusMonths(1)).isInThePast();- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not in the past.
-
isCurrentYearMonth
Verifies that the actualYearMonthis the currentYearMonth.Example:
// assertion succeeds: assertThat(YearMonth.now()).isCurrentYearMonth(); // assertion fails: assertThat(theFellowshipOfTheRing.getReleaseDate()).isCurrentYearMonth();- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not the currentYearMonth.
-
isInTheFuture
Verifies that the actualYearMonthis strictly in the future.Example:
// assertion succeeds: assertThat(YearMonth.now().plusMonths(1)).isInTheFuture();- Returns:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not in the future.
-
isBetween
Verifies that the actualYearMonthis 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:
thisassertion 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 actualYearMonthis in the [start, end] period (start and end included).Same assertion as
isBetween(YearMonth, YearMonth)but theYearMonths are built from given strings, which must follow theDateTimeFormatterpatternuuuu-MMto 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:
thisassertion 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 actualYearMonthis 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:
thisassertion 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 actualYearMonthis in the ]start, end[ period (start and end excluded).Same assertion as
isStrictlyBetween(YearMonth, YearMonth)but theYearMonths are built from given strings, which must follow theDateTimeFormatterpatternuuuu-MMto 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:
thisassertion 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 actualYearMonthis 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:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not in the given year.
-
hasMonth
Verifies that the actualYearMonthis 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:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not in the given month.
-
hasMonthValue
Verifies that the actualYearMonthis 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:
thisassertion object.- Throws:
AssertionError- if the actualYearMonthisnull.AssertionError- if the actualYearMonthis not in the given month.
-
parse
Obtains an instance ofYearMonthfrom a text string such as 2007-12.- Specified by:
parsein classAbstractTemporalAssert<SELF extends AbstractYearMonthAssert<SELF>,YearMonth> - Parameters:
yearMonthAsString- the string to parse, not null- Returns:
- the parsed
TEMPORAL, not null - See Also:
-