public abstract class AbstractOffsetTimeAssert<S extends AbstractOffsetTimeAssert<S>> extends AbstractAssert<S,OffsetTime>
OffsetTime
type from new Date & Time API introduced in Java 8.Modifier and Type | Field and Description |
---|---|
static String |
NULL_OFFSET_TIME_PARAMETER_MESSAGE |
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractOffsetTimeAssert(OffsetTime actual,
Class<?> selfType)
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
protected OffsetTime |
getActual() |
S |
hasSameHourAs(OffsetTime other)
Verifies that actual and given
OffsetTime have same hour fields (minute, second and nanosecond fields are
ignored in comparison). |
S |
isAfter(OffsetTime other)
Verifies that the actual
OffsetTime is strictly after the given one. |
S |
isAfter(String offsetTimeAsString)
Same assertion as
isAfter(java.time.OffsetTime) but the OffsetTime is built from given a
String that
must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isAfterOrEqualTo(OffsetTime other)
Verifies that the actual
OffsetTime is after or equals to the given one. |
S |
isAfterOrEqualTo(String offsetTimeAsString)
Same assertion as
isAfterOrEqualTo(java.time.OffsetTime) but the OffsetTime is built
from given
String, which must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isBefore(OffsetTime other)
Verifies that the actual
OffsetTime is strictly before the given one. |
S |
isBefore(String offsetTimeAsString)
Same assertion as
isBefore(java.time.OffsetTime) but the OffsetTime is built from given
String, which
must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isBeforeOrEqualTo(OffsetTime other)
Verifies that the actual
OffsetTime is before or equals to the given one. |
S |
isBeforeOrEqualTo(String offsetTimeAsString)
Same assertion as
isBeforeOrEqualTo(java.time.OffsetTime) but the OffsetTime is built
from given
String, which must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isEqualTo(String offsetTimeAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be OffsetTime ) but here
you
pass OffsetTime String representation that must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isEqualToIgnoringNanos(OffsetTime other)
Verifies that actual and given
OffsetTime have same hour, minute and second fields (nanosecond fields are
ignored in comparison). |
S |
isEqualToIgnoringSeconds(OffsetTime other)
Verifies that actual and given
OffsetTime have same hour and minute fields (second and nanosecond
fields are
ignored in comparison). |
S |
isEqualToIgnoringTimezone(OffsetTime other)
Verifies that actual and given
OffsetTime have same hour, minute, second and nanosecond fields). |
S |
isIn(String... offsetTimesAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be OffsetTime ) but here
you
pass OffsetTime String representations that must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isNotEqualTo(String offsetTimeAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be OffsetTime ) but
here you
pass OffsetTime String representation that must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
S |
isNotIn(String... offsetTimesAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be OffsetTime ) but
here you
pass OffsetTime String representations that must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence) method. |
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
public static final String NULL_OFFSET_TIME_PARAMETER_MESSAGE
protected AbstractOffsetTimeAssert(OffsetTime actual, Class<?> selfType)
AbstractOffsetTimeAssert
.selfType
- the "self type"actual
- the actual value to verifyprotected OffsetTime getActual()
public S isBefore(OffsetTime other)
OffsetTime
is strictly before the given one.
Example :
assertThat(parse("12:00:00Z")).isBefore(parse("13:00:00Z"));
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not strictly before the given one.public S isBefore(String offsetTimeAsString)
isBefore(java.time.OffsetTime)
but the OffsetTime
is built from given
String, which
must follow ISO OffsetTime format to allow calling OffsetTime.parse(CharSequence)
method.
Example :
// you can express expected OffsetTime as String (AssertJ taking care of the conversion)
assertThat(parse("12:59Z")).isBefore("13:00Z");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not strictly before the OffsetTime
built
from given String.public S isBeforeOrEqualTo(OffsetTime other)
OffsetTime
is before or equals to the given one.
Example :
assertThat(parse("12:00:00Z")).isBeforeOrEqualTo(parse("12:00:00Z"))
.isBeforeOrEqualTo(parse("12:00:01Z"));
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not before or equals to the given one.public S isBeforeOrEqualTo(String offsetTimeAsString)
isBeforeOrEqualTo(java.time.OffsetTime)
but the OffsetTime
is built
from given
String, which must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not before or equals to the OffsetTime
built from given String.public S isAfterOrEqualTo(OffsetTime other)
OffsetTime
is after or equals to the given one.
Example :
assertThat(parse("13:00:00Z")).isAfterOrEqualTo(parse("13:00:00Z"))
.isAfterOrEqualTo(parse("12:00:00Z"));
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not after or equals to the given one.public S isAfterOrEqualTo(String offsetTimeAsString)
isAfterOrEqualTo(java.time.OffsetTime)
but the OffsetTime
is built
from given
String, which must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not after or equals to the OffsetTime
built from
given String.public S isAfter(OffsetTime other)
OffsetTime
is strictly after the given one.
Example :
assertThat(parse("13:00:00Z")).isAfter(parse("12:00:00Z"));
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not strictly after the given one.public S isAfter(String offsetTimeAsString)
isAfter(java.time.OffsetTime)
but the OffsetTime
is built from given a
String that
must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not strictly after the OffsetTime
built from given String.public S isEqualTo(String offsetTimeAsString)
AbstractAssert.isEqualTo(Object)
(where Object is expected to be OffsetTime
) but here
you
pass OffsetTime
String representation that must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not equal to the OffsetTime
built from
given String.public S isNotEqualTo(String offsetTimeAsString)
AbstractAssert.isNotEqualTo(Object)
(where Object is expected to be OffsetTime
) but
here you
pass OffsetTime
String representation that must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimeAsString
- String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is equal to the OffsetTime
built from
given String.public S isIn(String... offsetTimesAsString)
AbstractAssert.isIn(Object...)
(where Objects are expected to be OffsetTime
) but here
you
pass OffsetTime
String representations that must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimesAsString
- String array representing OffsetTime
s.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is not in the OffsetTime
s built from
given Strings.public S isNotIn(String... offsetTimesAsString)
AbstractAssert.isNotIn(Object...)
(where Objects are expected to be OffsetTime
) but
here you
pass OffsetTime
String representations that must follow ISO OffsetTime format to allow calling OffsetTime.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");
offsetTimesAsString
- Array of String representing a OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if given String is null or can't be converted to a OffsetTime
.AssertionError
- if the actual OffsetTime
is in the OffsetTime
s built from given
Strings.public S isEqualToIgnoringNanos(OffsetTime other)
OffsetTime
have 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);
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not equal with nanoseconds ignored.public S isEqualToIgnoringSeconds(OffsetTime other)
OffsetTime
have 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);
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not equal with second and nanosecond fields
ignored.public S isEqualToIgnoringTimezone(OffsetTime other)
OffsetTime
have 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);
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not equal with timezone ignored.public S hasSameHourAs(OffsetTime other)
OffsetTime
have 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);
other
- the given OffsetTime
.AssertionError
- if the actual OffsetTime
is null
.IllegalArgumentException
- if other OffsetTime
is null
.AssertionError
- if the actual OffsetTime
is not equal ignoring minute, second and nanosecond
fields.Copyright © 2014–2017 AssertJ. All rights reserved.