R
- The return type.public class FluentObjectAssertion<R> extends FluentAssertion<R>
Constructor and Description |
---|
FluentObjectAssertion(Assertion creator,
Object value,
R returns)
Constructor.
|
FluentObjectAssertion(Object value,
R returns)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
R |
doesNotEqual(Object value)
Asserts that the value equals the specified value.
|
R |
doesNotExist()
Asserts that the object is null.
|
protected Object |
equivalent(Object o)
Subclasses can override this method to provide special conversions on objects being compared.
|
R |
exists()
Asserts that the object is not null.
|
R |
is(Object value)
Asserts that the value equals the specified value.
|
R |
isAny(Object... values)
Asserts that the value is one of the specified values.
|
R |
isEqual(Object value)
Asserts that the value equals the specified value.
|
R |
isNot(Object value)
Asserts that the value equals the specified value.
|
R |
isNotAny(Object... values)
Asserts that the value is one of the specified values.
|
R |
isNotNull()
Asserts that the object is not null.
|
R |
isNull()
Asserts that the object i null.
|
R |
isType(Class<?> parent)
Asserts that the object is an instance of the specified class.
|
FluentStringAssertion<R> |
json()
Converts this object to simplified JSON and returns it as a new assertion.
|
FluentStringAssertion<R> |
jsonSorted()
Converts this object to sorted simplified JSON and returns it as a new assertion.
|
FluentObjectAssertion<R> |
msg(String msg,
Object... args)
Allows to to specify the assertion failure message.
|
<T> R |
passes(Class<T> c,
Predicate<T> test)
Asserts that the value passes the specified predicate test.
|
R |
passes(Predicate<Object> test)
Asserts that the value passes the specified predicate test.
|
R |
sameAs(Object o)
Verifies that two objects are equivalent after converting them both to JSON.
|
R |
sameAsSerialized(Object o,
WriterSerializer serializer)
Asserts that the specified object is the same as this object after converting both to strings using the specified serializer.
|
R |
sameAsSorted(Object o)
Verifies that two objects are equivalent after converting them both to sorted JSON.
|
FluentStringAssertion<R> |
serialized(WriterSerializer ws)
Converts this object to text using the specified serializer and returns it as a new assertion.
|
FluentObjectAssertion<R> |
stderr()
If an error occurs, send the error message to STDERR.
|
FluentObjectAssertion<R> |
stdout()
If an error occurs, send the error message to STDOUT.
|
FluentStringAssertion<R> |
string()
Converts this object to a string using
Object.toString() and returns it as a new assertion. |
<T> FluentStringAssertion<R> |
string(Class<T> c,
Function<T,String> function)
Converts this object to a string using the specified function and returns it as a new assertion.
|
FluentStringAssertion<R> |
string(Function<Object,String> function)
Converts this object to a string using the specified function and returns it as a new assertion.
|
returns
assertNotNull, assertNotNull, className, error
public FluentObjectAssertion(Object value, R returns)
value
- The object being tested.returns
- The object to return after the test.public FluentObjectAssertion(Assertion creator, Object value, R returns)
creator
- The assertion that created this assertion.value
- The object being tested.returns
- The object to return after the test.public R isType(Class<?> parent) throws AssertionError
parent
- The value to check against.AssertionError
- If assertion failed.public FluentStringAssertion<R> serialized(WriterSerializer ws)
ws
- The serializer to use to convert the object to text.public FluentStringAssertion<R> string()
Object.toString()
and returns it as a new assertion.
public FluentStringAssertion<R> string(Function<Object,String> function)
function
- The conversion function.public <T> FluentStringAssertion<R> string(Class<T> c, Function<T,String> function)
T
- The class of the object being converted.c
- The class of the object being converted.function
- The conversion function.public FluentStringAssertion<R> json()
public FluentStringAssertion<R> jsonSorted()
public R sameAs(Object o) throws AssertionError
o
- The object to compare against.AssertionError
- If assertion failed.public R sameAsSorted(Object o)
Properties, maps, and collections are all sorted on both objects before comparison.
o
- The object to compare against.AssertionError
- If assertion failed.public R sameAsSerialized(Object o, WriterSerializer serializer)
o
- The object to compare against.serializer
- The serializer to use to serialize this object.AssertionError
- If assertion failed.public R isEqual(Object value) throws AssertionError
value
- The value to check against.AssertionError
- If assertion failed.public R is(Object value) throws AssertionError
Equivalent to isEqual(Object)
.
value
- The value to check against.AssertionError
- If assertion failed.public R doesNotEqual(Object value) throws AssertionError
value
- The value to check against.AssertionError
- If assertion failed.public R passes(Predicate<Object> test) throws AssertionError
test
- The predicate to use to test the value.AssertionError
- If assertion failed.public <T> R passes(Class<T> c, Predicate<T> test) throws AssertionError
T
- The class type of the object being tested.c
- The class type of the object being tested.test
- The predicate to use to test the value.AssertionError
- If assertion failed.public R exists() throws AssertionError
Equivalent to isNotNull()
.
AssertionError
- If assertion failed.public R doesNotExist() throws AssertionError
Equivalent to isNotNull()
.
AssertionError
- If assertion failed.public R isNotNull() throws AssertionError
Equivalent to isNotNull()
.
AssertionError
- If assertion failed.public R isNull() throws AssertionError
Equivalent to isNotNull()
.
AssertionError
- If assertion failed.public R isNot(Object value) throws AssertionError
Equivalent to doesNotEqual(Object)
.
value
- The value to check against.AssertionError
- If assertion failed.public R isAny(Object... values) throws AssertionError
values
- The values to check against.AssertionError
- If assertion failed.public R isNotAny(Object... values) throws AssertionError
values
- The values to check against.AssertionError
- If assertion failed.protected Object equivalent(Object o)
o
- The object to cast.public FluentObjectAssertion<R> msg(String msg, Object... args)
Assertion
String can contain
msg
in class FluentAssertion<R>
msg
- The assertion failure message.args
- Optional message arguments.public FluentObjectAssertion<R> stderr()
Assertion
stderr
in class FluentAssertion<R>
public FluentObjectAssertion<R> stdout()
Assertion
stdout
in class FluentAssertion<R>
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.