You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to cover a file download endpoint via consumer driven contract test.
I don't care about the downloaded content but want to verify that the body is not empty by using PactDslRootValue.stringMatcher("^.+$", "whatever")
Consumer class:
public class DownloadEndpointsCDCTest extends ConsumerPactTest
{
@Override
protected RequestResponsePact createPact(final PactDslWithProvider aBuilder)
{
return aBuilder//
.given("A text generation job finished successfully")
.uponReceiving("A request to download text")
.pathFromProviderState("/textresult/${jobId}", "/textresult/" + "dummyJobId")
.method("GET")
.willRespondWith()
.status(200)
.headers(Map.of("Content-Type", "text/plain"))
.body(PactDslRootValue.stringMatcher("^.+$", "whatever"))
.toPact();
}
}
Unfortunately the verification on provider side fails in case body contains line breaks.
The body content "Hello World" can be verified successfully but "Hello \r\n World" fails with following message:
java.lang.AssertionError: Core_Chat_Client - Upon A request to download text
Failures:
Verifying a pact between Core_Chat_Client and Chat_Service - A request to download text has a matching body
1.1) body: / Expected body 'whatever' to match 'Hello
World' using regex '^.+$' but did not match
at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:66)
at foo.ContractVerificationTest.pactVerificationTestTemplate(ContractVerificationTest.java:147)
Used versions:
Consumer: au.com.dius.pact.consumer:junit:4.3.10
Provider: au.com.dius.pact.provider:junit5:4.3.10
The text was updated successfully, but these errors were encountered:
I tried to cover a file download endpoint via consumer driven contract test.
I don't care about the downloaded content but want to verify that the body is not empty by using PactDslRootValue.stringMatcher("^.+$", "whatever")
Consumer class:
Generated contract:
Unfortunately the verification on provider side fails in case body contains line breaks.
The body content "Hello World" can be verified successfully but "Hello \r\n World" fails with following message:
Used versions:
Consumer: au.com.dius.pact.consumer:junit:4.3.10
Provider: au.com.dius.pact.provider:junit5:4.3.10
The text was updated successfully, but these errors were encountered: