SELF
- the "self" type of this assertion class.public class AbstractInstantAssert<SELF extends AbstractInstantAssert<SELF>> extends AbstractTemporalAssert<SELF,Instant>
Instant
type from new Date & Time API introduced in Java 8.actual, info, myself, throwUnsupportedExceptionOnEquals
Modifier | Constructor and Description |
---|---|
protected |
AbstractInstantAssert(Instant actual,
Class<?> selfType)
Creates a new
. |
Modifier and Type | Method and Description |
---|---|
SELF |
isAfter(Instant other)
Verifies that the actual
Instant is strictly after the given one. |
SELF |
isAfter(String instantAsString)
Same assertion as
isAfter(Instant) but the Instant is built from given a String that
must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isAfterOrEqualTo(Instant other)
Verifies that the actual
Instant is after or equals to the given one. |
SELF |
isAfterOrEqualTo(String instantAsString)
Same assertion as
isAfterOrEqualTo(Instant) but the Instant is built from given
String, which must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isBefore(Instant other)
Verifies that the actual
Instant is strictly before the given one. |
SELF |
isBefore(String instantAsString)
Same assertion as
isBefore(Instant) but the Instant is built from given String, which
must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isBeforeOrEqualTo(Instant other)
Verifies that the actual
Instant is before or equals to the given one. |
SELF |
isBeforeOrEqualTo(String instantAsString)
Same assertion as
isBeforeOrEqualTo(Instant) but the Instant is built from given
String, which must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isBetween(Instant startInclusive,
Instant endInclusive)
Verifies that the actual
Instant is in the [start, end] period (start and end included). |
SELF |
isBetween(String startInclusive,
String endInclusive)
Same assertion as
isBetween(Instant, Instant) but here you pass Instant String representations
that must follow ISO Instant format
to allow calling Instant.parse(CharSequence) method. |
SELF |
isEqualTo(String instantAsString)
Same assertion as
AbstractAssert.isEqualTo(Object) (where Object is expected to be Instant ) but here you
pass Instant String representation that must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isIn(String... instantsAsString)
Same assertion as
AbstractAssert.isIn(Object...) (where Objects are expected to be Instant ) but here you
pass Instant String representations that must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isNotEqualTo(String instantAsString)
Same assertion as
AbstractAssert.isNotEqualTo(Object) (where Object is expected to be Instant ) but here you
pass Instant String representation that must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isNotIn(String... instantsAsString)
Same assertion as
AbstractAssert.isNotIn(Object...) (where Objects are expected to be Instant ) but here you
pass Instant String representations that must follow ISO Instant format to allow calling Instant.parse(CharSequence) method. |
SELF |
isStrictlyBetween(Instant startExclusive,
Instant endExclusive)
Verifies that the actual
Instant is in the ]start, end[ period (start and end excluded). |
SELF |
isStrictlyBetween(String startExclusive,
String endExclusive)
Same assertion as
isStrictlyBetween(Instant, Instant) but here you pass Instant String representations
that must follow ISO Instant format
to allow calling Instant.parse(CharSequence) method. |
protected Instant |
parse(String instantAsString)
Obtains an instance of
TEMPORAL from a string representation in ISO date format. |
getActual, isCloseTo, isCloseTo
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, 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, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
protected AbstractInstantAssert(Instant actual, Class<?> selfType)
AbstractInstantAssert
.selfType
- the "self type"actual
- the actual value to verifypublic SELF isBefore(Instant other)
Instant
is strictly before the given one.
Example :
assertThat(parse("2007-12-03T10:15:30.00Z")).isBefore(parse("2007-12-03T10:15:31.00Z"));
other
- the given Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if other Instant
is null
.AssertionError
- if the actual Instant
is not strictly before the given one.public SELF isBefore(String instantAsString)
isBefore(Instant)
but the Instant
is built from given String, which
must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2007-12-03T10:15:30.00Z").isBefore("2007-12-03T10:15:31.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not strictly before the Instant
built
from given String.public SELF isBeforeOrEqualTo(Instant other)
Instant
is before or equals to the given one.
Example :
assertThat(parse("2007-12-03T10:15:30.00Z")).isBeforeOrEqualTo(parse("2007-12-03T10:15:30.00Z"))
.isBeforeOrEqualTo(parse("2007-12-03T10:15:31.00Z"));
other
- the given Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if other Instant
is null
.AssertionError
- if the actual Instant
is not before or equals to the given one.public SELF isBeforeOrEqualTo(String instantAsString)
isBeforeOrEqualTo(Instant)
but the Instant
is built from given
String, which must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2007-12-03T10:15:30.00Z")).isBeforeOrEqualTo("2007-12-03T10:15:30.00Z")
.isBeforeOrEqualTo("2007-12-03T10:15:31.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not before or equals to the Instant
built from
given String.public SELF isAfterOrEqualTo(Instant other)
Instant
is after or equals to the given one.
Example :
assertThat(parse("2007-12-03T10:15:30.00Z")).isAfterOrEqualTo(parse("2007-12-03T10:15:30.00Z"))
.isAfterOrEqualTo(parse("2007-12-03T10:15:27.00Z"));
other
- the given Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if other Instant
is null
.AssertionError
- if the actual Instant
is not after or equals to the given one.public SELF isAfterOrEqualTo(String instantAsString)
isAfterOrEqualTo(Instant)
but the Instant
is built from given
String, which must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2007-12-03T10:15:30.00Z")).isAfterOrEqualTo("2007-12-03T10:15:30.00Z")
.isAfterOrEqualTo("2007-12-03T10:15:27.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not after or equals to the Instant
built from
given String.public SELF isAfter(Instant other)
Instant
is strictly after the given one.
Example :
assertThat(parse("2007-12-03T10:15:30.00Z").isAfter(parse("2007-12-03T10:15:27.00Z"));
other
- the given Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if other Instant
is null
.AssertionError
- if the actual Instant
is not strictly after the given one.public SELF isAfter(String instantAsString)
isAfter(Instant)
but the Instant
is built from given a String that
must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String in comparison to avoid conversion
assertThat(parse("2007-12-03T10:15:30.00Z")).isAfter("2007-12-03T10:15:27.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not strictly after the Instant
built
from given String.public SELF isEqualTo(String instantAsString)
AbstractAssert.isEqualTo(Object)
(where Object is expected to be Instant
) but here you
pass Instant
String representation that must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2007-12-03T10:15:30.00Z")).isEqualTo("2007-12-03T10:15:30.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not equal to the Instant
built from
given String.public SELF isNotEqualTo(String instantAsString)
AbstractAssert.isNotEqualTo(Object)
(where Object is expected to be Instant
) but here you
pass Instant
String representation that must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use directly String in comparison to avoid writing the code to perform the conversion
assertThat(parse("2007-12-03T10:15:30.00Z")).isNotEqualTo("2007-12-03T10:15:00.00Z");
instantAsString
- String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given String is null.DateTimeParseException
- if given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is equal to the Instant
built from given
String.public SELF isIn(String... instantsAsString)
AbstractAssert.isIn(Object...)
(where Objects are expected to be Instant
) but here you
pass Instant
String representations that must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String based representation of Instant
assertThat(parse("2007-12-03T10:15:30.00Z")).isIn("2007-12-03T10:15:30.00Z", "2007-12-03T10:15:35.00Z");
instantsAsString
- String array representing Instant
s.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given Strings are null or empty.DateTimeParseException
- if one of the given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is not in the Instant
s built from given
Strings.public SELF isNotIn(String... instantsAsString)
AbstractAssert.isNotIn(Object...)
(where Objects are expected to be Instant
) but here you
pass Instant
String representations that must follow ISO Instant format to allow calling Instant.parse(CharSequence)
method.
Example :
// use String based representation of Instant
assertThat(parse("2007-12-03T10:15:30.00Z")).isNotIn("2007-12-03T10:15:35.00Z", "2007-12-03T10:15:25.00Z");
instantsAsString
- Array of String representing a Instant
.AssertionError
- if the actual Instant
is null
.IllegalArgumentException
- if given Strings are null or empty.DateTimeParseException
- if one of the given String can't be converted to a Instant
.AssertionError
- if the actual Instant
is in the Instant
s built from given
Strings.public SELF isBetween(Instant startInclusive, Instant endInclusive)
Instant
is in the [start, end] period (start and end included).
Example:
Instant instant = Instant.now();
// assertions succeed:
assertThat(instant).isBetween(instant.minusSeconds(1), instant.plusSeconds(1))
.isBetween(instant, instant.plusSeconds(1))
.isBetween(instant.minusSeconds(1), instant)
.isBetween(instant, instant);
// assertions fail:
assertThat(instant).isBetween(instant.minusSeconds(10), instant.minusSeconds(1));
assertThat(instant).isBetween(instant.plusSeconds(1), instant.plusSeconds(10));
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in [start, end] range.public SELF isBetween(String startInclusive, String endInclusive)
isBetween(Instant, Instant)
but here you pass Instant
String representations
that must follow ISO Instant format
to allow calling Instant.parse(CharSequence)
method.
Example:
Instant firstOfJanuary2000 = Instant.parse("2000-01-01T00:00:00.00Z");
// assertions succeed:
assertThat(firstOfJanuary2000).isBetween("1999-01-01T00:00:00.00Z", "2001-01-01T00:00:00.00Z")
.isBetween("2000-01-01T00:00:00.00Z", "2001-01-01T00:00:00.00Z")
.isBetween("1999-01-01T00:00:00.00Z", "2000-01-01T00:00:00.00Z")
.isBetween("2000-01-01T00:00:00.00Z", "2000-01-01T00:00:00.00Z");
// assertion fails:
assertThat(firstOfJanuary2000).isBetween("1999-01-01T00:00:00.00Z", "1999-12-31T23:59:59.59Z");
startInclusive
- the start value (inclusive), expected not to be null.endInclusive
- the end value (inclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.DateTimeParseException
- if any of the given String can't be converted to a Instant
.AssertionError
- if the actual value is not in [start, end] range.public SELF isStrictlyBetween(Instant startExclusive, Instant endExclusive)
Instant
is in the ]start, end[ period (start and end excluded).
Example:
Instant instant = Instant.now();
// assertion succeeds:
assertThat(instant).isStrictlyBetween(instant.minusSeconds(1), instant.plusSeconds(1));
// assertions fail:
assertThat(instant).isStrictlyBetween(instant.minusSeconds(10), instant.minusSeconds(1));
assertThat(instant).isStrictlyBetween(instant.plusSeconds(1), instant.plusSeconds(10));
assertThat(instant).isStrictlyBetween(instant, instant.plusSeconds(1));
assertThat(instant).isStrictlyBetween(instant.minusSeconds(1), instant);
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.AssertionError
- if the actual value is not in ]start, end[ range.public SELF isStrictlyBetween(String startExclusive, String endExclusive)
isStrictlyBetween(Instant, Instant)
but here you pass Instant
String representations
that must follow ISO Instant format
to allow calling Instant.parse(CharSequence)
method.
Example:
Instant firstOfJanuary2000 = Instant.parse("2000-01-01T00:00:00.00Z");
// assertion succeeds:
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01T00:00:00.00Z", "2001-01-01T00:00:00.00Z");
// assertions fail:
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01T00:00:00.00Z", "1999-12-31T23:59:59.59Z");
assertThat(firstOfJanuary2000).isStrictlyBetween("2000-01-01T00:00:00.00Z", "2001-01-01T00:00:00.00Z");
assertThat(firstOfJanuary2000).isStrictlyBetween("1999-01-01T00:00:00.00Z", "2000-01-01T00:00:00.00Z");
startExclusive
- the start value (exclusive), expected not to be null.endExclusive
- the end value (exclusive), expected not to be null.AssertionError
- if the actual value is null
.NullPointerException
- if start value is null
.NullPointerException
- if end value is null
.DateTimeParseException
- if any of the given String can't be converted to a Instant
.AssertionError
- if the actual value is not in ]start, end[ range.protected Instant parse(String instantAsString)
AbstractTemporalAssert
TEMPORAL
from a string representation in ISO date format.parse
in class AbstractTemporalAssert<SELF extends AbstractInstantAssert<SELF>,Instant>
instantAsString
- the string to parse, not nullTEMPORAL
, not nullCopyright © 2014–2019 AssertJ. All rights reserved.