ChangeHostnameStep { public Environment execute() throws EnvironmentModificationException, EnvironmentNotFoundException { renameUtil.addTask( new RenameContainerTask( environment, containerId, newHostname ) ); TaskUtil.TaskResults<Object> renameResults = renameUtil.executeParallel(); TaskUtil.TaskResult<Object> renameResult = renameResults.getResults().iterator().next(); EnvironmentContainerImpl container = ( EnvironmentContainerImpl ) renameResult.getResult(); RenameContainerTask task = ( RenameContainerTask ) renameResult.getTask(); if ( renameResult.hasSucceeded() ) { oldHostname = task.getOldHostname(); newHostname = task.getNewHostname(); } else { throw new EnvironmentModificationException( String.format( "Failed to change hostname of container %s. Reason: %s", container.getId(), renameResult.getFailureReason() ) ); } return environmentManager.loadEnvironment( environment.getId() ); } ChangeHostnameStep( final EnvironmentManagerImpl environmentManager, final LocalEnvironment environment,
                               final ContainerId containerId, final String newHostname ); Environment execute(); String getOldHostname(); String getNewHostname();  }
@Test( expected = EnvironmentModificationException.class ) public void testExecute() throws Exception { doReturn( true ).when( taskResult ).hasSucceeded(); step.execute(); verify( environmentManager ).loadEnvironment( TestHelper.ENV_ID ); assertEquals( NEW_HOSTNAME, step.getNewHostname() ); assertNotSame( NEW_HOSTNAME, step.getOldHostname() ); doReturn( false ).when( taskResult ).hasSucceeded(); step.execute(); }