Class AbstractOffsetTimeAssert<SELF extends AbstractOffsetTimeAssert<SELF>>
- All Implemented Interfaces:
Assert<SELF,,OffsetTime> Descriptable<SELF>,ExtensionPoints<SELF,OffsetTime>
- Direct Known Subclasses:
OffsetTimeAssert
OffsetTime 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, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractOffsetTimeAssert(OffsetTime actual, Class<?> selfType) Creates a new.AbstractOffsetTimeAssert -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanareEqualIgnoringNanos(OffsetTime actual, OffsetTime other) Returns true if both OffsetTime are in the same hour, minute and second, false otherwise.private static booleanareEqualIgnoringSeconds(OffsetTime actual, OffsetTime other) Returns true if both OffsetTime are in the same hour and minute, false otherwise.private static booleanareEqualIgnoringTimezone(OffsetTime actual, OffsetTime other) Returns true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.private static voidassertOffsetTimeAsStringParameterIsNotNull(String OffsetTimeAsString) Check that theOffsetTimestring representation to compare actualOffsetTimeto is not null, otherwise throws aIllegalArgumentExceptionwith an explicit messageprivate static voidCheck that theOffsetTimeto compare actualOffsetTimeto is not null, in that case throws aIllegalArgumentExceptionwith an explicit messageprivate voidcheckIsNotNullAndNotEmpty(Object[] values) private static Object[]convertToOffsetTimeArray(String... offsetTimesAsString) hasSameHourAs(OffsetTime other) Verifies that actual and givenOffsetTimehave same hour fields (minute, second and nanosecond fields are ignored in comparison).private static booleanhaveSameHourField(OffsetTime actual, OffsetTime other) private static booleanhaveSameMinute(OffsetTime actual, OffsetTime other) private static booleanhaveSameNano(OffsetTime actual, OffsetTime other) private static booleanhaveSameSecond(OffsetTime actual, OffsetTime other) Same assertion asisAfter(java.time.OffsetTime)but theOffsetTimeis built from given a String that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isAfter(OffsetTime other) Verifies that the actualOffsetTimeis strictly after the given one.isAfterOrEqualTo(String offsetTimeAsString) Same assertion asisAfterOrEqualTo(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isAfterOrEqualTo(OffsetTime other) Verifies that the actualOffsetTimeis after or equals to the given one.Same assertion asisBefore(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isBefore(OffsetTime other) Verifies that the actualOffsetTimeis strictly before the given one.isBeforeOrEqualTo(String offsetTimeAsString) Same assertion asisBeforeOrEqualTo(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isBeforeOrEqualTo(OffsetTime other) Verifies that the actualOffsetTimeis before or equals to the given one.Same assertion asisBetween(OffsetTime, OffsetTime)but here you passOffsetTimeString representations which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isBetween(OffsetTime startInclusive, OffsetTime endInclusive) Verifies that the actualOffsetTimeis in the [start, end] period (start and end included).isCloseTo(OffsetTime other, TemporalOffset<? super OffsetTime> offset) Verifies that the actualOffsetTimeis close to the other according to the givenTemporalOffset.Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beOffsetTime) but here you passOffsetTimeString representation that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isEqualToIgnoringNanos(OffsetTime other) Deprecated.Deprecated.UseisCloseTo(OffsetTime, TemporalOffset)instead, although not exactly the same semantics, this is the right way to compare with a given precision.Verifies that actual and givenOffsetTimehave same hour, minute, second and nanosecond fields).Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beOffsetTime) but here you passOffsetTimeString representations that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isNotEqualTo(String offsetTimeAsString) Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beOffsetTime) but here you passOffsetTimeString representation that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beOffsetTime) but here you passOffsetTimeString representations that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isStrictlyBetween(String startExclusive, String endExclusive) Same assertion asisStrictlyBetween(OffsetTime, OffsetTime)but here you passOffsetTimeString representations which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.isStrictlyBetween(OffsetTime startExclusive, OffsetTime endExclusive) Verifies that the actualOffsetTimeis in the ]start, end[ period (start and end excluded).protected OffsetTimeObtains an instance ofTEMPORALfrom a string representation in ISO date format.Methods inherited from class org.assertj.core.api.AbstractTemporalAssert
isCloseTo, usingComparator, usingComparator, usingDefaultComparatorMethods 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, 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
-
Field Details
-
NULL_OFFSET_TIME_PARAMETER_MESSAGE
- See Also:
-
-
Constructor Details
-
AbstractOffsetTimeAssert
Creates a new.AbstractOffsetTimeAssert- Parameters:
actual- the actual value to verifyselfType- the "self type"
-
-
Method Details
-
isBefore
Verifies that the actualOffsetTimeis strictly before the given one.Example :
assertThat(parse("12:00:00Z")).isBefore(parse("13:00:00Z"));- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not strictly before the given one.
-
isBefore
Same assertion asisBefore(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("12:59Z")).isBefore("13:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not strictly before theOffsetTimebuilt from given String.
-
isBeforeOrEqualTo
Verifies that the actualOffsetTimeis before or equals to the given one.Example :
assertThat(parse("12:00:00Z")).isBeforeOrEqualTo(parse("12:00:00Z")) .isBeforeOrEqualTo(parse("12:00:01Z"));- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not before or equals to the given one.
-
isBeforeOrEqualTo
Same assertion asisBeforeOrEqualTo(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("12:00:00Z")).isBeforeOrEqualTo("12:00:00Z") .isBeforeOrEqualTo("13:00:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not before or equals to theOffsetTimebuilt from given String.
-
isAfterOrEqualTo
Verifies that the actualOffsetTimeis after or equals to the given one.Example :
assertThat(parse("13:00:00Z")).isAfterOrEqualTo(parse("13:00:00Z")) .isAfterOrEqualTo(parse("12:00:00Z"));- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not after or equals to the given one.
-
isAfterOrEqualTo
Same assertion asisAfterOrEqualTo(java.time.OffsetTime)but theOffsetTimeis built from given String, which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isAfterOrEqualTo("13:00:00Z") .isAfterOrEqualTo("12:00:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not after or equals to theOffsetTimebuilt from given String.
-
isAfter
Verifies that the actualOffsetTimeis strictly after the given one.Example :
assertThat(parse("13:00:00Z")).isAfter(parse("12:00:00Z"));- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not strictly after the given one.
-
isAfter
Same assertion asisAfter(java.time.OffsetTime)but theOffsetTimeis built from given a String that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isAfter("12:00:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not strictly after theOffsetTimebuilt from given String.
-
isEqualTo
Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beOffsetTime) but here you passOffsetTimeString representation that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isEqualTo("13:00:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not equal to theOffsetTimebuilt from given String.
-
isNotEqualTo
Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beOffsetTime) but here you passOffsetTimeString representation that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isNotEqualTo("12:00:00Z");- Parameters:
offsetTimeAsString- String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis equal to theOffsetTimebuilt from given String.
-
isIn
Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beOffsetTime) but here you passOffsetTimeString representations that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTimes as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isIn("12:00:00Z", "13:00:00Z");- Parameters:
offsetTimesAsString- String array representingOffsetTimes.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis not in theOffsetTimes built from given Strings.
-
isNotIn
Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beOffsetTime) but here you passOffsetTimeString representations that must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example :
// you can express expected OffsetTimes as String (AssertJ taking care of the conversion) assertThat(parse("13:00:00Z")).isNotIn("12:00:00Z", "14:00:00Z");- Parameters:
offsetTimesAsString- Array of String representing aOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if given String is null or can't be converted to aOffsetTime.AssertionError- if the actualOffsetTimeis in theOffsetTimes built from given Strings.
-
convertToOffsetTimeArray
-
checkIsNotNullAndNotEmpty
-
assertOffsetTimeAsStringParameterIsNotNull
Check that theOffsetTimestring representation to compare actualOffsetTimeto is not null, otherwise throws aIllegalArgumentExceptionwith an explicit message- Parameters:
OffsetTimeAsString- String representing theOffsetTimeto compare actual with- Throws:
IllegalArgumentException- with an explicit message if the givenStringis null
-
assertOffsetTimeParameterIsNotNull
Check that theOffsetTimeto compare actualOffsetTimeto is not null, in that case throws aIllegalArgumentExceptionwith an explicit message- Parameters:
other- theOffsetTimeto check- Throws:
IllegalArgumentException- with an explicit message if the givenOffsetTimeis null
-
isEqualToIgnoringNanos
Deprecated.UseisCloseTo(OffsetTime, TemporalOffset)instead, although not exactly the same semantics, this is the right way to compare with a given precision.Verifies that actual and givenOffsetTimehave same hour, minute and second fields (nanosecond fields are ignored in comparison).Assertion can fail with OffsetTimes in same chronological nanosecond time window, e.g :
23:00:01.000000000+01:00 and 23:00:00.999999999+01:00.
Assertion fails as second fields differ even if time difference is only 1ns.
Code example :
// successful assertions OffsetTime OffsetTime1 = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC); OffsetTime OffsetTime2 = OffsetTime.of(12, 0, 1, 456, ZoneOffset.UTC); assertThat(OffsetTime1).isEqualToIgnoringNanos(OffsetTime2); // failing assertions (even if time difference is only 1ns) OffsetTime OffsetTimeA = OffsetTime.of(12, 0, 1, 0, ZoneOffset.UTC); OffsetTime OffsetTimeB = OffsetTime.of(12, 0, 0, 999999999, ZoneOffset.UTC); assertThat(OffsetTimeA).isEqualToIgnoringNanos(OffsetTimeB);- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not equal with nanoseconds ignored.
-
isEqualToIgnoringSeconds
Deprecated.UseisCloseTo(OffsetTime, TemporalOffset)instead, although not exactly the same semantics, this is the right way to compare with a given precision.Verifies that actual and givenOffsetTimehave same hour and minute fields (second and nanosecond fields are ignored in comparison).Assertion can fail with OffsetTimes in same chronological second time window, e.g :
23:01:00.000+01:00 and 23:00:59.000+01:00.
Assertion fails as minute fields differ even if time difference is only 1s.
Code example :
// successful assertions OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC); OffsetTime OffsetTime2 = OffsetTime.of(23, 50, 10, 456, ZoneOffset.UTC); assertThat(OffsetTime1).isEqualToIgnoringSeconds(OffsetTime2); // failing assertions (even if time difference is only 1ms) OffsetTime OffsetTimeA = OffsetTime.of(23, 50, 00, 000, ZoneOffset.UTC); OffsetTime OffsetTimeB = OffsetTime.of(23, 49, 59, 999, ZoneOffset.UTC); assertThat(OffsetTimeA).isEqualToIgnoringSeconds(OffsetTimeB);- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not equal with second and nanosecond fields ignored.
-
isEqualToIgnoringTimezone
Verifies that actual and givenOffsetTimehave same hour, minute, second and nanosecond fields).Code examples :
// successful assertions OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC); OffsetTime offsetTime2 = OffsetTime.of(12, 0, 0, 0, ZoneOffset.MAX); assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2); // failing assertions (even if time difference is only 1ms) OffsetTime offsetTime = OffsetTime.of(12, 0, 0, 0, ZoneOffset.UTC); OffsetTime offsetTime2 = OffsetTime.of(12, 1, 0, 0, ZoneOffset.UTC); assertThat(offsetTime).isEqualToIgnoringTimezone(offsetTime2);- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not equal with timezone ignored.
-
hasSameHourAs
Verifies that actual and givenOffsetTimehave same hour fields (minute, second and nanosecond fields are ignored in comparison).Assertion can fail with OffsetTimes in same chronological second time window, e.g :
01:00:00.000+01:00 and 00:59:59.000+01:00.
Time difference is only 1s but hour fields differ.
Code example :
// successful assertions OffsetTime OffsetTime1 = OffsetTime.of(23, 50, 0, 0, ZoneOffset.UTC); OffsetTime OffsetTime2 = OffsetTime.of(23, 00, 2, 7, ZoneOffset.UTC); assertThat(OffsetTime1).hasSameHourAs(OffsetTime2); // failing assertions (even if time difference is only 1ms) OffsetTime OffsetTimeA = OffsetTime.of(01, 00, 00, 000, ZoneOffset.UTC); OffsetTime OffsetTimeB = OffsetTime.of(00, 59, 59, 999, ZoneOffset.UTC); assertThat(OffsetTimeA).hasSameHourAs(OffsetTimeB);- Parameters:
other- the givenOffsetTime.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualOffsetTimeisnull.IllegalArgumentException- if otherOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not equal ignoring minute, second and nanosecond fields.
-
isBetween
Verifies that the actualOffsetTimeis in the [start, end] period (start and end included).Example:
OffsetTime offsetTime = OffsetTime.now(); // assertions succeed: assertThat(offsetTime).isBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1)) .isBetween(offsetTime, offsetTime.plusSeconds(1)) .isBetween(offsetTime.minusSeconds(1), offsetTime) .isBetween(offsetTime, offsetTime); // assertions fail: assertThat(offsetTime).isBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1)); assertThat(offsetTime).isBetween(offsetTime.plusSeconds(1), offsetTime.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(OffsetTime, OffsetTime)but here you passOffsetTimeString representations which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example:
OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00"); // assertions succeed: assertThat(oneAm).isBetween("00:59:59+02:00", "01:00:01+02:00") .isBetween("01:00:00+02:00", "01:00:01+02:00") .isBetween("00:59:59+02:00", "01:00:00+02:00") .isBetween("01:00:00+02:00", "01:00:00+02:00") // assertion fails: assertThat(oneAm).isBetween("01:00:01+02:00", "02:00:01+02:00");- 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 aOffsetTime.AssertionError- if the actual value is not in [start, end] period.- Since:
- 3.7.1
-
isStrictlyBetween
Verifies that the actualOffsetTimeis in the ]start, end[ period (start and end excluded).Example:
OffsetTime offsetTime = OffsetTime.now(); // assertion succeeds: assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime.plusSeconds(1)); // assertions fail: assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(10), offsetTime.minusSeconds(1)); assertThat(offsetTime).isStrictlyBetween(offsetTime.plusSeconds(1), offsetTime.plusSeconds(10)); assertThat(offsetTime).isStrictlyBetween(offsetTime, offsetTime.plusSeconds(1)); assertThat(offsetTime).isStrictlyBetween(offsetTime.minusSeconds(1), offsetTime);- 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(OffsetTime, OffsetTime)but here you passOffsetTimeString representations which must follow ISO OffsetTime format to allow callingOffsetTime.parse(CharSequence)method.Example:
OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00"); // assertion succeeds: assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:01+02:00"); // assertions fail: assertThat(oneAm).isStrictlyBetween("02:00:00+02:00", "03:00:00+02:00"); assertThat(oneAm).isStrictlyBetween("00:59:59+02:00", "01:00:00+02:00"); assertThat(oneAm).isStrictlyBetween("01:00:00+02:00", "01:00:01+02:00");- 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 aOffsetTime.AssertionError- if the actual value is not in ]start, end[ period.- Since:
- 3.7.1
-
isCloseTo
Verifies that the actualOffsetTimeis close to the other according to the givenTemporalOffset.You can build the offset parameter using
Assertions.within(long, TemporalUnit)orAssertions.byLessThan(long, TemporalUnit).Example:
OffsetTime oneAm = OffsetTime.parse("01:00:00+02:00"); // assertion succeeds: assertThat(oneAm).isCloseTo(oneAm.plusHours(1), within(30, ChronoUnit.MINUTES)); // assertion fails: assertThat(oneAm).isCloseTo(_07_42, within(10, ChronoUnit.SECONDS));- Overrides:
isCloseToin classAbstractTemporalAssert<SELF extends AbstractOffsetTimeAssert<SELF>,OffsetTime> - Parameters:
other- the offsetTime to compare actual tooffset- the offset used for comparison- Returns:
- this assertion object
- Throws:
NullPointerException- ifOffsetTimeorTemporalOffsetparameter isnull.AssertionError- if the actualOffsetTimeisnull.AssertionError- if the actualOffsetTimeis not close to the given one within the provided offset.
-
parse
Obtains an instance ofTEMPORALfrom a string representation in ISO date format.- Specified by:
parsein classAbstractTemporalAssert<SELF extends AbstractOffsetTimeAssert<SELF>,OffsetTime> - Parameters:
offsetTimeAsString- the string to parse, not null- Returns:
- the parsed
TEMPORAL, not null
-
areEqualIgnoringNanos
Returns true if both OffsetTime are in the same hour, minute and second, false otherwise.- Parameters:
actual- the actual OffsetTime. expected not be nullother- the other OffsetTime. expected not be null- Returns:
- true if both OffsetTime are in the same year, month and day of month, hour, minute and second, false otherwise.
-
areEqualIgnoringSeconds
Returns true if both OffsetTime are in the same hour and minute, false otherwise.- Parameters:
actual- the actual OffsetTime. expected not be nullother- the other OffsetTime. expected not be null- Returns:
- true if both OffsetTime are in the same hour and minute, false otherwise.
-
areEqualIgnoringTimezone
Returns true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.- Parameters:
actual- the actual OffsetTime. expected not be nullother- the other OffsetTime. expected not be null- Returns:
- true if both OffsetTime are in the same hour, minute, second and nanosecond false otherwise.
-
haveSameNano
-
haveSameSecond
-
haveSameMinute
-
haveSameHourField
-
isCloseTo(OffsetTime, TemporalOffset)instead, although not exactly the same semantics, this is the right way to compare with a given precision.