pactpact-java

How to generate mock server for pact consumer from contract json file?


I want to use contract file from provider to run tests against consumer. I have

{
"provider": {
    "name": "Provider"
},
"consumer": {
    "name": "Consumer"
},
"interactions": [
    {
        "description": "Get data",
        "request": {
            "method": "Get",
            "path": "/data/1"
        },
        "response": {
            "status": 200,
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "message": ""
            }
        },
        "providerState": "state"
    }
],
"metadata": {
    "pact-specification": {
        "version": "2.0.0"
    },
    "pact-jvm": {
        "version": "3.5.6"
    }
}

And want to use it to generate pact mock server like:

RequestResponsePact pact = new RequestResponsePact(mockServerDescriptionString);

Is it possible to do this?


Solution

  • No. But you can use the pact-stub-server or the pact-stub-service CLI