package org.arquillian.cube.openshift.impl.client;

import org.arquillian.cube.spi.event.CreateCube;
import org.arquillian.cube.spi.event.CubeControlEvent;
import org.arquillian.cube.spi.event.DestroyCube;
import org.arquillian.cube.spi.event.StartCube;
import org.arquillian.cube.spi.event.StopCube;
import org.jboss.arquillian.core.api.Event;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
import org.jboss.arquillian.test.spi.event.suite.AfterSuite;
import org.jboss.arquillian.test.spi.event.suite.BeforeSuite;

public class OpenShiftSuiteLifecycleController {

    @Inject
    private Event<CubeControlEvent> controlEvent;

    public void startAutoContainers(@Observes(precedence = 99) BeforeSuite event,
        CubeOpenShiftConfiguration openshiftConfiguration) {
        for (String cubeId : openshiftConfiguration.getAutoStartContainers()) {
            controlEvent.fire(new CreateCube(cubeId));
            controlEvent.fire(new StartCube(cubeId));
        }
    }

    public void stopAutoContainers(@Observes(precedence = -99) AfterSuite event,
        CubeOpenShiftConfiguration openshiftConfiguration) {
        String[] autostart = openshiftConfiguration.getAutoStartContainers();
        for (int i = autostart.length - 1; i > -1; i--) {
            String cubeId = autostart[i];
            controlEvent.fire(new StopCube(cubeId));
            controlEvent.fire(new DestroyCube(cubeId));
        }
    }
}

@@ -45,16 +45,73 @@
 lient;%0A%0A
+import org.arquillian.cube.kubernetes.api.Configuration;%0A
 import o
@@ -147,24 +147,24 @@
 CreateCube;%0A
-
 import org.a
@@ -820,32 +820,153 @@
 oreSuite event,%0A
+        Configuration conf) %7B%0A        if (!(conf instanceof CubeOpenShiftConfiguration)) %7B%0A            return;%0A        %7D%0A
         CubeOpen
@@ -998,35 +998,70 @@
 iftConfiguration
-) %7B
+ = (CubeOpenShiftConfiguration) conf;%0A
 %0A        for (St
@@ -1324,32 +1324,153 @@
 terSuite event,%0A
+        Configuration conf) %7B%0A        if (!(conf instanceof CubeOpenShiftConfiguration)) %7B%0A            return;%0A        %7D%0A
         CubeOpen
@@ -1510,19 +1510,54 @@
 guration
-) %7B
+ = (CubeOpenShiftConfiguration) conf;%0A
 %0A       

Fix @Observer parameter (#774)