Package org.assertj.core.api
Class AbstractInstantAssert<SELF extends AbstractInstantAssert<SELF>>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,Instant>
org.assertj.core.api.AbstractTemporalAssert<SELF,Instant>
org.assertj.core.api.AbstractInstantAssert<SELF>
- Type Parameters:
SELF- the "self" type of this assertion class.
- All Implemented Interfaces:
Assert<SELF,,Instant> Descriptable<SELF>,ExtensionPoints<SELF,Instant>
- Direct Known Subclasses:
InstantAssert
public class AbstractInstantAssert<SELF extends AbstractInstantAssert<SELF>>
extends AbstractTemporalAssert<SELF,Instant>
Assertions for
Instant type from new Date & Time API introduced in Java 8.- Since:
- 3.7.0
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractInstantAssert(Instant actual, Class<?> selfType) Creates a new.AbstractInstantAssert -
Method Summary
Modifier and TypeMethodDescriptionSame assertion asisAfter(Instant)but theInstantis built from given a String that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Verifies that the actualInstantis strictly after the given one.isAfterOrEqualTo(String instantAsString) Same assertion asisAfterOrEqualTo(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.isAfterOrEqualTo(Instant other) Verifies that the actualInstantis after or equals to the given one.Same assertion asisBefore(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Verifies that the actualInstantis strictly before the given one.isBeforeOrEqualTo(String instantAsString) Same assertion asisBeforeOrEqualTo(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.isBeforeOrEqualTo(Instant other) Verifies that the actualInstantis before or equals to the given one.Same assertion asisBetween(Instant, Instant)but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Verifies that the actualInstantis in the [start, end] period (start and end included).Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beInstant) but here you passInstantString representation that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beInstant) but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Verifies that the actualInstantis strictly in the future.Verifies that the actualInstantis strictly in the past.isNotEqualTo(String instantAsString) Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beInstant) but here you passInstantString representation that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beInstant) but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.isStrictlyBetween(String startExclusive, String endExclusive) Same assertion asisStrictlyBetween(Instant, Instant)but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.parse(CharSequence)method.isStrictlyBetween(Instant startExclusive, Instant endExclusive) Verifies that the actualInstantis in the ]start, end[ period (start and end excluded).protected InstantObtains an instance ofTEMPORALfrom a string representation in ISO date format.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
-
AbstractInstantAssert
Creates a new.AbstractInstantAssert- Parameters:
actual- the actual value to verifyselfType- the "self type"
-
-
Method Details
-
isBefore
Verifies that the actualInstantis strictly before the given one.Example :
assertThat(parse("2007-12-03T10:15:30.00Z")).isBefore(parse("2007-12-03T10:15:31.00Z"));- Parameters:
other- the givenInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if otherInstantisnull.AssertionError- if the actualInstantis not strictly before the given one.- Since:
- 3.7.0
-
isBefore
Same assertion asisBefore(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis not strictly before theInstantbuilt from given String.- Since:
- 3.7.0
-
isBeforeOrEqualTo
Verifies that the actualInstantis 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"));- Parameters:
other- the givenInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if otherInstantisnull.AssertionError- if the actualInstantis not before or equals to the given one.- Since:
- 3.7.0
-
isBeforeOrEqualTo
Same assertion asisBeforeOrEqualTo(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis not before or equals to theInstantbuilt from given String.- Since:
- 3.7.0
-
isAfterOrEqualTo
Verifies that the actualInstantis 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"));- Parameters:
other- the givenInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if otherInstantisnull.AssertionError- if the actualInstantis not after or equals to the given one.- Since:
- 3.7.0
-
isAfterOrEqualTo
Same assertion asisAfterOrEqualTo(Instant)but theInstantis built from given String, which must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis not after or equals to theInstantbuilt from given String.- Since:
- 3.7.0
-
isAfter
Verifies that the actualInstantis strictly after the given one.Example :
assertThat(parse("2007-12-03T10:15:30.00Z").isAfter(parse("2007-12-03T10:15:27.00Z"));- Parameters:
other- the givenInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if otherInstantisnull.AssertionError- if the actualInstantis not strictly after the given one.- Since:
- 3.7.0
-
isAfter
Same assertion asisAfter(Instant)but theInstantis built from given a String that must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis not strictly after theInstantbuilt from given String.- Since:
- 3.7.0
-
isEqualTo
Same assertion asAbstractAssert.isEqualTo(Object)(where Object is expected to beInstant) but here you passInstantString representation that must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis not equal to theInstantbuilt from given String.- Since:
- 3.7.0
-
isNotEqualTo
Same assertion asAbstractAssert.isNotEqualTo(Object)(where Object is expected to beInstant) but here you passInstantString representation that must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantAsString- String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given String is null.DateTimeParseException- if given String can't be converted to aInstant.AssertionError- if the actualInstantis equal to theInstantbuilt from given String.- Since:
- 3.7.0
-
isIn
Same assertion asAbstractAssert.isIn(Object...)(where Objects are expected to beInstant) but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantsAsString- String array representingInstants.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given Strings are null or empty.DateTimeParseException- if one of the given String can't be converted to aInstant.AssertionError- if the actualInstantis not in theInstants built from given Strings.- Since:
- 3.7.0
-
isNotIn
Same assertion asAbstractAssert.isNotIn(Object...)(where Objects are expected to beInstant) but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.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");- Parameters:
instantsAsString- Array of String representing aInstant.- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.IllegalArgumentException- if given Strings are null or empty.DateTimeParseException- if one of the given String can't be converted to aInstant.AssertionError- if the actualInstantis in theInstants built from given Strings.- Since:
- 3.7.0
-
isInThePast
Verifies that the actualInstantis strictly in the past.Example:
// assertion succeeds: assertThat(Instant.now().minusSeconds(60)).isInThePast();- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.AssertionError- if the actualInstantis not in the past.- Since:
- 3.25.0
-
isInTheFuture
Verifies that the actualInstantis strictly in the future.Example:
// assertion succeeds: assertThat(Instant.now().plusSeconds(60)).isInTheFuture();- Returns:
- this assertion object.
- Throws:
AssertionError- if the actualInstantisnull.AssertionError- if the actualInstantis not in the future.- Since:
- 3.25.0
-
isBetween
Verifies that the actualInstantis 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));- 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] range.- Since:
- 3.7.1
-
isBetween
Same assertion asisBetween(Instant, Instant)but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.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");- 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 aInstant.AssertionError- if the actual value is not in [start, end] range.- Since:
- 3.7.1
-
isStrictlyBetween
Verifies that the actualInstantis 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);- 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[ range.- Since:
- 3.7.1
-
isStrictlyBetween
Same assertion asisStrictlyBetween(Instant, Instant)but here you passInstantString representations that must follow ISO Instant format to allow callingInstant.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");- 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 aInstant.AssertionError- if the actual value is not in ]start, end[ range.- Since:
- 3.7.1
-
parse
Description copied from class:AbstractTemporalAssertObtains an instance ofTEMPORALfrom a string representation in ISO date format.- Specified by:
parsein classAbstractTemporalAssert<SELF extends AbstractInstantAssert<SELF>,Instant> - Parameters:
instantAsString- the string to parse, not null- Returns:
- the parsed
TEMPORAL, not null
-