public void processCommands(@Observes org.arquillian.cube.spi.event.lifecycle.BeforeStop beforeStop, CubeRegistry cubeRegistry, DockerClientExecutor dockerClientExecutor) throws IOException { Cube<CubeContainer> cube = cubeRegistry.getCube(beforeStop.getCubeId(), DockerCube.class); CubeContainer configuration = cube.configuration(); if (configuration.getBeforeStop() != null) { Collection<BeforeStop> beforeStopConfiguration = configuration.getBeforeStop(); for (BeforeStop map : beforeStopConfiguration) { if (map.getCopy() != null) { Copy copyConfiguration = map.getCopy(); executeCopyAction(dockerClientExecutor, beforeStop.getCubeId(), copyConfiguration); } else { if (map.getLog() != null) { Log logConfiguration = map.getLog(); executeLogAction(dockerClientExecutor, beforeStop.getCubeId(), logConfiguration); } } if (map.getCustomBeforeStopAction() != null) { CustomBeforeStopAction customBeforeStopAction = map.getCustomBeforeStopAction(); executeCustomBeforeStopAction(dockerClientExecutor, beforeStop.getCubeId(), customBeforeStopAction); } } } }
@Test public void should_be_able_to_create_custom_before_stop_actions() { BeforeStop beforeStop = new BeforeStop(); CustomBeforeStopAction customBeforeStopAction = new CustomBeforeStopAction(); customBeforeStopAction.setStrategy("org.arquillian.cube.docker.impl.beforeStop.CustomBeforeStopActionImpl"); beforeStop.setCustomBeforeStopAction(customBeforeStopAction); BeforeStopAction beforeStopAction = BeforeStopActionFactory.create(dockerClientExecutor, new DefaultCubeId(containerId), customBeforeStopAction); assertThat(beforeStopAction, instanceOf(CustomBeforeStopActionInstantiator.class)); CustomBeforeStopActionInstantiator customBeforeStopActionInstantiator = (CustomBeforeStopActionInstantiator) beforeStopAction; customBeforeStopActionInstantiator.doBeforeStop(); verify(dockerClientExecutor, times(1)).getDockerUri(); } }
public void processCommands(@Observes org.arquillian.cube.spi.event.lifecycle.BeforeStop beforeStop, CubeRegistry cubeRegistry, DockerClientExecutor dockerClientExecutor) throws IOException { Cube<CubeContainer> cube = cubeRegistry.getCube(beforeStop.getCubeId(), DockerCube.class); CubeContainer configuration = cube.configuration(); if (configuration.getBeforeStop() != null) { Collection<BeforeStop> beforeStopConfiguration = configuration.getBeforeStop(); for (BeforeStop map : beforeStopConfiguration) { if (map.getCopy() != null) { Copy copyConfiguration = map.getCopy(); executeCopyAction(dockerClientExecutor, beforeStop.getCubeId(), copyConfiguration); } else { if (map.getLog() != null) { Log logConfiguration = map.getLog(); executeLogAction(dockerClientExecutor, beforeStop.getCubeId(), logConfiguration); } } if (map.getCustomBeforeStopAction() != null) { CustomBeforeStopAction customBeforeStopAction = map.getCustomBeforeStopAction(); executeCustomBeforeStopAction(dockerClientExecutor, beforeStop.getCubeId(), customBeforeStopAction); } } } }