Josh
05/13/2022, 3:43 PMsamiksha fulzele
05/16/2022, 9:57 AMAkash
05/17/2022, 12:53 AMAkash
05/17/2022, 1:24 AM4.2.20
). We’ve got 2 different similar requests like:
DslPart requestOneResponseBodyDslPart = PactDslJsonArray
.arrayEachLike()
.uuid("id", UUID.randomUUID())
.datetime("startTime", INSTANT_FORMAT_STRING)
// More keys here
.closeObject();
DslPart requestTwoResponseBodyDslPart = PactDslJsonArray
.arrayEachLike()
.uuid("id", UUID.randomUUID())
.datetime("scheduledStartTime", INSTANT_FORMAT_STRING)
.closeObject();
Both of them generate random UUIDs and the default datetime string adhering to the format like: "2000-02-01T00:00:00.000000Z"
in the pact JSON file.
The problem is that `requestOneResponseBodyDslPart`’s provider verification is expecting exact value matches for both the .uuid
and .datetime
fields, which is really odd, considering we’ve used PactDslJsonArray before too.Oscar Calderin
05/17/2022, 10:18 AM.body(PactDslJsonArray.arrayMinLike(1)
.stringType("transactionHash")
.stringType("originWallet")
.stringType("destinationWallet")
.decimalType("amount", 1.0)
.datetime("creationDate")
.stringType("method")
.stringType("status")
.decimalType("fee")
).toPact();
when I execute my consumer tests they are passing, but then when I'm running my provider tests I'm getting this error:
body: $.0.creationDate Expected 1652738400000 to match a datetime of 'yyyy-MM-dd'T'HHmmss': Unable to parse the date: 1652738400000Muthukumar Ramachandran
05/17/2022, 9:58 PMJames Weng
05/18/2022, 6:10 AMThomas Cederholm
05/18/2022, 11:19 AM@PactFilter
annotation, with the exact string of the state, then both tests fail to find pacts. Without the annotation it breaks because a test only contains one state. Do I have to have all states in each test file together with the @PactFilter
?Anja Gruss
05/18/2022, 12:03 PMRubén Pérez
05/19/2022, 11:11 AMNitesh Rajgopal
05/20/2022, 7:28 AMprivate fun responseBody2(): DslPart? {
return PactDslJsonArray.arrayEachLike()
.`object`("type")
.`object`("content")
.stringType("title", "Search Results")
.closeObject()
.closeObject()
.`object`("type2")
.`object`("content")
.stringType("price", "$500")
.stringType("subTitle", "")
.stringType("title", "")
.closeObject()
.closeObject()
}
Nitesh Rajgopal
05/20/2022, 7:30 AMBen Pilgrim
05/23/2022, 8:22 AMÉdouard Lopez
05/23/2022, 10:04 AM@PactVerifyProvider(…)
value and the consumer expectsToReceive(…)
one. I was using Pact only for REST until now and, to my understanding, I never had to use that. Why this difference?André Sousa
05/23/2022, 4:13 PMThomas K
05/24/2022, 1:21 PMvalueFromProviderState
seems to require an expression and example for my email address value, any recommendations here please?Carlos Henrique
05/24/2022, 6:31 PMQingyuan Liu
05/25/2022, 6:42 AMEmirhan Emmez
05/26/2022, 6:41 AMShaun Mendham
05/26/2022, 8:07 AMservice-name
and service-name-kafka
)
What I am seeing currently with a single provider name across two test classes, is that all contracts for the provider are run against both types of which the opposite type contracts fail.GitHub
05/26/2022, 6:21 PMpactbroker.providerBranches
(replacing pactbroker.providerTags
) on my provider with latest release 4.3.8
. It is not able to fetch pending and wip pacts using branches. It was able to fetch the pending and wip pacts using tags. Doing bit of investigation, it appears the problem is because this code populates providerVersionBranches
but Pact broker expects providerVersionBranch
I think (@Beth (pactflow.io/Pact Broker/pact-ruby) ?). This is my suspect but I am not sure.
Pactbroker log:
2022-05-26 17:48:01.586098 I [7:puma srv tp 001] PactBroker::Api::Resources::ProviderPactsForVerification -- Fetching pacts for verification by pactdemo-provider-springboot -- {:provider_name=>"pactdemo-provider-springboot", :params=>{"consumerVersionSelectors"=>[{"mainBranch"=>true}, {"deployedOrReleased"=>true}], "includePendingStatus"=>true, "includeWipPactsSince"=>"2022-05-01", "providerVersionBranches"=>["mybranch"], "providerVersionTags"=>[]}}
pact-foundation/pact-jvmJayakannan Jeyapandian
05/27/2022, 8:01 AM@PactTestFor(providerName = "test-provider", port = "${pact.server.port}")
We would be setting the same port in one of our config yml file hence we would like to either set it via command line or read and pass it to our yml config similar to using @AutoConfigureWiremockPort which exposes the port via ${wiremock.server.port}Aurelia
05/27/2022, 9:05 AMFrancisco González
05/27/2022, 10:56 AMWiesław Bondyra
05/27/2022, 11:05 AM@Pact(consumer = CONSUMER_NAME, provider = PROVIDER_NAME)
public RequestResponsePact createPactForWiesaTest(PactDslWithProvider pactDslWithProvider) {
MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.setContentType(ContentType.APPLICATION_FORM_URLENCODED)
.addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv")
.addTextBody("textPart", "sample text");
PactDslResponse builder = pactDslWithProvider
.given("Check buildId")
.uponReceiving("Request to get wiesa buildId")
.path("/wiesabuild")
.body(multipart2)
.method("POST")
.willRespondWith()
.status(HttpStatus.OK.getCode())
.body("is OK", MediaType.TEXT_PLAIN);
return builder.toPact();
}
@Test
@PactTestFor(providerName = "WiesaMultipartService", pactMethod = "createPactForWiesaTest")
void testWiesaMultipartService(MockServer mockServer) throws MalformedURLException {
String url = mockServer.getUrl();
String response;
MultipartEntityBuilder multipart2 = MultipartEntityBuilder.create()
.setMode(HttpMultipartMode.STRICT)
.setContentType(ContentType.APPLICATION_FORM_URLENCODED)
.addBinaryBody("file", "1,2,3".getBytes(), ContentType.create("text/csv"), "data.csv")
.addTextBody("textPart", "sample text");
try (RxHttpClient rxHttpClient = RxHttpClient.create(new URL(url))) {
response = rxHttpClient.toBlocking().retrieve(
<http://HttpRequest.POST|HttpRequest.POST>("/wiesabuild", multipart2)
.contentType(APPLICATION_FORM_URLENCODED)
.accept(APPLICATION_FORM_URLENCODED),
String.class
);
assertThat(response).as("body should be with simple is OK statement").isEqualToIgnoringWhitespace("is OK");
}
}
What might be wrong in this example?Akash
05/30/2022, 1:31 AMtrue
.Akash
05/31/2022, 4:47 AMShivam Kumar
05/31/2022, 10:41 AMorg.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter
exception. Can someone please help us on fixing it? If there is recommendation to use another approach, Can you please share?
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider::class)
fun pactVerificationTestTemplate(context: PactVerificationContext, requestBuilder: org.apache.hc.core5.http.HttpRequest) {
var newUri = sanitiseUrl(requestBuilder.uri.toString())
requestBuilder.setUri(URI(newUri))
context.verifyInteraction()
}
Dependencies used:
<http://au.com|au.com>.dius.pact.consumer.junit5
, 'org.apache.httpcomponents.core5', name: 'httpcore5', version: '5.1.3'
Akash
06/01/2022, 1:25 AM"au.com.dius.pact.provider:junit5spring:4.3.8"
"au.com.dius.pact.consumer:junit5:4.3.8" // tried this with junit 4 as well.
Because of this, running either tests now keep failing:
...
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
We think it’s because of including those packages together, despite running different classes for 1) generating the consumer tests. 2) running provider verifications. Any ideas for if this is indeed supported?Qingyuan Liu
06/06/2022, 4:52 AM