/*
 * 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.ext.unit.TestOptions;
import io.vertx.core.Handler;

A named suite of test cases that are executed altogether. The suite suite is created with the create and the returned suite contains initially no tests.

The suite can declare a callback before the suite with before or after the suite with after.

The suite can declare a callback before each test with beforeEach or after each test with afterEach.

Each test case of the suite is declared by calling the test method.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * A named suite of test cases that are executed altogether. The suite suite is created with * the {@link io.vertx.reactivex.ext.unit.TestSuite#create} and the returned suite contains initially no tests.<p/> * * The suite can declare a callback before the suite with {@link io.vertx.reactivex.ext.unit.TestSuite#before} or after * the suite with {@link io.vertx.reactivex.ext.unit.TestSuite#after}.<p/> * * The suite can declare a callback before each test with {@link io.vertx.reactivex.ext.unit.TestSuite#beforeEach} or after * each test with {@link io.vertx.reactivex.ext.unit.TestSuite#afterEach}.<p/> * * Each test case of the suite is declared by calling the {@link io.vertx.reactivex.ext.unit.TestSuite#test} method. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.ext.unit.TestSuite original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.ext.unit.TestSuite.class) public class TestSuite { @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; TestSuite that = (TestSuite) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<TestSuite> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new TestSuite((io.vertx.ext.unit.TestSuite) obj), TestSuite::getDelegate ); private final io.vertx.ext.unit.TestSuite delegate; public TestSuite(io.vertx.ext.unit.TestSuite delegate) { this.delegate = delegate; } public io.vertx.ext.unit.TestSuite getDelegate() { return delegate; }
Create and return a new test suite.
Params:
  • name – the test suite name
Returns:the created test suite
/** * Create and return a new test suite. * @param name the test suite name * @return the created test suite */
public static io.vertx.reactivex.ext.unit.TestSuite create(String name) { io.vertx.reactivex.ext.unit.TestSuite ret = io.vertx.reactivex.ext.unit.TestSuite.newInstance(io.vertx.ext.unit.TestSuite.create(name)); return ret; }
Set a callback executed before the tests.
Params:
  • callback – the callback
Returns:a reference to this, so the API can be used fluently
/** * Set a callback executed before the tests. * @param callback the callback * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite before(Handler<io.vertx.reactivex.ext.unit.TestContext> callback) { delegate.before(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Set a callback executed before each test and after the suite before callback.
Params:
  • callback – the callback
Returns:a reference to this, so the API can be used fluently
/** * Set a callback executed before each test and after the suite <code>before</code> callback. * @param callback the callback * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite beforeEach(Handler<io.vertx.reactivex.ext.unit.TestContext> callback) { delegate.beforeEach(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Set a callback executed after the tests.
Params:
  • callback – the callback
Returns:a reference to this, so the API can be used fluently
/** * Set a callback executed after the tests. * @param callback the callback * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite after(Handler<io.vertx.reactivex.ext.unit.TestContext> callback) { delegate.after(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Set a callback executed after each test and before the suite after callback.
Params:
  • callback – the callback
Returns:a reference to this, so the API can be used fluently
/** * Set a callback executed after each test and before the suite <code>after</code> callback. * @param callback the callback * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite afterEach(Handler<io.vertx.reactivex.ext.unit.TestContext> callback) { delegate.afterEach(new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { callback.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Add a new test case to the suite.
Params:
  • name – the test case name
  • testCase – the test case
Returns:a reference to this, so the API can be used fluently
/** * Add a new test case to the suite. * @param name the test case name * @param testCase the test case * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite test(String name, Handler<io.vertx.reactivex.ext.unit.TestContext> testCase) { delegate.test(name, new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { testCase.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Add a new test case to the suite.
Params:
  • name – the test case name
  • repeat – the number of times the test should be repeated
  • testCase – the test case
Returns:a reference to this, so the API can be used fluently
/** * Add a new test case to the suite. * @param name the test case name * @param repeat the number of times the test should be repeated * @param testCase the test case * @return a reference to this, so the API can be used fluently */
public io.vertx.reactivex.ext.unit.TestSuite test(String name, int repeat, Handler<io.vertx.reactivex.ext.unit.TestContext> testCase) { delegate.test(name, repeat, new Handler<io.vertx.ext.unit.TestContext>() { public void handle(io.vertx.ext.unit.TestContext event) { testCase.handle(io.vertx.reactivex.ext.unit.TestContext.newInstance(event)); } }); return this; }
Run the testsuite with the default options.

