Skip to content

Conversation

@GooDGreY
Copy link

@GooDGreY GooDGreY commented Sep 7, 2023

I also had the same problem, as people in issue#109.
For example with json like this:

{
    "bookings": [
        {
            "booking_id": "1d7a81b0-e0c4-441d-9fe4-48dfb776d8e7", 
            "created_at": "2023-09-07T07:28:57.822Z"
        },
           {
            "booking_id": "2a6a97b0-e0c4-441d-9fe4-48dfb776f1a8", 
            "created_at": "2023-09-07T08:28:55.823Z"
        }
    ]
}

And custom comparator like this:

CustomComparator customComparator = new CustomComparator(
        JSONCompareMode.LENIENT, 
        new Customization("**." + CREATED_AT, (o1, o2) -> true)
);

So "created_at" should be ignored, but AbstractComparator makes decision to use "created_at" as a unique key, when comparing elements in an array, so assertion fails. I fixed it, making it possible to pass unique key name as a parameter. For the example above, I would need to pass "booking_id" as a unique key for correct assertion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant