Questions tagged [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.

JVM implementation of the consumer driven contract library pact.

From the Ruby Pact website:

Define a pact between service consumers and providers, enabling "consumer driven contract" testing.

Pact provides an RSpec DSL for service consumers to define the HTTP requests they will make to a service provider and the HTTP responses they expect back. These expectations are used in the consumers specs to provide a mock service provider. The interactions are recorded, and played back in the service provider specs to ensure the service provider actually does provide the response the consumer expects.

This allows testing of both sides of an integration point using fast unit tests.

This gem is inspired by the concept of "Consumer driven contracts". See http://martinfowler.com/articles/consumerDrivenContracts.html for more information.

Read Getting started with Pact for more information on how to get going.

Source: https://github.com/DiUS/pact-jvm/

109 questions
5
votes
1 answer

Pact: How do I match an object whose keys match a regular expression?

I am trying to write a pact consumer test to match the following response. [ { "accountId" : 1, "permissions" : [ { "schedule" : { "01/01/2018" : false, "01/01/1900" : true …
Quincy Bowers
  • 390
  • 2
  • 15
5
votes
2 answers

Why assert in @PactVerification?

I don't understand the use of assert in @PactVerification. To me it seams more like a complicated way of saying 1 == 1. For example: import static org.assertj.core.api.Assertions.assertThat; public class PactConsumerDrivenContractUnitTest { …
4
votes
1 answer

How to implement a simple PACT-JVM solution on existing Scala code-base

We are trying to implement a Hybrid approach for PACT-provider for Scala. We're looking for a simple example of Pact-JVM-provider side implementation using PACT-JVM (Java variant) We've the project code-base in Scala, but would like to try Pact JVM…
user2451016
  • 1,857
  • 3
  • 20
  • 44
4
votes
1 answer

How to inject dynamic id for Pact test from provider to consumer using REST Assured

I need to check an api of the type /meeting/id using Pact tests and REST Assured. The id may change and I'd like to create an item before the test and inject their id to overwrite what is set as part of the url path for the contract but not sure how…
Francislainy Campos
  • 3,462
  • 4
  • 33
  • 81
4
votes
2 answers

How to verify stringified json in pact

I am trying to build a pact between two services using asynchronous communication. This is the code I used for generate the pact: @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider", providerType =…
4
votes
1 answer

Using java to create PACT I am not able to set the min value of the numberType in the body

I am learning how to use PACT into my Java project and I would like to define some values restrictions on the expected output. For example, into one request /hello-world I am expecting to receive a number into the id attribute that should be always…
Thiago Mata
  • 2,825
  • 33
  • 32
3
votes
2 answers

Publish pacts to a pact broker using maven plugin

I was able to generate a pact file and then verify it using the maven plugin. Now, I am trying to publish the pacts using a pact broker. What I have done so far is based on the below link- …
ljs
  • 495
  • 1
  • 8
  • 23
3
votes
2 answers

pact-jvm : how to solve au.com.dius.pact.consumer.PactMismatchesException

I am trying to generate a pact between 2 of our services using pact-JVM. But when I try to run the Java class, I get this exception. 1) I suspect something is wrong with the Pact body, is that correct? There is an extra 'message' parameter in the…
ljs
  • 495
  • 1
  • 8
  • 23
2
votes
1 answer

Pact - Ignore some interactions when verifying on provider side

Let's say I have a provider which is involved in 2 interactions (with one consumer or many, it shouldn't matter). On the provider side, I am able to handle one interaction in the sense that I know how to interpret the provider state of one…
Gaël J
  • 11,274
  • 4
  • 17
  • 32
2
votes
1 answer

Setting mock ports for multiple providers in pact-jvm

I am trying to learn the pact framework by rewriting some of our wiremock tests that test our application written in java and springboot. I have provided a simplified example of where we end up getting…
Kevin de Boer
  • 115
  • 1
  • 2
  • 4
2
votes
1 answer

Pact Dsl - provider returning more records than in pact file

I have the following classes:- public class Student { private String id; private String firstName; private String lastName; private int age; } public class DepartmentResponse { private String id; private String name; List
ShefZee
  • 95
  • 7
2
votes
1 answer

@SpyBean not working with Pact and JUnit 5

I'm trying to use the @SpyBean to mock a method of a @Component and doesn't work. @MockBean works (followed the example). I've tried, read and researched many ways but couldn't make it work. Here's the example: @SpringBootTest(webEnvironment =…
talabes
  • 5,344
  • 2
  • 22
  • 27
2
votes
0 answers

How to modify request body in POST during Pact provider verification?

Is it possible to modify parameter values defined in the body during provider verification? The pact wiki(https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245) provides a…
LoL
  • 41
  • 5
2
votes
3 answers

No primary or default constructor found for Pageable in Pact Contract Provider test

I set up following pact contract provider test @RunWith(SpringRestPactRunner.class) @Provider("structures") @PactFolder("pacts") @VerificationReports({"console", "markdown"}) @SpringBootTest public class ContractTest { @MockBean private…
Ira Re
  • 730
  • 3
  • 9
  • 25
2
votes
1 answer

Pact provider tests broken: pactVerificationTestTemplate » PreconditionViolation

I'm quite new to CDC testing and only make my first steps. I've deployed the Pact-Broker (docker-compose), running at localhost:80. The consumer sends the generated pacts successfully to the broker, but it seems that the provider can't get a valid…
Tagira
  • 31
  • 1
  • 3
1
2 3 4 5 6 7 8