Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pact-jvm not matching empty objects using Postel's law #298

Closed
BenSayers opened this issue Aug 3, 2016 · 3 comments
Closed

pact-jvm not matching empty objects using Postel's law #298

BenSayers opened this issue Aug 3, 2016 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@BenSayers
Copy link

BenSayers commented Aug 3, 2016

If I have a consumer Pact file containing this response body:

"body": {
    "name": {
        "first": "Donald"
    }
}

And the provider returns this response:

{
    "name": {
        "first": "Donald",
        "last": "Duck"
    }
}

Then all is well, the provider verify passes. However if I change the consumer Pact file to this:

"body": {
    "name": {
    }
}

pact-jvm will return this error when the provider verifies the pact file:

$.body.name -> Expected an empty Map but received Map(first -> Donald, last -> Duck)

This seems like a bug to me. If its not a bug can you please let me know how I can write a consumer Pact file that asserts that the name property is defined within the response but does not care about what values are within the object.

@uglyog
Copy link
Member

uglyog commented Aug 3, 2016

Not so much of a bug as a special case. I guess we did not think someone would want to specify an empty map that indicated they accept everything.

I'll have a look if using a like matcher will help in your case.

@uglyog
Copy link
Member

uglyog commented Aug 3, 2016

Looks like it won't accept a matcher in that case, I'll need to fix that.

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Aug 7, 2016
uglyog pushed a commit that referenced this issue Aug 1, 2021
@uglyog
Copy link
Member

uglyog commented Aug 1, 2021

@uglyog uglyog closed this as completed Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants