Package org.jtester.hamcrest.matcher.property.difference

Examples of org.jtester.hamcrest.matcher.property.difference.Difference


      if (isTransient(field.getModifiers()) || isStatic(field.getModifiers()) || field.isSynthetic()) {
        continue;
      }
      try {
        // recursively check the value of the fields
        Difference innerDifference = reflectionComparator.getDifference(field.get(left), field.get(right),
            onlyFirstDifference);
        if (innerDifference != null) {
          difference.addFieldDifference(field.getName(), innerDifference);
          if (onlyFirstDifference) {
            return;
View Full Code Here


                if (isKeyEqual) {
                    found = true;
                    rightIterator.remove();

                    // compare values
                    Difference elementDifference = reflectionComparator.getDifference(leftValue, rightValue, onlyFirstDifference);
                    if (elementDifference != null) {
                        difference.addValueDifference(leftKey, elementDifference);
                        if (onlyFirstDifference) {
                            return difference;
                        }
View Full Code Here

    if (left == right) {
      return null;
    }
    // check if the left value is null
    if (left == null) {
      return new Difference("Left value null", left, right);
    }
    // check if the right value is null
    if (right == null) {
      return new Difference("Right value null", left, right);
    }
    // check if right and left have same number value (including NaN and
    // Infinity)
    if ((left instanceof Character || left instanceof Number)
        && (right instanceof Character || right instanceof Number)) {
      Double leftDouble = getDoubleValue(left);
      Double rightDouble = getDoubleValue(right);
      if (leftDouble.equals(rightDouble)) {
        return null;
      }
      return new Difference("Different primitive values", left, right);
    }
    if (left.getClass() == String.class && Date.class.isAssignableFrom(right.getClass())) {
      SimpleDateFormat df = DateUtil.getDateFormat((String) left);
      right = df.format((Date) right);
    }
    // check if java objects are equal
    if (left.getClass().getName().startsWith("java.lang") || right.getClass().getName().startsWith("java.lang")) {
      if (left.equals(right)) {
        return null;
      }
      return new Difference("Different object values", left, right);
    }
    // check if enums are equal
    if (left instanceof Enum && right instanceof Enum) {
      if (left.equals(right)) {
        return null;
      }
      return new Difference("Different enum values", left, right);
    }
    return null;
  }
View Full Code Here

                String innerFieldName = createFieldName(fieldName, "[" + leftIndex + ",x]", false);
                result.append(formatValues(innerFieldName, unorderedCollectionDifference.getLeftList().get(leftIndex), NO_MATCH));
                continue;
            }

            Difference difference = unorderedCollectionDifference.getElementDifference(leftIndex, rightIndex);
            if (difference == null) {
                continue;
            }

            String innerFieldName = createFieldName(fieldName, "[" + leftIndex + "," + rightIndex + "]", false);
            result.append(difference.accept(treeDifferenceFormatterVisitor, innerFieldName));
        }
        return result.toString();
    }
View Full Code Here

    Iterator<?> leftIterator = leftList.iterator();
    Iterator<?> rightIterator = rightList.iterator();
    while (leftIterator.hasNext() && rightIterator.hasNext()) {
      elementIndex++;

      Difference elementDifference = reflectionComparator.getDifference(leftIterator.next(),
          rightIterator.next(), onlyFirstDifference);
      if (elementDifference != null) {
        difference.addElementDifference(elementIndex, elementDifference);
        if (onlyFirstDifference) {
          return difference;
View Full Code Here

TOP

Related Classes of org.jtester.hamcrest.matcher.property.difference.Difference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.