当前位置: 首页>>代码示例>>Java>>正文


Java Difference.getId方法代码示例

本文整理汇总了Java中org.custommonkey.xmlunit.Difference.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Difference.getId方法的具体用法?Java Difference.getId怎么用?Java Difference.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.custommonkey.xmlunit.Difference的用法示例。


在下文中一共展示了Difference.getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: identicalExceptAdditionalFieldsInActual

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * 
 * @return true si les deux résultats XML sont identiques en ignorant les champs supplémentaires dans le résultat du process ("actual result")
 * qui ne sont pas présents dans le résultat attendu ("expected result").
 */
public boolean identicalExceptAdditionalFieldsInActual() {
	boolean notIdentical = false;
	
	for (Difference difference : this.getAllDifferences()) {
		if (difference.getId() == DifferenceConstants.CHILD_NODELIST_LENGTH_ID) {
			// possibilité d'accepter des champs en plus dans le "actual"
			int expectedCount = Integer.parseInt(difference.getControlNodeDetail().getValue());
			int actualCount = Integer.parseInt(difference.getTestNodeDetail().getValue());
			
			if (expectedCount > actualCount) { // on accepte les différences s'il y a plus dans le actual que dans l'expected mais pas l'inverse
				notIdentical = true;
			}
		}
	}
	
	return (this.identical() && !notIdentical);
}
 
开发者ID:fastconnect,项目名称:tibco-fcunit,代码行数:23,代码来源:FCDiff.java

示例2: getAdditionalFieldsInActual

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * 
 * @return La liste des champs supplémentaires présents dans le résultat d'un process ("actual result")
 * et non présent dans le résultat attendu ("expected result") sous forme de différences ({@link org.custommonkey.xmlunit.Difference}).
 */
public List<Difference> getAdditionalFieldsInActual() {
	List<Difference> differences = new ArrayList<Difference>(this.getAllDifferences()); // deep-copy of the differences
	
    for (Iterator<Difference> it = differences.iterator(); it.hasNext(); ) {
    	Difference difference = it.next();
        if (difference.getId() == DifferenceConstants.CHILD_NODELIST_LENGTH_ID) {
			int expectedCount = Integer.parseInt(difference.getControlNodeDetail().getValue());
			int actualCount = Integer.parseInt(difference.getTestNodeDetail().getValue());
			
			if (expectedCount > actualCount) { // on accepte les différences s'il y a plus dans le actual que dans l'expected mais pas l'inverse
	            it.remove();
			}
        }
        else {
            it.remove();
        }
    }
    
	return differences;
}
 
开发者ID:fastconnect,项目名称:tibco-fcunit,代码行数:26,代码来源:FCDiff.java

示例3: differentValueAttributeOnInput

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Checks this heuristic: if the attribute that has been modified is the "value" attribute of an
 * "input" element, it is much likely to be a false difference
 */
