ContainerDestructionWorkflow extends CancellableWorkflow<ContainerDestructionWorkflow.ContainerDestructionPhase> { public ContainerDestructionPhase VALIDATE() { operationTracker.addLog( "Validating environment state" ); try { if ( environment.getContainerHosts().size() <= 1 ) { isLastContainer = true; throw new IllegalStateException( "Environment will have 0 containers after modification. Please, destroy environment instead" ); } else { return ContainerDestructionPhase.DESTROY_CONTAINER; } } catch ( Exception e ) { fail( e.getMessage(), e ); return null; } } ContainerDestructionWorkflow( final EnvironmentManagerImpl environmentManager,
                                         final LocalEnvironment environment, final ContainerHost containerHost,
                                         final TrackerOperation operationTracker ); ContainerDestructionPhase INIT(); ContainerDestructionPhase VALIDATE(); ContainerDestructionPhase DESTROY_CONTAINER(); ContainerDestructionPhase REMOVE_HOSTNAMES(); void FINALIZE(); @Override void fail( final String message, final Throwable e ); @Override void onCancellation();  }
@Test public void testVALIDATE() throws Exception { assertNull( workflow.VALIDATE() ); doReturn( Sets.newHashSet( container, TestHelper.ENV_CONTAINER() ) ).when( environment ).getContainerHosts(); assertEquals( ContainerDestructionWorkflow.ContainerDestructionPhase.DESTROY_CONTAINER, workflow.VALIDATE() ); }