Firstlty, Just Check four models Owners, Owner, Addresss(Its different from yours), CodeInfo from here https://github.com/rckr20/javers/tree/master/javerscore/src/test/java/org/javers/core/examples/model
Now what i am doing is comparing two Owners object using LEVENSHTEIN_DISTANCE algorithm in this way.
/*Comparing List */
Owners Owners1 = new Owners();
Owners1.add(new Owner(1,new Addresss("Delhi",null,new CodeInfo(null))));
Owners Owners2 = new Owners();
Owners2.add(new Owner(2,new Addresss("Noida","SEZ",new CodeInfo("abc"))));
Diff diff = JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.LEVENSHTEIN_DISTANCE).build().compare(Owners1, Owners2);
Now you will ask why i am not using simply List instead of using Owners(which is extending ArrayList of Owner). Secondly I can't use compareCollection() here. My current project architecture is like that and i can't change that.
So on comparison what i need is value changes but its returning the list change.
Diff:
changes on org.javers.core.graph.LiveGraphFactory$ListWrapper/ :
'list' collection changes :
0. 'org.divik.javers.JaversBasic.Owner@3f0846c6' changed to 'org.divik.javers.JaversBasic.Owner@77a98a6a'
And just for solving this i just tried to convert the Owners object into the JsonNode.
You can also check this https://easyupload.io/aez105
Just tried by mapping owner as Entity but the same noisy results. But got the solution We can compare it like this.
Diff diff = JaversBuilder.javers().withListCompareAlgorithm(ListCompareAlgorithm.LEVENSHTEIN_DISTANCE).build().compareCollections(((List)Owners1), (List)Owners2,Owner.class);
But facing problem again if I have Owners(i.e class extending array list) nested inside some model
Example:--
class Car{
@Id
int id;
Owners owners;
public Car(int id, Owners owners) {
this.id= id;
this.owners = owners;
}
}
Again I am getting noisy results.