static boolean differentValueAttributeOnInput(Difference difference) {
  String controlNodeXpath = difference.getTestNodeDetail().getXpathLocation();

  if ((controlNodeXpath != null) && controlNodeXpath.endsWith("@value")
      && (difference.getId() == 3)) {
    String nodeName = "input";
    String[] elements = controlNodeXpath.split("/");
    String secondLastElement = elements[elements.length - 2];

    if ((secondLastElement != null) && secondLastElement.startsWith(nodeName)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:google,项目名称:zarathustra,代码行数:20,代码来源:Heuristics.java

示例4: differenceFound

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
@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;
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:17,代码来源:IgnoreWhiteCharsDiffListener.java

示例5: isCausedByIgnoredAttribute

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Ignores all differences caused by an ignored attribute (see {@link DiffConfiguration#getIgnoredAttributes()}
 * @param difference
 * @return
 */
protected boolean isCausedByIgnoredAttribute(Difference difference) {
	if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID){
		//ignore attributes belonging to a certain namespace
		String attrName = difference.getControlNodeDetail().getValue();
		Node node;
		if (attrName == null || attrName.equals(ATTR_NULL)){
			attrName = difference.getTestNodeDetail().getValue();
			node = helper.getDocumentNode(difference, XmlDiffDocumentType.TEST, false);
		}else{
			node = helper.getDocumentNode(difference, XmlDiffDocumentType.CONTROL, false);
		}
		String namespace = helper.getNamespaceOfAttribute(attrName, node.getAttributes());
		if (namespace != null && ignoredNamespacesInAttributes.contains(namespace)){
			//add attribute name to ignored attributes so that a difference in attribute numbers can be caught later on
               getAttributeSetForNode(node, ignoredAttributesMap)
                       .add(attrName);
			return true;
		}
			
	}
	return isCausedByAttribute(difference, false);
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:28,代码来源:AbstractXmlDifferenceListener.java

示例6: isCausedByAddingDefaultAttribute

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Ignores all differences when the test model has added optional attributes
 * missing from the reference.
 * 
 * @param difference
 * @return
 */
protected boolean isCausedByAddingDefaultAttribute(Difference difference) {
    if (difference.getId() == DifferenceConstants.ATTR_NAME_NOT_FOUND_ID) {
        // ignore attributes belonging to a certain namespace
        String attrName = difference.getControlNodeDetail().getValue();
        String testAttrName = difference.getTestNodeDetail().getValue();
        Node node;
        if (attrName == null || attrName.equals(ATTR_NULL)) {
            node = helper.getDocumentNode(difference,
                    XmlDiffDocumentType.TEST, false);
        } else {
            node = helper.getDocumentNode(difference,
                    XmlDiffDocumentType.CONTROL, false);
        }
        Set<String> defaultedAttributesForNode = getAttributeSetForNode(
                node, defaultAttributesMap);
        for (String string : defaultedAttributesForNode) {
            if (testAttrName.equals(string)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:31,代码来源:AbstractXmlDifferenceListener.java

示例7: differenceFound

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
@Override
public int differenceFound(Difference aDifference) {
    if (aDifference.getId() == DifferenceConstants.TEXT_VALUE_ID) {
        if (blackList.contains(aDifference.getControlNodeDetail().getNode()
                .getNodeName())) {
            return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
        }
    }

    return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
}
 
开发者ID:jwiesel,项目名称:sfdcCommander,代码行数:12,代码来源:IgnoreNamedElementsDifferenceListener.java

示例8: differenceFound

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public int differenceFound(Difference diff) {
    if (diff.getId() == DifferenceConstants.SCHEMA_LOCATION_ID) {
        String control = reduceWhitespace(diff.getControlNodeDetail());
        String test = reduceWhitespace(diff.getTestNodeDetail());
        if ((control == null && test == null) || (control != null && control.equals(test))) {
            return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
        }
    }
    return RETURN_ACCEPT_DIFFERENCE;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:15,代码来源:SchemaLocationDifferenceListener.java

示例9: differentTextNotInScript

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Checks this heuristic: if a modified text is not in a script, consider it a false difference.
 * This difference was introduced after finding an injection on the content of an existing script.
 * Most of "modified text" differences are harmless and occur on span elements
 */
static boolean differentTextNotInScript(Difference difference) {
  if (difference.getId() == 14) {
    NodeDetail controlNode = difference.getControlNodeDetail();
    NodeDetail testNode = difference.getTestNodeDetail();
    String parentName = "script";

    return checkNodeNotInParent(controlNode, parentName)
        || checkNodeNotInParent(testNode, parentName);
  }

  return false;
}
 
开发者ID:google,项目名称:zarathustra,代码行数:18,代码来源:Heuristics.java

示例10: editedElementOnDifferentXpath

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Checks this heuristic: if an added/deleted/edited attribute or an edited text have different
 * xpaths on the control and test nodes, consider them as a false difference. This is needed to
 * deal with the recurring behavior of the comparer according to which elements are erroneously
 * seen as moved and hence compared with completely different nodes on different xpaths.
 */
static boolean editedElementOnDifferentXpath(Difference difference) {
  String firstXPath = Strings.nullToEmpty(difference.getControlNodeDetail().getXpathLocation());
  String secondXPath = Strings.nullToEmpty(difference.getTestNodeDetail().getXpathLocation());
  if (((difference.getId() == 2) || (difference.getId() == 3) || (difference.getId() == 14))
      && !firstXPath.equalsIgnoreCase(secondXPath)) {
    return true;
  } else {
    return false;
  }
}
 
开发者ID:google,项目名称:zarathustra,代码行数:17,代码来源:Heuristics.java

示例11: differencesDiff

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Only returns the differences in {@code differences} that are not present in {@code whitelist}.
 * Uses the XPath of the Difference to determine equality.
 */
private static List<Difference> differencesDiff(List<Difference> whitelist,
    List<Difference> differences) {
  List<Difference> uniqueDifferences = Lists.newArrayList();
  for (Difference difference : differences) {
    if ((difference.getId() == 2) || (difference.getId() == 3) || (difference.getId() == 14)
        || (difference.getId() == 22)) {
      if (!isFalseDifference(difference, whitelist)) {
        uniqueDifferences.add(difference);
      }
    }
  }

  return uniqueDifferences;
}
 
开发者ID:google,项目名称:zarathustra,代码行数:19,代码来源:DifferenceHelper.java

示例12: equalsInternal

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
@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();
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:16,代码来源:ExtendedJAXBEqualsStrategy.java

示例13: differenceFound

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:xmlunit,项目名称:xmlunit,代码行数:26,代码来源:TextDifferenceListenerBase.java

示例14: differenceFound

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
@Override
public int differenceFound(final Difference difference)
{
	if (difference.getId() == DifferenceConstants.TEXT_VALUE_ID
			&& ignoredElements.contains(difference
					.getControlNodeDetail()
					.getNode()
					.getParentNode()
					.getNodeName()))
	{
		return RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
	}

	return RETURN_ACCEPT_DIFFERENCE;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:16,代码来源:IgnoreNamedElementsDifferenceListener.java

示例15: isCausedByLanguageSettings

import org.custommonkey.xmlunit.Difference; //导入方法依赖的package包/类
/**
 * Ignores all attribute value differences for attributes marked as being language (locale) specific
 * @param difference
 * @return
 */
protected boolean isCausedByLanguageSettings(Difference difference) {
	if (difference.getId() == DifferenceConstants.ATTR_VALUE_ID && 
			languageSpecificAttributes.contains(difference.getControlNodeDetail().getNode().getLocalName())){
		return true;
	}
	return false;
}
 
开发者ID:bpmn-miwg,项目名称:bpmn-miwg-tools,代码行数:13,代码来源:AbstractXmlDifferenceListener.java


注:本文中的org.custommonkey.xmlunit.Difference.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。