PrepareTemplatesStep { public void execute() throws EnvironmentCreationException, PeerException { Map<String, Set<Node>> placement = topology.getNodeGroupPlacement(); for ( Map.Entry<String, Set<Node>> peerPlacement : placement.entrySet() ) { Peer peer = peerManager.getPeer( peerPlacement.getKey() ); templateUtil.addPeerTask( new PeerUtil.PeerTask<>( peer, new PeerImportTemplateTask( environment.getId(), peer, peerPlacement.getValue(), cdnToken, operationTracker ) ) ); } PeerUtil.PeerTaskResults<PrepareTemplatesResponse> templateResults = templateUtil.executeParallelFailFast(); boolean succeeded = true; for ( PeerUtil.PeerTaskResult<PrepareTemplatesResponse> templateResult : templateResults.getResults() ) { succeeded &= templateResult.getResult().hasSucceeded(); } if ( !succeeded ) { throw new EnvironmentCreationException( "Failed to import templates on all peers" ); } } PrepareTemplatesStep( final Environment environment, final PeerManager peerManager, final Topology topology,
                                 final String cdnToken, final TrackerOperation operationTracker ); void execute();  }
@Test( expected = EnvironmentCreationException.class ) public void testExecute() throws Exception { doReturn( true ).when( response ).hasSucceeded(); step.execute(); verify( peerUtil ).executeParallelFailFast(); doReturn( false ).when( response ).hasSucceeded(); step.execute(); }