本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}