Pactflow Code Demos
Introduction
We have created a number of example projects and demo material that you can use as references for your rolling out your contract-testing initiatives.
Resources
Here are some useful resources when it comes to engaging your teams to help with Pact or contract-testing related initiatives:
Resource | Description | Download | |
---|---|---|---|
Demo Pack | A general demo pack for introducing Pact & the concepts of contract testing | pdf | pptx |
Scenarios
Product Catalog System (HTTP/Messages)
Our standard example is a product catalog website (see React above) which consumes a basic Products API implementing the following HTTP interface. All demo languages implement this interface so that we can easily mix and match technologies.
Endpoint | Example Response |
---|---|
GET /products | [{"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"},{"id":"10","type":"CREDIT_CARD","name":"28 Degrees","version":"v1"},{"id":"11","type":"PERSONAL_LOAN","name":"MyFlexiPay","version":"v2"}] |
GET /product/1 | {"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"} |
info
The single get product endpoint is not a spelling mistake, and is used to show evolution to more standard resource based design
Demos
Consumers
Language | Use Case | Framework/Tech | Description |
---|---|---|---|
JS/NodeJS | Web | React | React JS website relying on a Products API |
JS/NodeJS | Web | Cypress | Example demonstrating how Cypress could be used to generate consumer pacts |
JS/NodeJS | AWS/SNS/Messages | SNS Lambda | AWS Lambda SNS Consumer |
Java | Messages | Kafka | Java Kafka consumer |
NodeJS | Messages | Kafka | NodeJS Kafka consumer |
Java | SOAP | Java | Java SOAP API consumer (note: only compatible with the SOAP provider) |
.NET | API | .NET | .NET Products API consumer |
Providers
Language | Use Case | Framework/Tech | Description |
---|---|---|---|
JS/NodeJS | API | Express JS | ExpressJS API provider |
JS/NodeJS | AWS/SNS/Messages | ExpressJS / AWS SNS | AWS Lambda SNS Provider |
Java | API | Spring Boot | Java Spring Boot API provider |
Java | Messages | Kafka | Java Kafka message provider |
Java | SOAP | Java | Java SOAP API provider (note: only compatible with the SOAP consumer) |
.NET | API | .NET | .NET API provider |