EnvironmentDestructionWorkflow extends CancellableWorkflow<EnvironmentDestructionWorkflow.EnvironmentDestructionPhase> { public void FINALIZE() { RelationManager relationManager = environmentManager.getRelationManager(); for ( final EnvironmentContainerHost containerHost : environment.getContainerHosts() ) { relationManager.removeRelation( containerHost ); } environmentManager.remove( environment ); relationManager.removeRelation( environment ); operationTracker.addLogDone( "Environment is destroyed" ); stop(); } EnvironmentDestructionWorkflow( final EnvironmentManagerImpl environmentManager,
                                           final LocalEnvironment environment, final TrackerOperation operationTracker ); EnvironmentDestructionPhase INIT(); EnvironmentDestructionPhase CLEANUP_ENVIRONMENT(); void FINALIZE(); @Override void fail( final String message, final Throwable e ); @Override void onCancellation();  }
@Test public void testFINALIZE() throws Exception { RelationManager relationManager = mock( RelationManager.class ); doReturn( relationManager ).when( environmentManager ).getRelationManager(); doReturn( Sets.newHashSet( TestHelper.ENV_CONTAINER() ) ).when( environment ).getContainerHosts(); workflow.FINALIZE(); verify( environmentManager, atLeastOnce() ).remove( environment ); }