Class RecursiveComparisonDifferenceCalculator

java.lang.Object
org.assertj.core.api.recursive.comparison.RecursiveComparisonDifferenceCalculator

public class RecursiveComparisonDifferenceCalculator extends Object
Based on DeepDifference but takes a RecursiveComparisonConfiguration, DeepDifference being itself based on the deep equals implementation of https://github.com/jdereg/java-util
Author:
John DeRegnaucourt ([email protected]), Pascal Schumacher
  • Constructor Details

    • RecursiveComparisonDifferenceCalculator

      public RecursiveComparisonDifferenceCalculator()
  • Method Details

    • determineDifferences

      public List<ComparisonDifference> determineDifferences(Object actual, Object expected, RecursiveComparisonConfiguration recursiveComparisonConfiguration)
      Compare two objects for differences by doing a 'deep' comparison. This will traverse the Object graph and perform either a field-by-field comparison on each object (if not .equals() method has been overridden from Object), or it will call the customized .equals() method if it exists.

      This method handles cycles correctly, for example A->B->C->A. Suppose a and a' are two separate instances of the A with the same values for all fields on A, B, and C. Then a.deepEquals(a') will return an empty list. It uses cycle detection storing visited objects in a Set to prevent endless loops.

      Parameters:
      actual - Object one to compare
      expected - Object two to compare
      recursiveComparisonConfiguration - the recursive comparison configuration
      Returns:
      the list of differences found or an empty list if objects are equivalent. Equivalent means that all field values of both subgraphs are the same, either at the field level or via the respectively encountered overridden .equals() methods during traversal.