0

I hope you would suggest me something as I am quite new to Java world and trying to work with assertj-core recursive comparison APIs for deep comparison between the objects as follows. But it appears that it doesn't work when we pass collections of custom objects for deep comparison when they are large in number for example even for 50 or 100, the comparison takes forever.

Let me share you the code chunks to look at.

class Owner
{
   String id;
   String name;
   ArrayList<Assignment> assignments;

   Owner(String id,String name, ArrayList<Assignment> assignments)
   {
      this.id = id;
      this.name = name;
      this.assignments = assignments;
   }
}

class Assignment
{
   String assignmentName;
   String assignmentDescription;
   
   Assignment(String assignmentName, String assignmentDescription)
   {
     this.assignmentName = assignmentName;
     this.assignmentDescription = assignmentDescription;
   }
}

From above model, I am generating a list 100 owners and each having 20 assignments. Similarly another list 100 owners with 20 assignments each.

Now when I start comparing them with assertj RecursiveComparisonDifferenceCalculator , the comparison takes forever.

Below is the sample code I have to get the difference between two objects.

var config = RecursiveComparisonConfiguration();
    
var difference = new RecursiveComparisonDifferenceCalculator.determineDifferences(list1owners, list2owners, config);

I have tried setting the properties of the RecursiveComparisonConfiguration object as follows but it doesn't seem work and the comparison is kind of stuck.

config.ignoreCollectionOrder(false);

Not sure, but I thought the above setting would make list comparison to work index wise like first object of the list be compared with first object of the another list and so on, but that too doesn't seem to work either and the comparison still takes a significant time.

Please guide with all the possible suggestions/solutions you guys might have, I will try to follow them.

Amit
  • 13
  • 4
  • Why do you need to compare such big amounts of objects? Why are two owners with two or three different assignments not enough for your unit tests? – Thomas Kläger Mar 08 '23 at 21:57
  • could you raise an issue in https://github.com/assertj/assertj/issues with a test reproducing the behavior? thanks! – Joel Costigliola Mar 09 '23 at 20:22
  • @JoelCostigliola thanks for the response. I have raised an issue as suggested. https://github.com/assertj/assertj/issues/2979 – Amit Mar 11 '23 at 09:32

0 Answers0