When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this context's event loop is used for running the test suite. Otherwise it is executed in the current thread.

The returned Completion object can be used to get a completion callback.
Returns:the related test completion
/** * Run the testsuite with the default options.<p/> * * When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this * context's event loop is used for running the test suite. Otherwise it is executed in the current thread.<p/> * * The returned {@link io.vertx.reactivex.ext.unit.Completion} object can be used to get a completion callback. * @return the related test completion */
public io.vertx.reactivex.ext.unit.TestCompletion run() { io.vertx.reactivex.ext.unit.TestCompletion ret = io.vertx.reactivex.ext.unit.TestCompletion.newInstance(delegate.run()); return ret; }
Run the testsuite with the specified options.

When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this context's event loop is used for running the test suite unless the TestOptions is set to false. In this case it is executed by the current thread.

Otherwise, the test suite will be executed in the current thread when TestOptions is set to false or null. If the value is true, this methods throws an IllegalStateException.

The returned Completion object can be used to get a completion callback.
Params:
  • options – the test options
Returns:the related test completion
/** * Run the testsuite with the specified <code>options</code>.<p/> * * When the test suite is executed in a Vertx context (i.e `Vertx.currentContext()` returns a context) this * context's event loop is used for running the test suite unless the {@link io.vertx.ext.unit.TestOptions} * is set to <code>false</code>. In this case it is executed by the current thread.<p/> * * Otherwise, the test suite will be executed in the current thread when {@link io.vertx.ext.unit.TestOptions} is * set to <code>false</code> or <code>null</code>. If the value is <code>true</code>, this methods throws an <code>IllegalStateException</code>.<p/> * * The returned {@link io.vertx.reactivex.ext.unit.Completion} object can be used to get a completion callback. * @param options the test options * @return the related test completion */
public io.vertx.reactivex.ext.unit.TestCompletion run(TestOptions options) { io.vertx.reactivex.ext.unit.TestCompletion ret = io.vertx.reactivex.ext.unit.TestCompletion.newInstance(delegate.run(options)); return ret; }
Run the testsuite with the default options and the specified vertx instance.

The test suite will be executed on the event loop provided by the vertx argument. The returned Completion object can be used to get a completion callback.

Params:
  • vertx – the vertx instance
Returns:the related test completion
/** * Run the testsuite with the default options and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument. The returned * {@link io.vertx.reactivex.ext.unit.Completion} object can be used to get a completion callback.<p/> * @param vertx the vertx instance * @return the related test completion */
public io.vertx.reactivex.ext.unit.TestCompletion run(io.vertx.reactivex.core.Vertx vertx) { io.vertx.reactivex.ext.unit.TestCompletion ret = io.vertx.reactivex.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate())); return ret; }
Run the testsuite with the specified options and the specified vertx instance.

The test suite will be executed on the event loop provided by the vertx argument when TestOptions is not set to false. The returned Completion object can be used to get a completion callback.
Params:
  • vertx – the vertx instance
  • options – the test options
Returns:the related test completion
/** * Run the testsuite with the specified <code>options</code> and the specified <code>vertx</code> instance.<p/> * * The test suite will be executed on the event loop provided by the <code>vertx</code> argument when * {@link io.vertx.ext.unit.TestOptions} is not set to <code>false</code>. The returned * {@link io.vertx.reactivex.ext.unit.Completion} object can be used to get a completion callback. * @param vertx the vertx instance * @param options the test options * @return the related test completion */
public io.vertx.reactivex.ext.unit.TestCompletion run(io.vertx.reactivex.core.Vertx vertx, TestOptions options) { io.vertx.reactivex.ext.unit.TestCompletion ret = io.vertx.reactivex.ext.unit.TestCompletion.newInstance(delegate.run(vertx.getDelegate(), options)); return ret; } public static TestSuite newInstance(io.vertx.ext.unit.TestSuite arg) { return arg != null ? new TestSuite(arg) : null; } }