package com.codingchili.core;

import io.vertx.core.Vertx;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.*;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

import com.codingchili.core.context.Delay;
import com.codingchili.core.context.LaunchContext;
import com.codingchili.core.testing.ContextMock;

/**
 * @author Robin Duda
 *         <p>
 *         Tests for the launcher.
 */
@RunWith(VertxUnitRunner.class)
public class LauncherIT {
    public static Async async;
    private ContextMock context;

    @Before
    public void setUp() {
        context = new ContextMock(Vertx.vertx());
        Delay.initialize(context);
    }

    @After
    public void tearDown(TestContext test) {
        context.vertx().close(test.asyncAssertSuccess());
    }

    @Test
    public void testFailNotVerticle(TestContext test) {
        async = test.async();

        new Launcher(getLaunchContextFor("com.codingchili.core.LauncherTest$1")) {
            @Override
            void exit() {
                async.complete();
            }
        };
    }

    @Test
    public void testDeployAService(TestContext test) {
        async = test.async();
        new Launcher(getLaunchContextFor("com.codingchili.core.IsClusterNode"));
    }

    public LaunchContext getLaunchContextFor(String node) {
        return new LaunchContext(new String[]{node}) {
            @Override
            protected List<String> block(String block) {
                List<String> list = new ArrayList<>();
                list.add(node);
                return list;
            }
        };
    }

    /**
     * Test class that is not a cluster node and will fail to deploy.
     */
    private static class NotClusterNode {
    }
}

package com.codingchili.core;

import io.vertx.core.Vertx;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.*;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.List;

import com.codingchili.core.context.Delay;
import com.codingchili.core.context.LaunchContext;
import com.codingchili.core.testing.ContextMock;

/**
 * @author Robin Duda
 *         <p>
 *         Tests for the launcher.
 */
@RunWith(VertxUnitRunner.class)
public class LauncherIT {
    public static Async async;
    private ContextMock context;

    @Before
    public void setUp() {
        context = new ContextMock(Vertx.vertx());
        Delay.initialize(context);
    }

    @After
    public void tearDown(TestContext test) {
        context.vertx().close(test.asyncAssertSuccess());
    }

    @Test
    public void testFailNotVerticle(TestContext test) {
        async = test.async();

        new Launcher(getLaunchContextFor(NotClusterNode.class.getName())) {
            @Override
            void exit() {
                async.complete();
            }
        };
    }

    @Test
    public void testFailNotFound(TestContext test) {
        async = test.async();

        new Launcher(getLaunchContextFor("com.codingchili.core.Missing$1")) {
            @Override
            void exit() {
                async.complete();
            }
        };
    }

    @Test
    public void testDeployAService(TestContext test) {
        async = test.async();
        new Launcher(getLaunchContextFor("com.codingchili.core.IsClusterNode"));
    }

    public LaunchContext getLaunchContextFor(String node) {
        return new LaunchContext(new String[]{}) {
            @Override
            protected List<String> block(String block) {
                List<String> list = new ArrayList<>();
                list.add(node);
                return list;
            }
        };
    }

    /**
     * Test class that is not a cluster node and will fail to deploy.
     */
    private static class NotClusterNode {
    }
}

Improve Launcher integration tests.