/** * Main entry point for the Loader * * @param resource The resource to load the data from * @return a Map representing the loaded data */ public Map<String, List<Map<String, Object>>> loadData(Resource resource) { LOG.debug("Trying to load the data for resource :" + resource.getResourceName()); Map<String, List<Map<String, Object>>> result = null; try { result = loadFromSpreadsheet(resource.getInputStream()); } catch (IOException e) { LOG.error( "IOException occured while trying to Load the resource {} . Moving to the next resource.", resource.getResourceName(), e); } if (result != null) { LOG.debug( "Loading data from resource {} succedded and the data loaded is {}", resource.getResourceName(), result); } return result; }
/** * Write the data back to the file that is represented by the Resource instance * * @param resource the resource instance to which teh data needs to be written * @param actualData the actual data that needs to be written * @param methodNames OPTIONAL names of methods for which the data needs to be written. If the * method names are not provided, then the data is written for all the test methods ofr which * teh data is present in the actualData parameter */ public void writeData( Resource resource, Map<String, List<Map<String, Object>>> actualData, String... methodNames) { try { if (methodNames == null || methodNames.length == 0) { writeFullDataToSpreadsheet(resource.getOutputStream(), actualData); } else { for (String methodName : methodNames) { writeDataToSpreadsheet(resource, methodName, actualData); } } } catch (IOException e) { LOG.warn( "Unable to write data to file {} . An I/O Exception occured.", resource.getResourceName(), e); } }