Example #1
0
 /**
  * This method is responsible for adding the {@link OutputData} element to the existing file. This
  * method determines the right position of the test record based on the id attribute {@link
  * TestRecord#getId()} of the {@link TestRecord}.
  *
  * @param inputTestData an Object representation of the XML data
  * @param actualData the data structure that contains the output data that needs to be written to
  *     the file. The output data is identified by the key {@link Loader#ACTUAL_RESULT}
  */
 private void updateTestMethods(
     InputTestData inputTestData, Map<String, List<Map<String, Object>>> actualData) {
   for (String methodName : actualData.keySet()) {
     List<Map<String, Object>> testRecords = actualData.get(methodName);
     for (Map<String, Object> testRecord : testRecords) {
       Boolean outputDataAdded = false;
       if (testRecord.containsKey(ACTUAL_RESULT)) {
         // The data needs to be written to the XML file.
         // Find the right place to put the data.
         for (TestMethod testMethod : inputTestData.getTestMethod()) {
           List<TestRecord> originalTestRecords = testMethod.getTestRecord();
           for (TestRecord originalTestRecord : originalTestRecords) {
             if (originalTestRecord.getId().equals(testRecord.get(RECORD_POSITION))) {
               OutputData outputData = new OutputData();
               Entry outputEntry = new Entry();
               outputEntry.setKey(ACTUAL_RESULT);
               outputEntry.setValue(testRecord.get(ACTUAL_RESULT).toString());
               outputData.getEntry().add(outputEntry);
               originalTestRecord.setOutputData(outputData);
               outputDataAdded = true;
               break;
             }
           }
           if (outputDataAdded) {
             break;
           }
         }
       }
     }
   }
 }
Example #2
0
 /**
  * Convert the data from List of {@link TestRecord} to a List of map representation. The LIst of
  * map represents the list of test data for a single test method.
  *
  * @param dataRecords an instance of List of {@link TestRecord}
  * @return an instance of {@link List} of Map
  */
 private List<Map<String, Object>> convertFromLIstOfTestRecords(List<TestRecord> dataRecords) {
   List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
   if (dataRecords != null) {
     for (TestRecord record : dataRecords) {
       Map<String, Object> singleTestData =
           convertFromListOfEntry(record.getInputData().getEntry());
       result.add(singleTestData);
     }
   }
   return result;
 }