Beispiel #1
0
  private Document processAsString(AggregatedStepExpectedOutputMetaData expectedObjectMetaData)
      throws AssertionError {
    Document document = null;
    String xmlString = "";
    AggregatedStepExpectedOutputMetaData metaData = expectedObjectMetaData;

    for (StepMetaData stepMetaData : metaData.getValues()) {
      for (NameValuePair nameValuePair : stepMetaData.getNameValuePairs()) {
        Object value = nameValuePair.getValue();
        Object key = nameValuePair.getName();
        if ((key != null) && (value != null)) {
          xmlString = xmlString + String.valueOf(value).trim();
        }
      }
    }

    // Validate XML String and then create document from XML string
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      document = builder.parse(new InputSource(new StringReader(xmlString)));
      return document;
    } catch (Exception e) {
      throw new AssertionError(e);
    }
  }
Beispiel #2
0
  @Override
  public Document preProcess(
      Object actualObject, AggregatedStepExpectedOutputMetaData expectedObjectMetaData)
      throws AssertionError {

    Class<?> expectedClass =
        expectedObjectMetaData.getMetaDataAtIndex(0).getValueAtIndex(0).getClass();

    if (ObjectUtil.isDocument(expectedClass)) {

      return (Document) expectedObjectMetaData.getMetaDataAtIndex(0).getValueAtIndex(0);

    } else {

      return processAsString(expectedObjectMetaData);
    }
  }