UpdateEtcHostsStep { public Environment execute() throws PeerException { Set<Peer> peers = environment.getPeers(); for ( final Peer peer : peers ) { peerUtil.addPeerTask( new PeerUtil.PeerTask<>( peer, new Callable<Object>() { @Override public Object call() throws Exception { peer.updateEtcHostsWithNewContainerHostname( environment.getEnvironmentId(), oldHostname, newHostname ); return null; } } ) ); } PeerUtil.PeerTaskResults<Object> peerResults = peerUtil.executeParallel(); for ( PeerUtil.PeerTaskResult peerResult : peerResults.getResults() ) { if ( peerResult.hasSucceeded() ) { trackerOperation.addLog( String.format( "Updated hosts on peer %s", peerResult.getPeer().getName() ) ); } else { trackerOperation.addLog( String.format( "Failed to update hosts on peer %s. Reason: %s", peerResult.getPeer().getName(), peerResult.getFailureReason() ) ); } } return environment; } UpdateEtcHostsStep( final LocalEnvironment environment, final String oldHostname, final String newHostname,
                               TrackerOperation trackerOperation ); Environment execute();  }
@Test public void testExecute() throws Exception { doReturn( true ).doReturn( false ).when( peerTaskResult ).hasSucceeded(); step.execute(); step.execute(); verify( peerUtil, times( 2 ) ).executeParallel(); }