public List<SaveResult> checkResults(BulkConnection bulkConnection,JobInfo job,List<BatchInfo> batchInfoList) throws AsyncApiException, IOException {
  LOG.debug("Checking Results.... ");
  List<SaveResult> saveResults=new ArrayList<SaveResult>();
  for (  BatchInfo batchInfo : batchInfoList) {
    CSVReader csvReaderForBatchResultStream=new CSVReader(bulkConnection.getBatchResultStream(job.getId(),batchInfo.getId()));
    List<String> resultHeader=csvReaderForBatchResultStream.nextRecord();
    int resultCols=resultHeader.size();
    List<String> batchResultStream=null;
    while ((batchResultStream=csvReaderForBatchResultStream.nextRecord()) != null) {
      Map<String,String> resultInfo=new HashMap<String,String>();
      for (int i=0; i < resultCols; i++) {
        resultInfo.put(resultHeader.get(i),batchResultStream.get(i));
      }
      SaveResult sr=new SaveResult();
      sr.setId(resultInfo.get("Id"));
      boolean success=Boolean.valueOf(resultInfo.get("Success"));
      sr.setSuccess(success);
      if (!success) {
        if (resultInfo.get("Error") != null && StringUtils.isNotEmpty(resultInfo.get("Error"))) {
          ApexUnitUtils.shutDownWithErrMsg("Error while fetching results for the batch job" + resultInfo.get("Error"));
        }
      }
      saveResults.add(sr);
    }
  }
  return saveResults;
}

public List < SaveResult > checkResults ( BulkConnection bulkConnection , JobInfo job , List < BatchInfo > batchInfoList ) throws AsyncApiException , IOException { LOG . debug ( "Checking Results.... " ) ; List < SaveResult > saveResults = new ArrayList < SaveResult > ( ) ; for ( BatchInfo batchInfo : batchInfoList ) { CSVReader csvReaderForBatchResultStream = new CSVReader ( bulkConnection . getBatchResultStream ( job . getId ( ) , batchInfo . getId ( ) ) ) ; List < String > resultHeader = csvReaderForBatchResultStream . nextRecord ( ) ; int resultCols = resultHeader . size ( ) ; List < String > batchResultStream = null ; while ( ( batchResultStream = csvReaderForBatchResultStream . nextRecord ( ) ) != null ) { Map < String , String > resultInfo = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < resultCols ; i ++ ) { resultInfo . put ( resultHeader . get ( i ) , batchResultStream . get ( i ) ) ; } SaveResult sr = new SaveResult ( ) ; sr . setId ( resultInfo . get ( "Id" ) ) ; boolean success = Boolean . valueOf ( resultInfo . get ( "Success" ) ) ; sr . setSuccess ( success ) ; if ( ! success ) { if ( resultInfo . get ( "Error" ) != null && StringUtils . isNotEmpty ( resultInfo . get ( "Error" ) ) ) { ApexUnitUtils . shutDownWithErrMsg ( "Error while fetching results for the batch job" + resultInfo . get ( "Error" ) ) ; } } saveResults . add ( sr ) ; } } return saveResults ; }
gets the results of the operation and checks for errors .
