/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.reactivex.ext.unit;

import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

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.
/** * The test context is used for performing test assertions and manage the completion of the test. This context * is provided by <i>vertx-unit</i> as argument of the test case. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.ext.unit.TestContext original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.ext.unit.TestContext.class) public class TestContext { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TestContext that = (TestContext) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<TestContext> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new TestContext((io.vertx.ext.unit.TestContext) obj), TestContext::getDelegate ); private final io.vertx.ext.unit.TestContext delegate; public TestContext(io.vertx.ext.unit.TestContext delegate) { this.delegate = delegate; } public io.vertx.ext.unit.TestContext getDelegate() { return delegate; }
Get some data from the context.
Params:
  • key – the key of the data
Returns:the data
/** * Get some data from the context. * @param key the key of the data * @return the data */
public <T> T get(String key) { T ret = (T) delegate.get(key); return ret; }
Put some data in the context.

This can be used to share data between different tests and before/after phases.

Params:
  • key – the key of the data
  • value – the data
Returns:the previous object when it exists
/** * Put some data in the context. * <p> * This can be used to share data between different tests and before/after phases. * @param key the key of the data * @param value the data * @return the previous object when it exists */
public <T> T put(String key, Object value) { T ret = (T) delegate.put(key, value); return ret; }
Remove some data from the context.
Params:
  • key – the key to remove
Returns:the removed object when it exists
/** * Remove some data from the context. * @param key the key to remove * @return the removed object when it exists */
public <T> T remove(String key) { T ret = (T) delegate.remove(key); return ret; }
Assert the expected argument is null. If the argument is not, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the argument being asserted to be null
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNull(Object expected) { delegate.assertNull(expected); return this; }
Assert the expected argument is null. If the argument is not, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the argument being asserted to be null
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is <code>null</code>. If the argument is not, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be null * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNull(Object expected, String message) { delegate.assertNull(expected, message); return this; }
Assert the expected argument is not null. If the argument is null, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the argument being asserted to be not null
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is not <code>null</code>. If the argument is <code>null</code>, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be not null * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNotNull(Object expected) { delegate.assertNotNull(expected); return this; }
Assert the expected argument is not null. If the argument is null, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the argument being asserted to be not null
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is not <code>null</code>. If the argument is <code>null</code>, an assertion error is thrown * otherwise the execution continue. * @param expected the argument being asserted to be not null * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNotNull(Object expected, String message) { delegate.assertNotNull(expected, message); return this; }
Assert the specified condition is true. If the condition is false, an assertion error is thrown otherwise the execution continue.
Params:
  • condition – the condition to assert
