Esempio n. 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;
           }
         }
       }
     }
   }
 }
Esempio n. 2
0
 /**
  * Returns a Map representation of a Single data set for a given method. This data is used to run
  * the test method once.
  *
  * @param testEntry a list of {@link Entry} objects
  * @return a Map
  */
 Map<String, Object> convertFromListOfEntry(List<Entry> testEntry) {
   Map<String, Object> testData = new HashMap<String, Object>();
   if (testEntry != null) {
     for (Entry entry : testEntry) {
       testData.put(entry.getKey(), entry.getValue());
     }
   }
   return testData;
 }