Skip to main content

Example Maven provider project

Source Code​

https://github.com/pact-foundation/pact-plugins/tree/main/examples

This example project has a server implementation in Kotlin for the area calculator service call:

  rpc calculate (ShapeMessage) returns (AreaResponse) {}

The Maven Protobuf plugin is used to generate the gRPC classes for the calculate service call and the Kotlin Server class implements the calculate method.

gRPC plugin​

To run the test in this project, it requires the gRPC plugin to be installed. See the documentation on that plugin.

Pact verification test​

There is a Pact verification test written in Java and JUint 5 that can verify the Kotlin server using a Pact file from one of the consumer projects.

In order to run the test, you must copy the pact files, from the consumer directory

mkdir -p src/test/resources/pacts
cp ../consumer-maven/target/pacts/*.json src/test/resources/pacts

You can then run the provider tests with

mvn test