Romain Létendart
01/31/2025, 4:56 PMTim Vahlbrock
02/10/2025, 8:01 AMVictor Vargas
02/10/2025, 9:51 AM@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
public void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
If not, what is the recommended way of doing so?
Thanks in advance 🤗Victor Vargas
02/10/2025, 2:53 PM[WARNING] Rule 2: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for org.apache.tika:tika-core:2.9.1 paths to dependency are:
+-com.myproject:1.55.8-SNAPSHOT
+-au.com.dius.pact.provider:spring:4.6.16
+-au.com.dius.pact.provider:junit:4.6.16
+-au.com.dius.pact:provider:4.6.16
+-au.com.dius.pact.core:matchers:4.6.16
+-org.apache.tika:tika-core:2.9.1
and
+-com.myproject:1.55.8-SNAPSHOT
+-au.com.dius.pact.provider:spring:4.6.16
+-au.com.dius.pact.provider:junit:4.6.16
+-au.com.dius.pact:provider:4.6.16
+-io.pact.plugin.driver:core:0.5.1
+-org.apache.tika:tika-core:2.9.2
and
+-com.myprojecti:1.55.8-SNAPSHOT
+-au.com.dius.pact.provider:spring:4.6.16
+-au.com.dius.pact.provider:junit:4.6.16
+-au.com.dius.pact.core:model:4.6.16
+-org.apache.tika:tika-core:2.9.1
Spencer
02/11/2025, 3:34 PMJuan Park
02/12/2025, 3:25 PM"interactions": [
{
"description": "List bundles request",
"interactionMarkup": {
"markup": [...]
},
"key": "5050049c",
"pending": false,
[...]
"metadata": {
"pact-jvm": {
"version": "4.6.14"
},
"pactSpecification": {
"version": "4.0"
},
}
GitHub
02/14/2025, 12:56 AMHaritima Haritima
02/18/2025, 11:40 AMExecutor.closeIdleConnections();
with @afterEach tests but that doesnt work.
Can someone please help with alternative solution to tear down the connection after each tests (edited)Denys
02/18/2025, 3:46 PM@ExtendWith(PactConsumerTestExt.class)
@PactTestFor(providerName = "P01823-TS-Trade-Store", pactVersion = PactSpecVersion.V4, providerType = ProviderType.SYNCH_MESSAGE)
class GetTradesByFilterProductTypeFXFWDTest {
ManagedChannel channel;
@BeforeEach
void setUp(MockServer mockServer) {
System.setProperty("pact_do_not_track", "true");
}
////////////////// 1. GetTradesByFilter product types
@Pact(consumer = "P01819-ipa-mi")
public V4Pact tradesByFilterProductTypeFXFWD(PactBuilder builder) {
return builder
.usingPlugin("protobuf")
.expectsToReceive("a get trade by filter request", "core/interaction/synchronous-message")
.with(Map.of(
"pact:proto", filePath("proto/tsServiceV2.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "TradeStoreService/GetTradesByFilter",
"pact:protobuf-config", Map.of(
"additionalIncludes",
List.of(filePath("proto/tsService.proto"))),
// Details on the request message
"request", Map.of(
"productTypes",
Map.of("value",
"matching(equalTo, 'FXFWD')")),
// Details on the response
"response",
Map.of("trade_key",
Map.of("product_type", "matching(equalTo, 'FXFWD')")))
).toPact();
}
@Test
@PactTestFor(pactMethod = "tradesByFilterProductTypeFXFWD")
@MockServerConfig(implementation = MockServerImplementation.Plugin, registryEntry = "protobuf/transport/grpc")
void testTradesByFilterProductTypeFXFWD(MockServer mockServer, V4Interaction.SynchronousMessages interaction) throws InvalidProtocolBufferException, InterruptedException {
boolean success = false;
ManagedChannel channel = ManagedChannelBuilder.forTarget("127.0.0.1:" + mockServer.getPort())
.usePlaintext()
.build();
try {
TradeStoreServiceGrpc.TradeStoreServiceBlockingStub stub = TradeStoreServiceGrpc.newBlockingStub(channel);
ts.api.TsServiceV2.TradeFilter tradeFilter = ts.api.TsServiceV2.TradeFilter.parseFrom(interaction.getRequest().getContents().getValue());
Iterator<TsService.Trade> responseTrade = stub.getTradesByFilter(tradeFilter);
assertThat(responseTrade).as("getTradeByFilter is null").isNotNull();
} finally {
if (!success) {
channel.awaitTermination(10, TimeUnit.SECONDS);
channel.shutdown();
}
}
}
@Pact(consumer = "P01819-ipa-mi")
public V4Pact tradesByFilterProductTypeFXFWDONE(PactBuilder builder) {
return builder
.usingPlugin("protobuf")
.expectsToReceive("a get trade by filter request", "core/interaction/synchronous-message")
.with(Map.of(
"pact:proto", filePath("proto/tsServiceV2.proto"),
"pact:content-type", "application/grpc",
"pact:proto-service", "TradeStoreService/GetTradesByFilter",
"pact:protobuf-config", Map.of(
"additionalIncludes",
List.of(filePath("proto/tsService.proto"))),
// Details on the request message
"request", Map.of(
"productTypes",
Map.of("value",
"matching(equalTo, 'FXFWD')")),
// Details on the response
"response",
Map.of("trade_key",
Map.of("product_type", "matching(equalTo, 'FXFWD')")))
).toPact();
}
@Test
@PactTestFor(pactMethod = "tradesByFilterProductTypeFXFWDONE")
@MockServerConfig(implementation = MockServerImplementation.Plugin, registryEntry = "protobuf/transport/grpc")
void testTradesByFilterProductTypeFXFWDONE(MockServer mockServer, V4Interaction.SynchronousMessages interaction) throws InvalidProtocolBufferException, InterruptedException {
boolean success = false;
ManagedChannel channel = ManagedChannelBuilder.forTarget("127.0.0.1:" + mockServer.getPort())
.usePlaintext()
.build();
try {
TradeStoreServiceGrpc.TradeStoreServiceBlockingStub stub = TradeStoreServiceGrpc.newBlockingStub(channel);
ts.api.TsServiceV2.TradeFilter tradeFilter = ts.api.TsServiceV2.TradeFilter.parseFrom(interaction.getRequest().getContents().getValue());
Iterator<TsService.Trade> responseTrade = stub.getTradesByFilter(tradeFilter);
assertThat(responseTrade).as("getTradeByFilter is null").isNotNull();
} finally {
if (!success) {
channel.awaitTermination(10, TimeUnit.SECONDS);
channel.shutdown();
}
}
}
}
After running all class I have an error:
2025-02-18 17:34:46,081 ERROR [main] [:] io.pact.plugins.jvm.core.DefaultPluginManager: Failed to initialise the plugin
io.grpc.StatusRuntimeException: UNAVAILABLE: io exception
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:351)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:332)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:174)
at io.pact.plugin.PactPluginGrpc$PactPluginBlockingStub.initPlugin(PactPluginGrpc.java:641)
at io.pact.plugins.jvm.core.DefaultPluginManager.initPlugin$lambda$37(PluginManager.kt:913)
at io.pact.plugins.jvm.core.DefaultPactPlugin.withGrpcStub(PluginManager.kt:267)
at io.pact.plugins.jvm.core.DefaultPluginManager.initPlugin(PluginManager.kt:913)
at io.pact.plugins.jvm.core.DefaultPluginManager.tryInitPlugin(PluginManager.kt:892)
at io.pact.plugins.jvm.core.DefaultPluginManager.initialisePlugin(PluginManager.kt:866)
at io.pact.plugins.jvm.core.DefaultPluginManager.loadPlugin(PluginManager.kt:419)
at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin(PactBuilder.kt:113)
at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin$default(PactBuilder.kt:110)
at au.com.dius.pact.consumer.dsl.PactBuilder.usingPlugin(PactBuilder.kt)
at com.ing.ipami.pact.product_type.GetTradesByFilterProductTypeFXFWDTest.tradesByFilterProductTypeFXFWDONE(GetTradesByFilterProductTypeFXFWDTest.java:101)
Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: getsockopt: /[00000001]52748
Caused by: java.net.ConnectException: Connection refused: getsockopt
Process finished with exit code 0
protobuf plugin V 0.5.4 is installed on my laptop
Do you have any ideas why after running tested class PACT framework generated only one tested method inside contract/.json file?
Thanksvicky
02/19/2025, 12:19 PMHaritima Haritima
02/19/2025, 5:01 PMBas Dijkstra
02/24/2025, 7:25 AMShrinivas Khawase
02/24/2025, 8:52 AMau.com.dius.pact.consumer:junit Version 4.6.14
but we often get the error mentioned below which blocks our pipeline , has anyone else faced this ?Its not consistent but occurs randomly
cc @Sitaram Appalla @Ramesh Kumar
Failed to transform java-semver-0.9.0.jar (com.github.zafarkhaja:java-semver:0.9.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not find java-semver-0.9.0.jar (com.github.zafarkhaja:java-semver:0.9.0).
Searched in the following locations:
<https://jitpack.io/com/github/zafarkhaja/java-semver/0.9.0/java-semver-0.9.0.jar>
Oleksandr Verdiev
02/24/2025, 9:58 AM"yyyy-MM-dd'T'HH:mm:ssZ"
"yyyy-MM-dd'T'HH:mm:ss.SSZ"
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
...
"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZ"
I have tried these so far:
return new PactDslJsonBody()
.object("Data", looksLike()
.uuid("ConsentId")
.datetime("CreationDateTime", INSTANT_ISO_DATETIME_FORMAT, Instant.now())
// "yyyy-MM-dd'T'HH:mm:ss[.[SSSSSSSSS][SSSSSSSS][SSSSSSS][SSSSSS][SSSSS][SSSS][SSS][SS][S]]'Z'";
// static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSZ";
// static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss[.SSSSSSSSS]Z";
static final String INSTANT_ISO_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss(.SSSSSSSSS)?Z";
Paul Sobocinski
02/24/2025, 7:00 PMprovider.getUrl()
is returning null
, which in turn causes the test to fail before the ConsumerClient
is even invoked.
I have it set up the test and example its own repo here. The full error message I'm getting follows:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running exampleclients.ExampleJavaConsumerPactRuleTest
Provider URL: null
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.027 s <<< FAILURE! - in exampleclients.ExampleJavaConsumerPactRuleTest
[ERROR] runTest(exampleclients.ExampleJavaConsumerPactRuleTest) Time elapsed: 0.017 s <<< FAILURE!
java.lang.AssertionError: Provider URL is null! Aborting test.
at exampleclients.ExampleJavaConsumerPactRuleTest.runTest(ExampleJavaConsumerPactRuleTest.java:57)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] ExampleJavaConsumerPactRuleTest.runTest:57 Provider URL is null! Aborting test.
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
Versions used: JDK 1.8
; JUnit 4.8.2
; Pact-JVM 4.1.43
Kusuma Guntamadugu
02/25/2025, 4:15 AMval pactBody = PactDslJsonBody()
.stringMatcher("test", "^(test1|test2)$")
Przemyslaw Boszczyk
03/04/2025, 10:34 AMparameters
field is a Map<String, String> of undefined size and fields.
{
"id": "string"
"parameters": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
}
}
I'm banging my head how to tackle it:
@Pact(consumer = CONSUMER)
RequestResponsePact pact(PactDslWithProvider builder) {
return builder
.uponReceiving("Post message")
.path("/api/messages")
.method("POST")
.body(newJsonBody(body -> {
body.stringType("id", "example_id");
// body.object("parameters", values -> values.eachLike())
}).build())
.matchHeader("Content-Type", "application/json.*", "application/json")
.willRespondWith()
.status(200)
.toPact();
}
Martin Mineo
03/07/2025, 1:16 PMRuud Welling
03/14/2025, 11:10 AM@PactVerifyProvider("A command message")
public MessageAndMetadata processCommand(MessageContents messageContents) {
var jsonMessage = messageContents.getContents().valueAsString();
// this json message does not have the provider state applied
// instead it contains the example value provided by the consumer...
}
I tried to look for examples in the pact SDK, but could not really find any. Am I doing this in the right way? Is provider state supported in message pacts?Neha Munjal
03/14/2025, 11:47 PMRuud Welling
03/19/2025, 4:36 PM@Test
@PactTestFor(pactMethod = "mySyncMessagePact")
void mySyncMessagePact(V4Interaction.SynchronousMessages interaction) {
String request = "{}"; // 1: should call a method that produces the request
// 2: Validate that the request is okay according to the pact
// 3: Validate that the response message can be handled
}
How do I validate that the request message is compliant with the pact that I specified?
After looking at the library code I could not find a standard utility that allows me to easily validate thisRyan Quinn
03/25/2025, 4:19 AM@AllowOverridePactUrl
annotation set, how do I run that test class as part of my regular pipeline? It works fine when I get a request from a webhook, but I don't know how to create the appropriate URLs when running from my build pipeline. Am I confused about something?Chandramani Jha
03/26/2025, 1:22 PMSlackbot
03/26/2025, 1:22 PMErich Zimmerman
03/27/2025, 3:34 PM{
"plans": {
"ABCD32": {
"idRequired": true,
"ids": [
"1234"
]
}
}
}
I'm trying to use object(<name>)
for this, but the name isn't generally predictable.
rootResponseObject.object("plans", (plans) ->
plans.object("??????", (plan) -> {
ratePlan.booleanType("idRequired", true);
ratePlan.array("ids", (item) -> item.stringType("12345"));
})
);
I think I'm a bit confused on when we want things to be more general, and when "test by example" is the right way to go. Since I control the request and data, should I just match to that exact string as the result that fulfills the example?Adrien DEVILLERS
03/28/2025, 10:41 AMRuth
04/08/2025, 9:01 AMjava.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
kotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
at kotlin.reflect.jvm.internal.KCallableImpl.call
Any idea what I can do? Can I use my own serializer, eg. objectMapper?Bas Dijkstra
04/08/2025, 2:11 PMmvn
, and because my provider is a Spring service, this works fine:
mvn clean "-Dpact.verifier.publishResults=true" "-Dpact.provider.version=1.0.0-address-ee07f8c04721b90be743fc1c08946663f01e6e46" test
However, I now also want to list the provider branch, but when I try this (following the docs):
mvn clean "-Dpact.verifier.publishResults=true" "-Dpact.provider.version=1.0.0-address-ee07f8c04721b90be743fc1c08946663f01e6e46" "-Dpactbroker.providerBranch=main" test
It does not record the provider branch. Any ideas? Is this even important? I know I will need it in the next step, when I'll introduce pending pacts...Shaiju B
04/21/2025, 4:02 AM<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.3.6</version>
<scope>test</scope>
</dependency>
Class
@au.com.dius.pact.consumer.junit5.Pact
Any suggestion on how I could resolve this ?Truth Opaleye
04/23/2025, 10:28 PM