Skip to content

WireMock Java library: AbstractLogicalMatcher equality check is not considering all operands #3353

@sivakumarbuddha

Description

@sivakumarbuddha

Proposal

Issue

In wiremock java library when I set ignoreRepeatRequests in recordingSpec to avoid the scenarios, stub mappings are not created for some recorded requests.

I suspect AbstractLogicalMatcher equality check is only looking at first operand and ignoring everything else when checking equality. Parent class' equals implementation is used and it is incorrectly doing equals check when identifying duplicate requests

References

No response

Reproduction steps

  • Create a stub mapping with the following setup.
  • Set ignoreRepeatRequests in WireMock recording config and execute multiple requests with variations (example 3 variations) in request body with the following stub matching criteria defined here.
  • Notice that less than 3 stub mappings are created when WireMock recording is stopped.
{
  "id" : "04e8d8e1-c8cc-477f-96e4-c4d6d024eac3",
  "name" : "service_session_getSession",
  "request" : {
    "url" : "/service/test",
    "method" : "POST",
    "bodyPatterns" : [ {
      "and" : [ {
        "matchesJsonPath" : {
          "expression" : "$.sessionContext",
          "equalToJson" : "",
          "ignoreArrayOrder" : true,
          "ignoreExtraElements" : true
        }
      }, {
        "matchesJsonPath" : {
          "expression" : "$.method",
          "equalTo" : "getSession"
        }
      }, {
        "matchesJsonPath" : {
          "expression" : "$.sessionId",
          "equalTo" : "e980bf4f-bad7-3fae-b845-d4fd8dbf9a3a"
        }
      } ]
    } ]
  },
"response" : {
    "status" : 200,
    "bodyFileName" : "service_session-04e8d8e1-c8cc-477f-96e4-c4d6d024eac3.json"
  },
  "uuid" : "04e8d8e1-c8cc-477f-96e4-c4d6d024eac3",
  "persistent" : true,
  "priority" : 1,
  "insertionIndex" : 1
}

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions