P2PSecretKeyResetStep { public void execute() throws PeerException { Set<Peer> peers = environment.getPeers(); for ( final Peer peer : peers ) { resetUtil.addPeerTask( new PeerUtil.PeerTask<>( peer, new ResetP2pKeyTask( peer, p2PCredentials, trackerOperation ) ) ); } PeerUtil.PeerTaskResults<Object> resetResults = resetUtil.executeParallel(); for ( PeerUtil.PeerTaskResult resetResult : resetResults.getResults() ) { if ( resetResult.hasSucceeded() ) { trackerOperation.addLog( String.format( "P2P secret key reset succeeded on peer %s", resetResult.getPeer().getName() ) ); } else { trackerOperation.addLog( String.format( "P2P secret key reset failed on peer %s. Reason: %s", resetResult.getPeer().getName(), resetResult.getFailureReason() ) ); } } if ( resetResults.hasFailures() ) { throw new PeerException( "Failed to reset p2p key across all peers" ); } } P2PSecretKeyResetStep( final LocalEnvironment environment, final P2PCredentials p2PCredentials,
                                  final TrackerOperation trackerOperation ); void execute();  }
@Test( expected = PeerException.class ) public void testExecute() throws Exception { doReturn( true ).when( peerTaskResult ).hasSucceeded(); step.execute(); verify( peerUtil ).executeParallel(); doReturn( false ).when( peerTaskResult ).hasSucceeded(); doReturn( true ).when( peerTaskResults ).hasFailures(); step.execute(); }