Package io.vertx.reactivex.ext.unit
Class TestContext
- java.lang.Object
-
- io.vertx.reactivex.ext.unit.TestContext
-
public class TestContext extends Object
The test context is used for performing test assertions and manage the completion of the test. This context is provided by vertx-unit as argument of the test case.NOTE: This class has been automatically generated from the
original
non RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<TestContext>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description TestContext(TestContext delegate)
TestContext(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TestContext
assertEquals(Object expected, Object actual)
Assert theexpected
argument is equals to theactual
argument.TestContext
assertEquals(Object expected, Object actual, String message)
Assert theexpected
argument is equals to theactual
argument.TestContext
assertFalse(boolean condition)
Assert the specifiedcondition
isfalse
.TestContext
assertFalse(boolean condition, String message)
Assert the specifiedcondition
isfalse
.TestContext
assertInRange(double expected, double actual, double delta)
Asserts that theexpected
double argument is equals to theactual
double argument within a positive delta.TestContext
assertInRange(double expected, double actual, double delta, String message)
Asserts that theexpected
double argument is equals to theactual
double argument within a positive delta.TestContext
assertNotEquals(Object first, Object second)
Assert thefirst
argument is not equals to thesecond
argument.TestContext
assertNotEquals(Object first, Object second, String message)
Assert thefirst
argument is not equals to thesecond
argument.TestContext
assertNotNull(Object expected)
Assert theexpected
argument is notnull
.TestContext
assertNotNull(Object expected, String message)
Assert theexpected
argument is notnull
.TestContext
assertNull(Object expected)
Assert theexpected
argument isnull
.TestContext
assertNull(Object expected, String message)
Assert theexpected
argument isnull
.TestContext
assertTrue(boolean condition)
Assert the specifiedcondition
istrue
.TestContext
assertTrue(boolean condition, String message)
Assert the specifiedcondition
istrue
.Async
async()
Create and returns a new async object, the returned async controls the completion of the test.Async
async(int count)
Create and returns a new async object, the returned async controls the completion of the test.<T> Handler<AsyncResult<T>>
asyncAssertFailure()
Creates and returns a new async handler, the returned handler controls the completion of the test.<T> Handler<AsyncResult<T>>
asyncAssertFailure(Handler<Throwable> causeHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test.<T> Handler<AsyncResult<T>>
asyncAssertSuccess()
Creates and returns a new async handler, the returned handler controls the completion of the test.<T> Handler<AsyncResult<T>>
asyncAssertSuccess(Handler<T> resultHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test.boolean
equals(Object o)
Handler<Throwable>
exceptionHandler()
void
fail()
Throw a failure.void
fail(String message)
Throw a failure with the specified failuremessage
.void
fail(Throwable cause)
Throw a failure with the specified failurecause
.<T> T
get(String key)
Get some data from the context.TestContext
getDelegate()
int
hashCode()
static TestContext
newInstance(TestContext arg)
<T> T
put(String key, Object value)
Put some data in the context.<T> T
remove(String key)
Remove some data from the context.Async
strictAsync(int count)
Create and returns a new async object, the returned async controls the completion of the test.String
toString()
TestContext
verify(Handler<Void> block)
Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework.
-
-
-
Field Detail
-
__TYPE_ARG
public static final io.vertx.lang.rx.TypeArg<TestContext> __TYPE_ARG
-
-
Constructor Detail
-
TestContext
public TestContext(TestContext delegate)
-
TestContext
public TestContext(Object delegate)
-
-
Method Detail
-
getDelegate
public TestContext getDelegate()
-
get
public <T> T get(String key)
Get some data from the context.- Parameters:
key
- the key of the data- Returns:
- the data
-
put
public <T> T put(String key, Object value)
Put some data in the context.This can be used to share data between different tests and before/after phases.
- Parameters:
key
- the key of the datavalue
- the data- Returns:
- the previous object when it exists
-
remove
public <T> T remove(String key)
Remove some data from the context.- Parameters:
key
- the key to remove- Returns:
- the removed object when it exists
-
assertNull
public TestContext assertNull(Object expected)
Assert theexpected
argument isnull
. If the argument is not, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the argument being asserted to be null- Returns:
- a reference to this, so the API can be used fluently
-
assertNull
public TestContext assertNull(Object expected, String message)
Assert theexpected
argument isnull
. If the argument is not, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the argument being asserted to be nullmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertNotNull
public TestContext assertNotNull(Object expected)
Assert theexpected
argument is notnull
. If the argument isnull
, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the argument being asserted to be not null- Returns:
- a reference to this, so the API can be used fluently
-
assertNotNull
public TestContext assertNotNull(Object expected, String message)
Assert theexpected
argument is notnull
. If the argument isnull
, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the argument being asserted to be not nullmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertTrue
public TestContext assertTrue(boolean condition)
Assert the specifiedcondition
istrue
. If the condition isfalse
, an assertion error is thrown otherwise the execution continue.- Parameters:
condition
- the condition to assert- Returns:
- a reference to this, so the API can be used fluently
-
assertTrue
public TestContext assertTrue(boolean condition, String message)
Assert the specifiedcondition
istrue
. If the condition isfalse
, an assertion error is thrown otherwise the execution continue.- Parameters:
condition
- the condition to assertmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertFalse
public TestContext assertFalse(boolean condition)
Assert the specifiedcondition
isfalse
. If the condition istrue
, an assertion error is thrown otherwise the execution continue.- Parameters:
condition
- the condition to assert- Returns:
- a reference to this, so the API can be used fluently
-
assertFalse
public TestContext assertFalse(boolean condition, String message)
Assert the specifiedcondition
isfalse
. If the condition istrue
, an assertion error is thrown otherwise the execution continue.- Parameters:
condition
- the condition to assertmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertEquals
public TestContext assertEquals(Object expected, Object actual)
Assert theexpected
argument is equals to theactual
argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the object the actual object is supposedly equals toactual
- the actual object to test- Returns:
- a reference to this, so the API can be used fluently
-
assertEquals
public TestContext assertEquals(Object expected, Object actual, String message)
Assert theexpected
argument is equals to theactual
argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the object the actual object is supposedly equals toactual
- the actual object to testmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertInRange
public TestContext assertInRange(double expected, double actual, double delta)
Asserts that theexpected
double argument is equals to theactual
double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the object the actual object is supposedly equals toactual
- the actual object to testdelta
- the maximum delta- Returns:
- a reference to this, so the API can be used fluently
-
assertInRange
public TestContext assertInRange(double expected, double actual, double delta, String message)
Asserts that theexpected
double argument is equals to theactual
double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.- Parameters:
expected
- the object the actual object is supposedly equals toactual
- the actual object to testdelta
- the maximum deltamessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
assertNotEquals
public TestContext assertNotEquals(Object first, Object second)
Assert thefirst
argument is not equals to thesecond
argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.- Parameters:
first
- the first object to testsecond
- the second object to test- Returns:
- a reference to this, so the API can be used fluently
-
assertNotEquals
public TestContext assertNotEquals(Object first, Object second, String message)
Assert thefirst
argument is not equals to thesecond
argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.- Parameters:
first
- the first object to testsecond
- the second object to testmessage
- the failure message- Returns:
- a reference to this, so the API can be used fluently
-
verify
public TestContext verify(Handler<Void> block)
Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework. AnyAssertionError
thrown will be caught (and propagated) in order to fulfill potential expected async completeness.- Parameters:
block
- block of code to be executed- Returns:
- a reference to this, so the API can be used fluently
-
fail
public void fail()
Throw a failure.
-
fail
public void fail(String message)
Throw a failure with the specified failuremessage
.- Parameters:
message
- the failure message
-
fail
public void fail(Throwable cause)
Throw a failure with the specified failurecause
.- Parameters:
cause
- the failure cause
-
async
public Async async()
Create and returns a new async object, the returned async controls the completion of the test. Calling theAsync.complete()
completes the async operation. The test case will complete when all the async objects have theirAsync.complete()
method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Returns:
- the async instance
-
async
public Async async(int count)
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when theAsync.countDown()
is calledcount
times. The test case will complete when all the async objects have theirAsync.complete()
method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Parameters:
count
-- Returns:
- the async instance
-
strictAsync
public Async strictAsync(int count)
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when theAsync.countDown()
is calledcount
times. IfAsync.countDown()
is called more thancount
times, anIllegalStateException
is thrown. The test case will complete when all the async objects have theirAsync.complete()
method called at least once. This method shall be used for creating asynchronous exit points for the executed test.- Parameters:
count
-- Returns:
- the async instance
-
exceptionHandler
public Handler<Throwable> exceptionHandler()
- Returns:
- an exception handler that will fail this context
-
asyncAssertSuccess
public <T> Handler<AsyncResult<T>> asyncAssertSuccess()
Creates and returns a new async handler, the returned handler controls the completion of the test. When the returned handler is called back with a succeeded result it completes the async operation. When the returned handler is called back with a failed result it fails the test with the cause of the failure.- Returns:
- the async result handler
-
asyncAssertSuccess
public <T> Handler<AsyncResult<T>> asyncAssertSuccess(Handler<T> resultHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test. When the returned handler is called back with a succeeded result it invokes theresultHandler
argument with the async result. The test completes after the result handler is invoked and does not fails. When the returned handler is called back with a failed result it fails the test with the cause of the failure. Note that the result handler can create other async objects during its invocation that would postpone the completion of the test case until those objects are resolved.- Parameters:
resultHandler
- the result handler- Returns:
- the async result handler
-
asyncAssertFailure
public <T> Handler<AsyncResult<T>> asyncAssertFailure()
Creates and returns a new async handler, the returned handler controls the completion of the test. When the returned handler is called back with a failed result it completes the async operation. When the returned handler is called back with a succeeded result it fails the test.- Returns:
- the async result handler
-
asyncAssertFailure
public <T> Handler<AsyncResult<T>> asyncAssertFailure(Handler<Throwable> causeHandler)
Creates and returns a new async handler, the returned handler controls the completion of the test. When the returned handler is called back with a failed result it completes the async operation. When the returned handler is called back with a succeeded result it fails the test.- Parameters:
causeHandler
- the cause handler- Returns:
- the async result handler
-
newInstance
public static TestContext newInstance(TestContext arg)
-
-