pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 480 forks source link

ClasscastException when validating v4 PACT (SynchronousHttp cannot be cast to class RequestResponseInteraction) #1368

Open gtudan opened 3 years ago

gtudan commented 3 years ago

I'm trying to validate a v4 PACT with the junit5 provider-tests but get an exception:

1) Verifying a pact between push-tan-sdk-rest and push-notification-fs-rest - registration

    1.1)       class au.com.dius.pact.core.model.V4Interaction$SynchronousHttp cannot be cast to class au.com.dius.pact.core.model.RequestResponseInteraction (au.com.dius.pact.core.model.V4Interaction$SynchronousHttp and au.com.dius.pact.core.model.RequestResponseInteraction are in unnamed module of loader 'app')
    at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:62)

I'm running the latest version (4.2.5) with Junit5.

Here's the PACT:

{
  "provider": {
    "name": "push-notification-fs-rest"
  },
  "consumer": {
    "name": "push-tan-sdk-rest"
  },
  "interactions": [{
      "_id": "d17c5a35c94b0153efa22b40b38a7a31012f587d",
      "type": "Synchronous/HTTP",
      "description": "registration",
      "request": {
        "method": "POST",
        "path": "/push-notification-functional-service/device",
        "query": {
        },
        "headers": {
          "Content-Type": "application/json"
        },
        "body": {
          "deviceId": "4de4adb9-21ee-47e3-aeb4-8cf8ed6c109a",
          "deviceToken": "string",
          "operatingSystem": "iOS"
        }
      },
      "response": {
        "status": 204,
        "headers": {
        },
        "body": null
      },
      "providerStates": [{
          "name": "new device",
          "params": {
          }
        }]
    }],
  "metadata": {
    "pactSpecification": {
      "version": "4.0"
    },
    "pact-dart": {
      "version": "0.0.1"
    }
  },
  "createdAt": "2021-05-18T13:31:24+00:00"
}
uglyog commented 3 years ago

Linking to #1376