nmrao
Thanks for reply, I tried below codes,
1) For Decimal:
class BigDecimalElementDifferenceEvaluator implements DifferenceEvaluator {
private String elementName;
public BigDecimalElementDifferenceEvaluator(String elementName) {
this.elementName = elementName;
}
@Override
public ComparisonResult evaluate(Comparison comparison, ComparisonResult outcome) {
if (outcome == ComparisonResult.EQUAL) return outcome; // only evaluate differences.
final Node controlNode = comparison.getControlDetails().getTarget();
final Node testNode = comparison.getTestDetails().getTarget();
if (controlNode.getParentNode() instanceof Element && testNode.getParentNode() instanceof Element) {
Element controlElement = (Element) controlNode.getParentNode();
Element testElement = (Element) testNode.getParentNode();
if (controlElement.getNodeName().equals(elementName)) {
final String controlValue = controlElement.getTextContent();
final String testValue = testElement.getTextContent();
if (new BigDecimal(controlValue).compareTo(new BigDecimal(testValue)) == 0) {
return ComparisonResult.SIMILAR;
}
}
}
return outcome;
}
}
//Implementation
Diff myDiff = DiffBuilder.compare(control).withTest(test)
.withDifferenceEvaluator(new BigDecimalElementDifferenceEvaluator("amount"))
.checkForSimilar()
.build();
Error Getting: Caught exception during comparision.
2) Element Order
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.conditionalBuilder().whenElementIsNamed("ShiftAttributes").thenUse(ElementSelectors.byXPath('./ShiftAttribute', ElementSelectors.byNameAndAllAttributes)).elseUse(ElementSelectors.byName).build()))
Error: But it's not handling order.