EnvironmentModifyWorkflow extends CancellableWorkflow<EnvironmentModifyWorkflow.EnvironmentModificationPhase> { public EnvironmentModificationPhase DESTROY_CONTAINERS() { operationTracker.addLog( "Destroying containers" ); try { if ( environment.getContainerHosts().size() <= removedContainers.size() ) { String errMsg = "Environment will have 0 containers after modification. Please, destroy environment instead. " + "Container destruction has been skipped"; if ( !( hasContainerCreation || hasQuotaModification ) ) { operationTracker.addLogFailed( errMsg ); } else { operationTracker.addLog( errMsg ); } return EnvironmentModificationPhase.FINALIZE; } else { for ( String removeContainerHostId : removedContainers ) { removedContainerHosts.add( environment.getContainerHostById( removeContainerHostId ) ); } environment = ( LocalEnvironment ) new DestroyContainersStep( environment, environmentManager, removedContainers, operationTracker ).execute(); saveEnvironment(); return EnvironmentModificationPhase.REMOVE_HOSTNAMES; } } catch ( Exception e ) { fail( e.getMessage(), e ); return null; } } EnvironmentModifyWorkflow( String defaultDomain, IdentityManager identityManager, PeerManager peerManager,
                                      SecurityManager securityManager, LocalEnvironment environment, Topology topology,
                                      Set<String> removedContainers, Map<String, ContainerQuota> changedContainers,
                                      TrackerOperation operationTracker, EnvironmentManagerImpl environmentManager ); EnvironmentModificationPhase INIT(); EnvironmentModificationPhase GENERATE_KEYS(); EnvironmentModificationPhase RESERVE_NET(); EnvironmentModificationPhase SETUP_P2P(); EnvironmentModificationPhase PREPARE_TEMPLATES(); EnvironmentModificationPhase CLONE_CONTAINERS(); EnvironmentModificationPhase CONFIGURE_HOSTS(); EnvironmentModificationPhase CONFIGURE_SSH(); EnvironmentModificationPhase SET_QUOTA(); EnvironmentModificationPhase MODIFY_QUOTA(); EnvironmentModificationPhase DESTROY_CONTAINERS(); EnvironmentModificationPhase REMOVE_HOSTNAMES(); void FINALIZE(); @Override void fail( final String message, final Throwable e ); @Override void onCancellation();  }
@Test public void testDESTROY_CONTAINERS() throws Exception { workflow.DESTROY_CONTAINERS(); verify( trackerOperation, atLeastOnce() ).addLog( anyString() ); }