Example usage for io.vertx.core CompositeFuture join

List of usage examples for io.vertx.core CompositeFuture join

Introduction

In this page you can find the example usage for io.vertx.core CompositeFuture join.

Prototype

static <T1, T2> CompositeFuture join(Future<T1> f1, Future<T2> f2) 

Source Link

Document

Return a composite future, succeeded when all futures are succeeded, failed when any future is failed.

Usage

From source file:org.eclipse.hono.tests.IntegrationTestSupport.java

License:Open Source License

/**
 * Deletes all temporary objects from the Device Registry which
 * have been created during the last test execution.
 * /* w  w w.  j  a  v a 2  s. c om*/
 * @param ctx The vert.x context.
 */
public void deleteObjects(final TestContext ctx) {

    devicesToDelete.forEach((tenantId, devices) -> {
        devices.forEach(deviceId -> {
            final Async deletion = ctx.async();
            CompositeFuture
                    .join(registry.deregisterDevice(tenantId, deviceId),
                            registry.removeAllCredentials(tenantId, deviceId))
                    .setHandler(ok -> deletion.complete());
            deletion.await();
        });
    });
    devicesToDelete.clear();

    tenantsToDelete.forEach(tenantId -> {
        final Async deletion = ctx.async();
        registry.removeTenant(tenantId).setHandler(ok -> deletion.complete());
        deletion.await();
    });
    tenantsToDelete.clear();
}