Java Code Examples for org.custommonkey.xmlunit.Difference#getId()

The following examples show how to use org.custommonkey.xmlunit.Difference#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegexDifferenceListener.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public int differenceFound(Difference difference) {

    final Node controlNode = difference.getControlNodeDetail().getNode();
    final Node testNode = difference.getTestNodeDetail().getNode();
    if (difference.getId() == DifferenceConstants.ATTR_VALUE_ID && isXSIType(controlNode) && isXSIType(testNode)) {
        if (getNameSpaceFromPrefix(controlNode).compareTo(getNameSpaceFromPrefix(testNode)) != 0) {
            return RETURN_ACCEPT_DIFFERENCE;
        }
        String withoutPrefixControl = getNameWithoutPrefix(controlNode);
        String withoutPrefixTest = getNameWithoutPrefix(testNode);

        if (withoutPrefixControl.compareTo(withoutPrefixTest) == 0) {
            return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
        }
    }

    if (difference.getControlNodeDetail().getValue() != null //
        && difference.getControlNodeDetail().getValue().startsWith("${") //
        && difference.getControlNodeDetail().getValue().endsWith("}")) {
        return checkSpecialValue(difference);
    }

    return RETURN_ACCEPT_DIFFERENCE;
}
 
Example 2
Source File: RegexDifferenceListener.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public int differenceFound(Difference difference) {
   Node controlNode = difference.getControlNodeDetail().getNode();
   Node testNode = difference.getTestNodeDetail().getNode();
   if (difference.getId() == 3 && this.isXSIType(controlNode) && this.isXSIType(testNode)) {
      if (this.getNameSpaceFromPrefix(controlNode).compareTo(this.getNameSpaceFromPrefix(testNode)) != 0) {
         return 0;
      }

      String withoutPrefixControl = this.getNameWithoutPrefix(controlNode);
      String withoutPrefixTest = this.getNameWithoutPrefix(testNode);
      if (withoutPrefixControl.compareTo(withoutPrefixTest) == 0) {
         return 1;
      }
   }

   return difference.getControlNodeDetail().getValue() != null && difference.getControlNodeDetail().getValue().startsWith("${") && difference.getControlNodeDetail().getValue().endsWith("}") ? this.checkSpecialValue(difference) : 0;
}
 
Example 3
Source File: RegexDifferenceListener.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public int differenceFound(Difference difference) {

    final Node controlNode = difference.getControlNodeDetail().getNode();
    final Node testNode = difference.getTestNodeDetail().getNode();
    if (difference.getId() == DifferenceConstants.ATTR_VALUE_ID && isXSIType(controlNode) && isXSIType(testNode)) {
        if (getNameSpaceFromPrefix(controlNode).compareTo(getNameSpaceFromPrefix(testNode)) != 0) {
            return RETURN_ACCEPT_DIFFERENCE;
        }
        String withoutPrefixControl = getNameWithoutPrefix(controlNode);
        String withoutPrefixTest = getNameWithoutPrefix(testNode);

        if (withoutPrefixControl.compareTo(withoutPrefixTest) == 0) {
            return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
        }
    }

    if (difference.getControlNodeDetail().getValue() != null //
        && difference.getControlNodeDetail().getValue().startsWith("${") //
        && difference.getControlNodeDetail().getValue().endsWith("}")) {
        return checkSpecialValue(difference);
    }

    return RETURN_ACCEPT_DIFFERENCE;
}
 
Example 4
Source File: IgnoreWhiteCharsDiffListener.java    From yangtools with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public int differenceFound(Difference diff) {

    if (diff.getId() == DifferenceConstants.TEXT_VALUE.getId()) {
        String control = diff.getControlNodeDetail().getValue();
        if (control != null) {
            control = control.trim();
            if (diff.getTestNodeDetail().getValue() != null
                && control.equals(diff.getTestNodeDetail().getValue().trim())) {
                return
                    DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
            }
        }
    }
    return RETURN_ACCEPT_DIFFERENCE;
}
 
Example 5
Source File: DomDifferenceListener.java    From apogen with Apache License 2.0 5 votes vote down vote up
public int differenceFound(Difference difference) {

		Set<String> blackList = new HashSet<String>();
		blackList.add("br");
		blackList.add("style");
		blackList.add("script");

		if (difference.getControlNodeDetail() == null || difference.getControlNodeDetail().getNode() == null
				|| difference.getTestNodeDetail() == null || difference.getTestNodeDetail().getNode() == null) {
			return RETURN_ACCEPT_DIFFERENCE;
		}

		// if (ignoreAttributes.contains(difference.getTestNodeDetail().getNode()
		// .getNodeName())
		// || ignoreAttributes.contains(difference.getControlNodeDetail()
		// .getNode().getNodeName())) {
		// return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
		// }

		if (difference.getId() == DifferenceConstants.TEXT_VALUE_ID) {
			if (blackList.contains(difference.getControlNodeDetail().getNode().getParentNode().getNodeName())) {
				return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
			}
		}

		return RETURN_ACCEPT_DIFFERENCE;
	}
 
Example 6
Source File: ExtendedJAXBEqualsStrategy.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected boolean equalsInternal(ObjectLocator leftLocator,
		ObjectLocator rightLocator, Node lhs, Node rhs) {
	final Diff diff = new Diff(new DOMSource(lhs), new DOMSource(rhs)) {
		@Override
		public int differenceFound(Difference difference) {
			if (difference.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) {
				return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
			} else {
				return super.differenceFound(difference);
			}
		}
	};
	return diff.identical();
}
 
Example 7
Source File: TextDifferenceListenerBase.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Delegates to the nested DifferenceListener unless the
 * Difference is of type {@link DifferenceConstants#ATTR_VALUE_ID
 * ATTR_VALUE_ID}, {@link DifferenceConstants#CDATA_VALUE_ID
 * CDATA_VALUE_ID}, {@link DifferenceConstants#COMMENT_VALUE_ID
 * COMMENT_VALUE_ID} or {@link DifferenceConstants#TEXT_VALUE_ID
 * TEXT_VALUE_ID} - for those special differences {@link
 * #attributeDifference attributeDifference}, {@link
 * #cdataDifference cdataDifference}, {@link #commentDifference
 * commentDifference} or {@link #textDifference textDifference}
 * are invoked respectively.
 */
public int differenceFound(Difference difference) {
    switch (difference.getId()) {
    case DifferenceConstants.ATTR_VALUE_ID:
        return attributeDifference(difference);
    case DifferenceConstants.CDATA_VALUE_ID:
        return cdataDifference(difference);
    case DifferenceConstants.COMMENT_VALUE_ID:
        return commentDifference(difference);
    case DifferenceConstants.TEXT_VALUE_ID:
        return textDifference(difference);
    }
    return delegateTo.differenceFound(difference);
}
 
Example 8
Source File: CustomDifferenceListener.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
@Override
public int differenceFound(Difference difference) {
  switch (difference.getId()) {
    case DifferenceConstants.NAMESPACE_URI_ID:
      return namespaceDifferenceFound(difference);
    case DifferenceConstants.ELEMENT_NUM_ATTRIBUTES_ID:
    case DifferenceConstants.ATTR_NAME_NOT_FOUND_ID:
      return attributeDifferenceFound(difference);
    default:
      return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
  }
}