镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Issue #109 unique key for an arrays of json objects - #177

Open
GooDGreY wants to merge 1 commit into
skyscreamer:masterfrom
GooDGreY:master
Open

GooDGreY wants to merge 1 commit into
skyscreamer:masterfrom
GooDGreY:master

Conversation

@GooDGreY

@GooDGreY GooDGreY commented Sep 7, 2023 •

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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