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

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


    public Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator) {
        // check if right and left have same number value (including NaN and Infinity)
        Double leftDouble = getDoubleValue(left);
        Double rightDouble = getDoubleValue(right);
        if (!leftDouble.equals(rightDouble)) {
            return new Difference("Different primitive values", left, right);
        }
        return null;
    }
View Full Code Here


   * @param actualValue
   *            the right instance
   * @return true if there is no difference, false otherwise
   */
  public boolean isEqual(Object expectedValue, Object actualValue) {
    Difference difference = getDifference(expectedValue, actualValue, true);
    return difference == null;
  }
View Full Code Here

    }
    cachedResult.put(actualValue, null);

    // perform actual comparison by iterating over the comparators
    boolean compared = false;
    Difference result = null;
    for (Comparator comparator : comparators) {
      boolean canCompare = comparator.canCompare(expectedValue, actualValue);
      if (canCompare) {
        result = comparator.compare(expectedValue, actualValue, onlyFirstDifference, this);
        compared = true;
View Full Code Here

                return new ObjectDifference("Different hibernate proxy types. Left: " + leftType + ", right: " + rightType, left, right);
            }

            Object leftIndentifier = getIdentifier(left);
            Object rightIdentifier = getIdentifier(right);
            Difference identifierDifference = reflectionComparator.getDifference(leftIndentifier, rightIdentifier, onlyFirstDifference);
            if (identifierDifference != null) {
                ObjectDifference difference = new ObjectDifference("Different hibernate proxy values", left, right);
                difference.addFieldDifference("<proxy id>", identifierDifference);
                return difference;
            }
View Full Code Here

     * @param reflectionComparator The root comparator for inner comparisons, not null
     * @return A difference if one of the dates is null and the other one not, else null
     */
    public Difference compare(Object left, Object right, boolean onlyFirstDifference, ReflectionComparator reflectionComparator) {
        if ((right == null && left instanceof Date) || (left == null && right instanceof Date)) {
            return new Difference("Lenient dates, but not both instantiated or both null", 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(differenceFormatterVisitor, innerFieldName));
        }
        return result.toString();
    }
View Full Code Here

    Object leftValue = leftList.get(leftIndex);
    for (int rightIndex = 0; rightIndex < rightList.size(); rightIndex++) {
      Object rightValue = rightList.get(rightIndex);

      Difference elementDifference = reflectionComparator.getDifference(leftValue, rightValue, true);
      if (elementDifference != null) {
        // elements are not matching
        continue;
      }
View Full Code Here

    // loops over all left and right elements to calculate the differences
    for (int leftIndex = 0; leftIndex < leftList.size(); leftIndex++) {
      Object leftValue = leftList.get(leftIndex);
      for (int rightIndex = 0; rightIndex < rightList.size(); rightIndex++) {
        Object rightValue = rightList.get(rightIndex);
        Difference elementDifference = reflectionComparator.getDifference(leftValue, rightValue, false);
        difference.addElementDifference(leftIndex, rightIndex, elementDifference);
      }
    }
  }
View Full Code Here

    Map<Integer, Map<Integer, Difference>> differences = difference.getElementDifferences();

    for (Integer leftIndex : leftIndexes) {
      int score = Integer.MAX_VALUE;
      for (Integer rightIndex : rightIndexes) {
        Difference elementDifference = differences.get(leftIndex).get(rightIndex);

        int matchingScore = matchingScoreCalculator.calculateMatchingScore(elementDifference);
        if (matchingScore < score) {
          score = matchingScore;
          difference.setBestMatchingIndexes(leftIndex, rightIndex);
View Full Code Here

    while (rightIterator.hasNext()) {
      int rightIndex = rightIterator.next();
      Iterator<Integer> leftIterator = leftIndexes.iterator();
      while (leftIterator.hasNext()) {
        int leftIndex = leftIterator.next();
        Difference elementDifference = differences.get(leftIndex).get(rightIndex);
        if (elementDifference == null) {
          rightIterator.remove();
          leftIterator.remove();
        }
      }
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.