Class AbstractOffsetDateTimeAssert<SELF extends AbstractOffsetDateTimeAssert<SELF>>
- Type Parameters:
SELF- the "self" type of this assertion class.
- All Implemented Interfaces:
Assert<SELF,,OffsetDateTime> Descriptable<SELF>,ExtensionPoints<SELF,OffsetDateTime>
- Direct Known Subclasses:
OffsetDateTimeAssert
OffsetDateTime type from new Date & Time API introduced in Java 8.-
Field Summary
FieldsFields inherited from class org.assertj.core.api.AbstractTemporalAssert
comparablesFields inherited from class org.assertj.core.api.AbstractAssert
actual, conditions, info, myself, objects -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractOffsetDateTimeAssert(OffsetDateTime actual, Class<?> selfType) Creates a new.AbstractOffsetDateTimeAssert -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanareEqualIgnoringMinutes(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.private static booleanareEqualIgnoringNanos(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year, month and day of month, hour, minute and second, false otherwise.private static booleanareEqualIgnoringSeconds(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year, month, day of month, hour and minute, false otherwise.private static booleanareEqualIgnoringTimezone(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same hour, minute, second and nanosecond false otherwise.private static voidassertOffsetDateTimeAsStringParameterIsNotNull(String offsetDateTimeAsString) Check that theOffsetDateTimestring representation to compare actualOffsetDateTimeto is not null, otherwise throws aIllegalArgumentExceptionwith an explicit messageprivate static voidCheck that theOffsetDateTimeto compare actualOffsetDateTimeto is not null, in that case throws aIllegalArgumentExceptionwith an explicit messageprivate voidcheckIsNotNullAndNotEmpty(Object[] values) private static Object[]convertToOffsetDateTimeArray(String... dateTimesAsString) private static booleanhaveSameNano(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same nanosecond, false otherwise.private static booleanhaveSameYear(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year, false otherwise.private static booleanhaveSameYearAndMonth(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year and month, false otherwise.private static booleanhaveSameYearMonthAndDayOfMonth(OffsetDateTime actual, OffsetDateTime other) Returns true if both OffsetDateTime are in the same year, month and day of month, false otherwise.Same assertion asisAfter(java.time.OffsetDateTime)but theOffsetDateTimeis built from given a String that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isAfter(OffsetDateTime other) Verifies that the actualOffsetDateTimeis strictly after the given one.isAfterOrEqualTo(String offsetDateTimeAsString) Same assertion asisAfterOrEqualTo(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isAfterOrEqualTo(OffsetDateTime other) Verifies that the actualOffsetDateTimeis after or equals to the given one.Same assertion asisBefore(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isBefore(OffsetDateTime other) Verifies that the actualOffsetDateTimeis strictly before the given one.isBeforeOrEqualTo(String offsetDateTimeAsString) Same assertion asisBeforeOrEqualTo(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isBeforeOrEqualTo(OffsetDateTime other) Verifies that the actualOffsetDateTimeis before or equals to the given one.Same assertion asisBetween(OffsetDateTime, OffsetDateTime)but here you passOffsetDateTimeString representations which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isBetween(OffsetDateTime startInclusive, OffsetDateTime endInclusive) Verifies that the actualOffsetDateTimeis in the [start, end] period (start and end included).Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beOffsetDateTime) but here you passOffsetDateTimeString representation that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Verifies that actual and givenOffsetDateTimehave same year, month and day fields (hour, minute, second and nanosecond fields are ignored in comparison).Verifies that actual and givenOffsetDateTimehave same year, month, day and hour fields (minute, second and nanosecond fields are ignored in comparison).Verifies that actual and givenOffsetDateTimehave same year, month, day, hour, minute and second fields, (nanosecond fields are ignored in comparison).Verifies that actual and givenOffsetDateTimehave same year, month, day, hour and minute fields (second and nanosecond fields are ignored in comparison).Verifies that actual and givenOffsetDateTimehave same year, month, day, hour, minute, second and nanosecond fields, (timezone fields are ignored in comparison).Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beOffsetDateTime) but here you passOffsetDateTimeString representations that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isNotEqualTo(String dateTimeAsString) Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beOffsetDateTime) but here you passOffsetDateTimeString representation that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beOffsetDateTime) but here you passOffsetDateTimeString representations that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isStrictlyBetween(String startInclusive, String endInclusive) Same assertion asisStrictlyBetween(OffsetDateTime, OffsetDateTime)but here you passOffsetDateTimeString representations which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.isStrictlyBetween(OffsetDateTime startInclusive, OffsetDateTime endInclusive) Verifies that the actualOffsetDateTimeis in the ]start, end[ period (start and end excluded).protected OffsetDateTimeObtains an instance ofTEMPORALfrom a string representation in ISO date format.Methods inherited from class org.assertj.core.api.AbstractTemporalAssert
getActual, isCloseTo, isCloseToMethods inherited from class org.assertj.core.api.AbstractAssert
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, 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, overridingErrorMessage, satisfies, setCustomRepresentation, throwAssertionError, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
-
Field Details
-
NULL_OFFSET_DATE_TIME_PARAMETER_MESSAGE
- See Also:
-
-
Constructor Details
-
AbstractOffsetDateTimeAssert
Creates a new.AbstractOffsetDateTimeAssert- Parameters:
selfType- the "self type"actual- the actual value to verify
-
-
Method Details
-
isBefore
Verifies that the actualOffsetDateTimeis strictly before the given one.Example :
assertThat(parse("2000-01-01T23:59:59Z")).isBefore(parse("2000-01-02T00:00:00Z"));- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis not strictly before the given one.
-
isBefore
Same assertion asisBefore(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid writing the code to perform the conversion assertThat(parse("2000-01-01T23:59:59Z")).isBefore("2000-01-02T00:00:00Z");- Parameters:
offsetDateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not strictly before theOffsetDateTimebuilt from given String.
-
isBeforeOrEqualTo
Verifies that the actualOffsetDateTimeis before or equals to the given one.Example :
assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo(parse("2000-01-01T23:59:59Z")) .isBeforeOrEqualTo(parse("2000-01-02T00:00:00Z"));- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis not before or equals to the given one.
-
isBeforeOrEqualTo
Same assertion asisBeforeOrEqualTo(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01T23:59:59Z")).isBeforeOrEqualTo("2000-01-01T23:59:59Z") .isBeforeOrEqualTo("2000-01-02T00:00:00Z");- Parameters:
offsetDateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not before or equals to theOffsetDateTimebuilt from given String.
-
isAfterOrEqualTo
Verifies that the actualOffsetDateTimeis after or equals to the given one.Example :
assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo(parse("2000-01-01T00:00:00Z")) .isAfterOrEqualTo(parse("1999-12-31T23:59:59Z"));- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis not after or equals to the given one.
-
isAfterOrEqualTo
Same assertion asisAfterOrEqualTo(java.time.OffsetDateTime)but theOffsetDateTimeis built from given String, which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01T00:00:00Z")).isAfterOrEqualTo("2000-01-01T00:00:00Z") .isAfterOrEqualTo("1999-12-31T23:59:59Z");- Parameters:
offsetDateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not after or equals to theOffsetDateTimebuilt from given String.
-
isAfter
Verifies that the actualOffsetDateTimeis strictly after the given one.Example :
assertThat(parse("2000-01-01T00:00:00Z")).isAfter(parse("1999-12-31T23:59:59Z"));- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis not strictly after the given one.
-
isAfter
Same assertion asisAfter(java.time.OffsetDateTime)but theOffsetDateTimeis built from given a String that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid conversion assertThat(parse("2000-01-01T00:00:00Z")).isAfter("1999-12-31T23:59:59Z");- Parameters:
offsetDateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not strictly after theOffsetDateTimebuilt from given String.
-
isEqualTo
Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beOffsetDateTime) but here you passOffsetDateTimeString representation that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid writing the code to perform the conversion assertThat(parse("2000-01-01T00:00:00Z")).isEqualTo("2000-01-01T00:00:00Z");- Parameters:
dateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not equal to theOffsetDateTimebuilt from given String.
-
isNotEqualTo
Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beOffsetDateTime) but here you passOffsetDateTimeString representation that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String in comparison to avoid writing the code to perform the conversion assertThat(parse("2000-01-01T00:00:00Z")).isNotEqualTo("2000-01-15T00:00:00Z");- Parameters:
dateTimeAsString- String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis equal to theOffsetDateTimebuilt from given String.
-
isIn
Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beOffsetDateTime) but here you passOffsetDateTimeString representations that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String based representation of OffsetDateTime assertThat(parse("2000-01-01T00:00:00Z")).isIn("1999-12-31T00:00:00Z", "2000-01-01T00:00:00Z");- Parameters:
dateTimesAsString- String array representingOffsetDateTimes.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis not in theOffsetDateTimes built from given Strings.
-
isNotIn
Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beOffsetDateTime) but here you passOffsetDateTimeString representations that must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example :
// use String based representation of OffsetDateTime assertThat(parse("2000-01-01T00:00:00Z")).isNotIn("1999-12-31T00:00:00Z", "2000-01-02T00:00:00Z");- Parameters:
dateTimesAsString- Array of String representing aOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetDateTime.AssertionError- if the actualOffsetDateTimeis in theOffsetDateTimes built from given Strings.
-
isEqualToIgnoringNanos
Verifies that actual and givenOffsetDateTimehave same year, month, day, hour, minute and second fields, (nanosecond fields are ignored in comparison).Assertion can fail with OffsetDateTimes in same chronological nanosecond time window, e.g :
2000-01-01T00:00:01.000000000+01:00 and 2000-01-01T00:00:00.999999999+01:00.
Assertion fails as second fields differ even if time difference is only 1ns.
Code example :
// successful assertions OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 456, ZoneOffset.UTC); assertThat(OffsetDateTime1).isEqualToIgnoringNanos(OffsetDateTime2);// failing assertions (even if time difference is only 1ns) OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 999999999, ZoneOffset.UTC); assertThat(OffsetDateTimeA).isEqualToIgnoringNanos(OffsetDateTimeB);- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis are not equal with nanoseconds ignored.
-
isEqualToIgnoringTimezone
Verifies that actual and givenOffsetDateTimehave same year, month, day, hour, minute, second and nanosecond fields, (timezone fields are ignored in comparison).Code example :
// successful assertions OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.MAX); assertThat(OffsetDateTime1).isEqualToIgnoringTimezone(OffsetDateTime2); // failing assertions OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 0, 0, 0, 999999999, ZoneOffset.UTC); assertThat(OffsetDateTimeA).isEqualToIgnoringTimezone(OffsetDateTimeB);- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis are not equal with timezone ignored.
-
isEqualToIgnoringSeconds
Verifies that actual and givenOffsetDateTimehave same year, month, day, hour and minute fields (second and nanosecond fields are ignored in comparison).Assertion can fail with OffsetDateTimes in same chronological second time window, e.g :
2000-01-01T00:01:00.000+01:00 and 2000-01-01T00:00:59.000+01:00.
Assertion fails as minute fields differ even if time difference is only 1s.
Code example :
// successful assertions OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 50, 0, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 23, 50, 10, 456, ZoneOffset.UTC); assertThat(OffsetDateTime1).isEqualToIgnoringSeconds(OffsetDateTime2); // failing assertions (even if time difference is only 1ms) OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 23, 50, 00, 000, ZoneOffset.UTC); OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 23, 49, 59, 999, ZoneOffset.UTC); assertThat(OffsetDateTimeA).isEqualToIgnoringSeconds(OffsetDateTimeB);- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis are not equal with second and nanosecond fields ignored.
-
isEqualToIgnoringMinutes
Verifies that actual and givenOffsetDateTimehave same year, month, day and hour fields (minute, second and nanosecond fields are ignored in comparison).Assertion can fail with OffsetDateTimes in same chronological second time window, e.g :
2000-01-01T01:00:00.000+01:00 and 2000-01-01T00:59:59.000+01:00.
Time difference is only 1s but hour fields differ.
Code example :
// successful assertions OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 50, 0, 0, ZoneOffset.UTC); OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 23, 00, 2, 7, ZoneOffset.UTC); assertThat(OffsetDateTime1).isEqualToIgnoringMinutes(OffsetDateTime2); // failing assertions (even if time difference is only 1ms) OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 1, 01, 00, 00, 000, ZoneOffset.UTC); OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 00, 59, 59, 999, ZoneOffset.UTC); assertThat(OffsetDateTimeA).isEqualToIgnoringMinutes(OffsetDateTimeB);- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis are not equal ignoring minute, second and nanosecond fields.
-
isEqualToIgnoringHours
Verifies that actual and givenOffsetDateTimehave same year, month and day fields (hour, minute, second and nanosecond fields are ignored in comparison).Assertion can fail with OffsetDateTimes in same chronological minute time window, e.g :
2000-01-01T23:59:00.000+01:00 and 2000-01-02T00:00:00.000+01:00.
Time difference is only 1min but day fields differ.
Code example :
// successful assertions OffsetDateTime OffsetDateTime1 = OffsetDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneOffset.UTC); OffsetDateTime OffsetDateTime2 = OffsetDateTime.of(2000, 1, 1, 00, 00, 00, 000, ZoneOffset.UTC); assertThat(OffsetDateTime1).isEqualToIgnoringHours(OffsetDateTime2); // failing assertions (even if time difference is only 1ms) OffsetDateTime OffsetDateTimeA = OffsetDateTime.of(2000, 1, 2, 00, 00, 00, 000, ZoneOffset.UTC); OffsetDateTime OffsetDateTimeB = OffsetDateTime.of(2000, 1, 1, 23, 59, 59, 999, ZoneOffset.UTC); assertThat(OffsetDateTimeA).isEqualToIgnoringHours(OffsetDateTimeB);- Parameters:
other- the givenOffsetDateTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetDateTimeisnull.IllegalArgumentException- if otherOffsetDateTimeisnull.AssertionError- if the actualOffsetDateTimeis are not equal with second and nanosecond fields ignored.
-
isBetween
Verifies that the actualOffsetDateTimeis in the [start, end] period (start and end included).Example:
OffsetDateTime offsetDateTime = OffsetDateTime.now(); // assertions succeed: assertThat(offsetDateTime).isBetween(offsetDateTime.minusSeconds(1), offsetDateTime.plusSeconds(1)) .isBetween(offsetDateTime, offsetDateTime.plusSeconds(1)) .isBetween(offsetDateTime.minusSeconds(1), offsetDateTime) .isBetween(offsetDateTime, offsetDateTime); // assertions fail: assertThat(offsetDateTime).isBetween(offsetDateTime.minusSeconds(10), offsetDateTime.minusSeconds(1)); assertThat(offsetDateTime).isBetween(offsetDateTime.plusSeconds(1), offsetDateTime.plusSeconds(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(OffsetDateTime, OffsetDateTime)but here you passOffsetDateTimeString representations which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example:
OffsetDateTime firstOfJanuary2000 = OffsetDateTime.parse("2000-01-01T00:00:00Z"); // assertions succeed: assertThat(firstOfJanuary2000).isBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:01Z") .isBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z") .isBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:00Z") .isBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:00Z"); // assertion fails: assertThat(firstOfJanuary2000).isBetween("1999-01-01T00:00:01Z", "1999-12-31T23:59:59Z");- 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 aOffsetDateTime.AssertionError- if the actual value is not in [start, end] period.- Since:
- 3.7.1
-
isStrictlyBetween
Verifies that the actualOffsetDateTimeis in the ]start, end[ period (start and end excluded).Example:
OffsetDateTime offsetDateTime = OffsetDateTime.now(); // assertion succeeds: assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(1), offsetDateTime.plusSeconds(1)); // assertions fail: assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(10), offsetDateTime.minusSeconds(1)); assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.plusSeconds(1), offsetDateTime.plusSeconds(10)); assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime, offsetDateTime.plusSeconds(1)); assertThat(offsetDateTime).isStrictlyBetween(offsetDateTime.minusSeconds(1), offsetDateTime);- 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
-
isStrictlyBetween
Same assertion asisStrictlyBetween(OffsetDateTime, OffsetDateTime)but here you passOffsetDateTimeString representations which must follow ISO OffsetDateTime format to allow callingOffsetDateTime.parse(CharSequence)method.Example:
OffsetDateTime firstOfJanuary2000 = OffsetDateTime.parse("2000-01-01T00:00:00Z"); // assertion succeeds: assertThat(firstOfJanuary2000).isStrictlyBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:01Z"); // assertions fail: assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01T00:00:01Z", "1999-12-31T23:59:59Z"); assertThat(firstOfJanuary2000).isStrictlyBetween("2000-01-01T00:00:00Z", "2000-01-01T00:00:01Z"); assertThat(firstOfJanuary2000).isStrictlyBetween("1999-12-31T23:59:59Z", "2000-01-01T00:00:00Z");- 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 aOffsetDateTime.AssertionError- if the actual value is not in ]start, end[ period.- Since:
- 3.7.1
-
parse
Obtains an instance ofTEMPORALfrom a string representation in ISO date format.- Specified by:
parsein classAbstractTemporalAssert<SELF extends AbstractOffsetDateTimeAssert<SELF>,OffsetDateTime> - Parameters:
offsetDateTimeAsString- the string to parse, not null- Returns:
- the parsed
TEMPORAL, not null
-
areEqualIgnoringNanos
Returns true if both OffsetDateTime are in the same year, month and day of month, hour, minute and second, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, month and day of month, hour, minute and second, false otherwise.
-
areEqualIgnoringSeconds
Returns true if both OffsetDateTime are in the same year, month, day of month, hour and minute, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, month, day of month, hour and minute, false otherwise.
-
areEqualIgnoringMinutes
Returns true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, month, day of month and hour, false otherwise.
-
haveSameYearMonthAndDayOfMonth
Returns true if both OffsetDateTime are in the same year, month and day of month, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, month and day of month, false otherwise
-
haveSameYearAndMonth
Returns true if both OffsetDateTime are in the same year and month, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year and month, false otherwise
-
haveSameYear
Returns true if both OffsetDateTime are in the same year, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, false otherwise
-
areEqualIgnoringTimezone
Returns true if both OffsetDateTime are in the same hour, minute, second and nanosecond false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same hour, minute, second and nanosecond false otherwise.
-
haveSameNano
Returns true if both OffsetDateTime are in the same nanosecond, false otherwise.- Parameters:
actual- the actual OffsetDateTime. expected not be nullother- the other OffsetDateTime. expected not be null- Returns:
- true if both OffsetDateTime are in the same year, false otherwise
-
convertToOffsetDateTimeArray
-
checkIsNotNullAndNotEmpty
-
assertOffsetDateTimeAsStringParameterIsNotNull
Check that theOffsetDateTimestring representation to compare actualOffsetDateTimeto is not null, otherwise throws aIllegalArgumentExceptionwith an explicit message- Parameters:
offsetDateTimeAsString- String representing theOffsetDateTimeto compare actual with- Throws:
IllegalArgumentException- with an explicit message if the givenStringis null
-
assertOffsetDateTimeParameterIsNotNull
Check that theOffsetDateTimeto compare actualOffsetDateTimeto is not null, in that case throws aIllegalArgumentExceptionwith an explicit message- Parameters:
other- theOffsetDateTimeto check- Throws:
IllegalArgumentException- with an explicit message if the givenOffsetDateTimeis null
-