java.util.Optional .
java.util.Optional .
| Modifier and Type | Field and Description |
|---|---|
| private ComparisonStrategy |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public SELF | Returns: this assertion object.the expected value inside the expectedValue)java..Verifies that the actual |
| public SELF | Returns: this assertion object.the expected class of the value inside the clazz)Optional.Verifies that the actual |
| public SELF | Returns: this assertion object.the expected value inside the expectedValue)java..Verifies that the actual |
| public <U> AbstractOptionalAssert | Returns: a newAbstractOptionalAssert for assertions chaining on the flatMap of the Optional.Call |
| public AbstractObjectAssert | Returns: a newAbstractObjectAssert for assertions chaining on the value of the Optional.Verifies that the actual |
| public < the type of the resulting ASSERT extends AbstractAssertAssert | Returns: a new narrowedAssert instance for assertions chaining on the value of the Optionalthe factory which verifies the type and creates the new assertFactory)AssertVerifies that the actual |
| public SELF | Returns: this assertion object.the expected value inside the expectedValue)java..Verifies that the actual |
| public SELF | Returns: this assertion object.to further assert on the object contained inside the requirement)java..Verifies that the actual |
| public SELF | Returns: this assertion object.the given condition. condition)Verifies that the actual |
| private AbstractObjectAssert | |
| public SELF | |
| public SELF | Returns: this assertion object.Verifies that there is a value present in the actual |
| public SELF | Returns: this assertion object.Verifies that the actual |
| public SELF | Returns: this assertion object.Verifies that there is a value present in the actual |
| public <U> AbstractOptionalAssert | Returns: a newAbstractOptionalAssert for assertions chaining on the map of the Optional.Call |
| public SELF | Returns: this assertion object.Revert to standard comparison for incoming assertion |
| public SELF | Returns: this assertion object.
Deprecated
This method is deprecated because it performs a shallow field by field comparison, i.e. elements are compared
field by field but the fields are compared with equals, use
Use field/property by field/property comparison (including inherited fields/properties) instead of relying on
actual type A get() chained with AbstractObjectAssert#usingRecursiveComparison() instead.
equals method to compare the Optional value's object for incoming assertion
checks.
|
| public RecursiveAssertionAssert | Returns: A new instance ofRecursiveAssertionAssert built with a default RecursiveAssertionConfiguration.Overrides org. Asserts that the given predicate is met for all fields of the object under test recursively (but not the object itself). |
| public RecursiveAssertionAssert | Returns: A new instance ofRecursiveAssertionAssert built with a default RecursiveAssertionConfiguration.The recursion configuration described above. recursiveAssertionConfiguration)Overrides org. The same as |
| public RecursiveComparisonAssert | Returns: a newRecursiveComparisonAssert instanceOverrides org. RecursiveComparisonAssert,
Example:
|
| public RecursiveComparisonAssert | Returns: a newRecursiveComparisonAssert instance built with the given RecursiveComparisonConfiguration.the recursiveComparisonConfiguration)RecursiveComparisonConfiguration used in the chained isEqualTo assertion.Overrides org. usingRecursiveComparison() but allows to specify your own RecursiveComparisonConfiguration.
|
| public SELF | Returns: this assertion object.the comparator to use for incoming assertion checks. customComparator)Use given custom comparator instead of relying on actual type A |
| optionalValueComparisonStrategy | back to summary |
|---|---|
| private ComparisonStrategy optionalValueComparisonStrategy | |
| AbstractOptionalAssert | back to summary |
|---|---|
| protected AbstractOptionalAssert(Optional<VALUE> actual, Class<?> selfType) | |
| assertValueIsPresent | back to summary |
|---|---|
| private void assertValueIsPresent() | |
| checkNotNull | back to summary |
|---|---|
| private void checkNotNull(Object expectedValue) | |
| contains | back to summary |
|---|---|
| public SELF contains(VALUE expectedValue) Verifies that the actual Assertion will pass :
Assertion will fail :
| |
| containsInstanceOf | back to summary |
|---|---|
| public SELF containsInstanceOf(Class<?> clazz) Verifies that the actual Assertions will pass:
Assertion will fail:
| |
| containsSame | back to summary |
|---|---|
| public SELF containsSame(VALUE expectedValue) Verifies that the actual Assertion will pass :
Assertion will fail :
| |
| flatMap | back to summary |
|---|---|
| public <U> AbstractOptionalAssert Call Examples:
| |
| get | back to summary |
|---|---|
| public AbstractObjectAssert Verifies that the actual Note that it is only possible to return Object assertions after calling this method due to java generics limitations. Example:
| |
| get | back to summary |
|---|---|
| public <ASSERT extends AbstractAssert Verifies that the actual
The
Wrapping the given Example:
| |
| hasValue | back to summary |
|---|---|
| public SELF hasValue(VALUE expectedValue) Verifies that the actual Assertion will pass :
Assertion will fail :
| |
| hasValueSatisfying | back to summary |
|---|---|
| public SELF hasValueSatisfying(Consumer<VALUE> requirement) Verifies that the actual Assertions will pass :
Assertions will fail :
| |
| hasValueSatisfying | back to summary |
|---|---|
| public SELF hasValueSatisfying(Condition<? super VALUE> condition) Verifies that the actual Examples:
| |
| internalGet | back to summary |
|---|---|
| private AbstractObjectAssert | |
| isEmpty | back to summary |
|---|---|
| public SELF isEmpty() Verifies that the actual Assertion will pass :
Assertion will fail :
| |
| isNotEmpty | back to summary |
|---|---|
| public SELF isNotEmpty() Verifies that there is a value present in the actual Assertion will pass :
Assertion will fail :
| |
| isNotPresent | back to summary |
|---|---|
| public SELF isNotPresent() Verifies that the actual Assertion will pass :
Assertion will fail :
| |
| isPresent | back to summary |
|---|---|
| public SELF isPresent() Verifies that there is a value present in the actual Assertion will pass :
Assertion will fail :
| |
| map | back to summary |
|---|---|
| public <U> AbstractOptionalAssert Call Examples:
| |
| usingDefaultValueComparator | back to summary |
|---|---|
| public SELF usingDefaultValueComparator() Revert to standard comparison for incoming assertion
This method should be used to disable a custom comparison strategy set by calling
| |
| usingFieldByFieldValueComparator | back to summary |
|---|---|
| public SELF usingFieldByFieldValueComparator()
Deprecated This method is deprecated because it performs a shallow field by field comparison, i.e. elements are compared
field by field but the fields are compared with equals, use
See https://assertj.github.io/doc/#assertj-core-recursive-comparison Use field/property by field/property comparison (including inherited fields/properties) instead of relying on
actual type A
This can be handy if equals method.
Example:
| |
| usingRecursiveAssertion | back to summary |
|---|---|
| public RecursiveAssertionAssert usingRecursiveAssertion() Overrides org. Asserts that the given predicate is met for all fields of the object under test recursively (but not the object itself). For example if the object under test is an instance of class A, A has a B field and B a C field then the assertion checks A's B field and B's C field and all C's fields. The recursive algorithm employs cycle detection, so object graphs with cyclic references can safely be asserted over without causing looping. This method enables recursive asserting using default configuration, which means all fields of all objects have the
You can change how the recursive assertion deals with arrays, collections, maps and optionals, see:
It is possible to assert several predicates over the object graph in a row. The classes used in recursive asserting are not thread safe. Care must be taken when running tests in parallel not to run assertions over object graphs that are being shared between tests. Example
In case one or more fields in the object graph fails the predicate test, the entire assertion will fail. Failing fields will be listed in the failure report using a JSON path-ish notation.
| |
| usingRecursiveAssertion | back to summary |
|---|---|
| public RecursiveAssertionAssert usingRecursiveAssertion(RecursiveAssertionConfiguration recursiveAssertionConfiguration) Overrides org. The same as
Please refer to the documentation of
| |
| usingRecursiveComparison | back to summary |
|---|---|
| public RecursiveComparisonAssert Overrides org. Enable using a recursive field by field comparison strategy when calling the chained Example:
A detailed documentation for the recursive comparison is available here: https://assertj.github.io/doc/#assertj-core-recursive-comparison.
The default recursive comparison behavior is
| |
| usingRecursiveComparison | back to summary |
|---|---|
| public RecursiveComparisonAssert Overrides org. Same as
| |
| usingValueComparator | back to summary |
|---|---|
| public SELF usingValueComparator(Comparator<? super VALUE> customComparator) Use given custom comparator instead of relying on actual type A Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy. Examples :
| |