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

Negative Integer is not recognised as such #1575

Open
SandorArpa opened this issue Jun 27, 2022 · 3 comments
Open

Negative Integer is not recognised as such #1575

SandorArpa opened this issue Jun 27, 2022 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@SandorArpa
Copy link

We have a pact test where one of the variables is a negative number (MessagePactBuilder generated file):

{ "consumer": { "name": "ledger" }, "provider": { "name": "connector" }, "messages": [ { "_id": "c3d524ebb49c46e1e8b100a94d9c880b6a0cc43b", "description": "a dispute lost event", "metaData": { "contentType": "application/json" }, "contents": { "event_type": "DISPUTE_LOST", "service_id": "service-id", "resource_type": "dispute", "event_details": { "amount": 6500, "gateway_account_id": "a-gateway-account-id", "fee": 1500, "net_amount": -8000 }, "live": true, "timestamp": "2022-01-19T07:59:20.000000Z", "resource_external_id": "payment-external-id", "parent_resource_external_id": "external-id" }, "matchingRules": { "body": { ... "$.event_details.net_amount": { "matchers": [ { "match": "integer" } ], "combine": "AND" }, "$.event_details.amount": { "matchers": [ { "match": "integer" } ], "combine": "AND" }, "$.event_details.gateway_account_id": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.event_details.fee": { "matchers": [ { "match": "integer" } ], "combine": "AND" } } } } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.6.15" } }

The provider's response:

{ "resource_external_id": "resource-external-id", "event_details": { "gateway_account_id": "a-gateway-account-id", "net_amount": -8000, "amount": 6500, "fee": 1500 } ... }

The error:

BodyComparisonResult(mismatches={$.event_details.net_amount=[BodyMismatch(expected=-8000, actual=-8000, mismatch=Expected -8000 (JsonPrimitive) to be an integer, path=$.event_details.net_amount, diff=null)]}, diff=[{, - "event_type": "DISPUTE_LOST",, - "service_id": "service-id",, - "resource_type": "dispute",, + "resource_external_id": "resource-external-id",, "event_details": {, - "amount": 6500,, "gateway_account_id": "a-gateway-account-id",, - "fee": 1500,, - "net_amount": -8000, + "net_amount": -8000,, + "amount": 6500,, + "fee": 1500, },, - "live": true,, "timestamp": "2022-01-19T07:59:20.000000Z",, - "resource_external_id": "payment-external-id",, - "parent_resource_external_id": "external-id", + "parent_resource_external_id": "external-id",, + "service_id": "service-id",, + "live": true,, + "resource_type": "dispute",, + "event_type": "DISPUTE_LOST", }])

when running in IDE against a local pact file (Running with PactFolder tag on provider, using PactVerifyProvider, not State) :

  • without matchingRules - it passes
  • with matchingRules but net_amount type set to number - it passes
  • with matchingRules and net_amount type is integer - fails
@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Jul 26, 2022
@rholshausen
Copy link
Contributor

I've tested this with the latest version (4.3.12), and it works correctly. I've noticed your Pact file has "pact-jvm": { "version": "3.6.15" }, is that the version you are using (3.6.15)?

@SandorArpa
Copy link
Author

Yes, we are on 3.6.15

@rholshausen
Copy link
Contributor

Can you upgrade? That version is not supported anymore, and the supported versions do not have this issue.

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