Returns:a reference to this, so the API can be used fluently
/** * Assert the specified <code>condition</code> is <code>true</code>. If the condition is <code>false</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertTrue(boolean condition) { delegate.assertTrue(condition); return this; }
Assert the specified condition is true. If the condition is false, an assertion error is thrown otherwise the execution continue.
Params:
  • condition – the condition to assert
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the specified <code>condition</code> is <code>true</code>. If the condition is <code>false</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertTrue(boolean condition, String message) { delegate.assertTrue(condition, message); return this; }
Assert the specified condition is false. If the condition is true, an assertion error is thrown otherwise the execution continue.
Params:
  • condition – the condition to assert
Returns:a reference to this, so the API can be used fluently
/** * Assert the specified <code>condition</code> is <code>false</code>. If the condition is <code>true</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertFalse(boolean condition) { delegate.assertFalse(condition); return this; }
Assert the specified condition is false. If the condition is true, an assertion error is thrown otherwise the execution continue.
Params:
  • condition – the condition to assert
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the specified <code>condition</code> is <code>false</code>. If the condition is <code>true</code>, an assertion error is thrown * otherwise the execution continue. * @param condition the condition to assert * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertFalse(boolean condition, String message) { delegate.assertFalse(condition, message); return this; }
Assert the expected argument is equals to the actual argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the object the actual object is supposedly equals to
  • actual – the actual object to test
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is equals to the <code>actual</code> argument. If the arguments are not equals * an assertion error is thrown otherwise the execution continue. * @param expected the object the actual object is supposedly equals to * @param actual the actual object to test * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertEquals(Object expected, Object actual) { delegate.assertEquals(expected, actual); return this; }
Assert the expected argument is equals to the actual argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the object the actual object is supposedly equals to
  • actual – the actual object to test
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>expected</code> argument is equals to the <code>actual</code> argument. If the arguments are not equals * an assertion error is thrown otherwise the execution continue. * @param expected the object the actual object is supposedly equals to * @param actual the actual object to test * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertEquals(Object expected, Object actual, String message) { delegate.assertEquals(expected, actual, message); return this; }
Asserts that the expected double argument is equals to the actual double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the object the actual object is supposedly equals to
  • actual – the actual object to test
  • delta – the maximum delta
Returns:a reference to this, so the API can be used fluently
/** * Asserts that the <code>expected</code> double argument is equals to the <code>actual</code> double argument * within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise * the execution continue. * @param expected the object the actual object is supposedly equals to * @param actual the actual object to test * @param delta the maximum delta * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertInRange(double expected, double actual, double delta) { delegate.assertInRange(expected, actual, delta); return this; }
Asserts that the expected double argument is equals to the actual double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.
Params:
  • expected – the object the actual object is supposedly equals to
  • actual – the actual object to test
  • delta – the maximum delta
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Asserts that the <code>expected</code> double argument is equals to the <code>actual</code> double argument * within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise * the execution continue. * @param expected the object the actual object is supposedly equals to * @param actual the actual object to test * @param delta the maximum delta * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertInRange(double expected, double actual, double delta, String message) { delegate.assertInRange(expected, actual, delta, message); return this; }
Assert the first argument is not equals to the second argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.
Params:
  • first – the first object to test
  • second – the second object to test
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>first</code> argument is not equals to the <code>second</code> argument. If the arguments are equals * an assertion error is thrown otherwise the execution continue. * @param first the first object to test * @param second the second object to test * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNotEquals(Object first, Object second) { delegate.assertNotEquals(first, second); return this; }
Assert the first argument is not equals to the second argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.
Params:
  • first – the first object to test
  • second – the second object to test
  • message – the failure message
Returns:a reference to this, so the API can be used fluently
/** * Assert the <code>first</code> argument is not equals to the <code>second</code> argument. If the arguments are equals * an assertion error is thrown otherwise the execution continue. * @param first the first object to test * @param second the second object to test * @param message the failure message * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext assertNotEquals(Object first, Object second, String message) { delegate.assertNotEquals(first, second, message); return this; }
Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework. Any AssertionError thrown will be caught (and propagated) in order to fulfill potential expected async completeness.
Params:
  • block – block of code to be executed
Returns:a reference to this, so the API can be used fluently
/** * Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework. * Any {@link java.lang.AssertionError} thrown will be caught (and propagated) in order to fulfill potential expected async * completeness. * @param block block of code to be executed * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestContext verify(Handler<Void> block) { delegate.verify(block); return this; }
Throw a failure.
/** * Throw a failure. */
public void fail() { delegate.fail(); }
Throw a failure with the specified failure message.
Params:
  • message – the failure message
/** * Throw a failure with the specified failure <code>message</code>. * @param message the failure message */
public void fail(String message) { delegate.fail(message); }
Throw a failure with the specified failure cause.
Params:
  • cause – the failure cause
/** * Throw a failure with the specified failure <code>cause</code>. * @param cause the failure cause */
public void fail(Throwable cause) { delegate.fail(cause); }
Create and returns a new async object, the returned async controls the completion of the test. Calling the Async.complete completes the async operation.

The test case will complete when all the async objects have their Async.complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.
Returns:the async instance
/** * Create and returns a new async object, the returned async controls the completion of the test. Calling the * {@link io.vertx.reactivex.ext.unit.Async#complete} completes the async operation.<p/> * * The test case will complete when all the async objects have their {@link io.vertx.reactivex.ext.unit.Async#complete} * method called at least once.<p/> * * This method shall be used for creating asynchronous exit points for the executed test. * @return the async instance */
public io.vertx.reactivex.ext.unit.Async async() { io.vertx.reactivex.ext.unit.Async ret = io.vertx.reactivex.ext.unit.Async.newInstance(delegate.async()); return ret; }
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the Async.countDown is called count times.

The test case will complete when all the async objects have their Async.complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

Params:
  • count –
Returns:the async instance
/** * Create and returns a new async object, the returned async controls the completion of the test. This async operation * completes when the {@link io.vertx.reactivex.ext.unit.Async#countDown} is called <code>count</code> times.<p/> * * The test case will complete when all the async objects have their {@link io.vertx.reactivex.ext.unit.Async#complete} * method called at least once.<p/> * * This method shall be used for creating asynchronous exit points for the executed test.<p/> * @param count * @return the async instance */
public io.vertx.reactivex.ext.unit.Async async(int count) { io.vertx.reactivex.ext.unit.Async ret = io.vertx.reactivex.ext.unit.Async.newInstance(delegate.async(count)); return ret; }
Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the Async.countDown is called count times.

If Async.countDown is called more than count times, an IllegalStateException is thrown.

The test case will complete when all the async objects have their Async.complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

Params:
  • count –
Returns:the async instance
/** * Create and returns a new async object, the returned async controls the completion of the test. * This async operation completes when the {@link io.vertx.reactivex.ext.unit.Async#countDown} is called <code>count</code> times.<p/> * If {@link io.vertx.reactivex.ext.unit.Async#countDown} is called more than <code>count</code> times, an {@link java.lang.IllegalStateException} is thrown.<p/> * * The test case will complete when all the async objects have their {@link io.vertx.reactivex.ext.unit.Async#complete} * method called at least once.<p/> * * This method shall be used for creating asynchronous exit points for the executed test.<p/> * @param count * @return the async instance */
public io.vertx.reactivex.ext.unit.Async strictAsync(int count) { io.vertx.reactivex.ext.unit.Async ret = io.vertx.reactivex.ext.unit.Async.newInstance(delegate.strictAsync(count)); return ret; }
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
/** * Creates and returns a new async handler, the returned handler controls the completion of the test.<p/> * * When the returned handler is called back with a succeeded result it completes the async operation.<p/> * * When the returned handler is called back with a failed result it fails the test with the cause of the failure.<p/> * @return the async result handler */
public <T> Handler<AsyncResult<T>> asyncAssertSuccess() { Handler<AsyncResult<T>> ret = delegate.asyncAssertSuccess(); return ret; }
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 the resultHandler 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.
Params:
  • resultHandler – the result handler
Returns:the async result handler
/** * Creates and returns a new async handler, the returned handler controls the completion of the test.<p/> * * When the returned handler is called back with a succeeded result it invokes the <code>resultHandler</code> argument * with the async result. The test completes after the result handler is invoked and does not fails.<p/> * * When the returned handler is called back with a failed result it fails the test with the cause of the failure.<p/> * * 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. * @param resultHandler the result handler * @return the async result handler */
public <T> Handler<AsyncResult<T>> asyncAssertSuccess(Handler<T> resultHandler) { Handler<AsyncResult<T>> ret = delegate.asyncAssertSuccess(resultHandler); return ret; }
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
/** * Creates and returns a new async handler, the returned handler controls the completion of the test.<p/> * * When the returned handler is called back with a failed result it completes the async operation.<p/> * * When the returned handler is called back with a succeeded result it fails the test.<p/> * @return the async result handler */
public <T> Handler<AsyncResult<T>> asyncAssertFailure() { Handler<AsyncResult<T>> ret = delegate.asyncAssertFailure(); return ret; }
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.

Params:
  • causeHandler – the cause handler
Returns:the async result handler
/** * Creates and returns a new async handler, the returned handler controls the completion of the test.<p/> * * When the returned handler is called back with a failed result it completes the async operation.<p/> * * When the returned handler is called back with a succeeded result it fails the test.<p/> * @param causeHandler the cause handler * @return the async result handler */
public <T> Handler<AsyncResult<T>> asyncAssertFailure(Handler<Throwable> causeHandler) { Handler<AsyncResult<T>> ret = delegate.asyncAssertFailure(causeHandler); return ret; }
Returns:an exception handler that will fail this context
/** * @return an exception handler that will fail this context */
public Handler<Throwable> exceptionHandler() { Handler<Throwable> ret = delegate.exceptionHandler(); return ret; } public static TestContext newInstance(io.vertx.ext.unit.TestContext arg) { return arg != null ? new TestContext(arg) : null; } }