ChangeQuotaStep { public void execute() throws PeerException { if ( !CollectionUtil.isMapEmpty( changedContainers ) ) { for ( final Map.Entry<String, ContainerQuota> entry : changedContainers.entrySet() ) { final EnvironmentContainerHost containerHost = environment.getContainerHostById( entry.getKey() ); final ContainerQuota containerQuota = entry.getValue(); quotaUtil.addTask( new TaskUtil.Task<Object>() { @Override public Object call() throws Exception { containerHost.setQuota( containerQuota ); return null; } } ); TaskUtil.TaskResults<Object> quotaResults = quotaUtil.executeParallel(); for ( TaskUtil.TaskResult quotaResult : quotaResults.getResults() ) { if ( quotaResult.hasSucceeded() ) { trackerOperation.addLog( String.format( "Container %s's size has been modified", containerHost.getHostname() ) ); } else { trackerOperation.addLog( String.format( "Failed to modify size of container %s. Reason: %s", containerHost.getHostname(), quotaResult.getFailureReason() ) ); } } if ( quotaResults.hasFailures() ) { throw new PeerException( "Failed to change size of each container" ); } } } } ChangeQuotaStep( final LocalEnvironment environment, final Map<String, ContainerQuota> changedContainers,
                            final TrackerOperation trackerOperation ); void execute();  }
@Test( expected = PeerException.class ) public void testExecute() throws Exception { doReturn( true ).when( taskResult ).hasSucceeded(); step.execute(); verify( trackerOperation ).addLog( anyString() ); doReturn( true ).when( taskResults ).hasFailures(); doReturn( false ).when( taskResult ).hasSucceeded(); step.execute(); }