Open noamaankhan opened 3 years ago
PactDslJsonRootValue
is for JSON values. Use PactDslRootValue
for plain text.
Also, as your body is plain text, you can't use type matchers (like numberType
), and there are no types with plain text. It is always just text. You probably want PactDslRootValue.stringMatcher('\\d+', '100')
which can match the text body with a regex.
I wrote a Pact consumer contract with the response body expecting a number type using the available api: PactDslJsonRootValue.numberType(). But The verifier is always expecting number 100 instead of just matching a number type.
Here is my example Pact Code:
The consumer pact code:
`@Pact(provider = PROVIDER_NAME, consumer = CONSUMER_NAME) public RequestResponsePact fetchCurrentTimePact(PactDslWithProvider builder) { Map<String, String> responseHeaders = new HashMap<>(); responseHeaders.put(HttpHeaders.CONTENT_TYPE, "text/plain");
I am getting this error when running verifier tests:
java.lang.AssertionError: 0 - BodyComparisonResult(mismatches={/=[BodyMismatch(expected=100, actual=1631595234858, mismatch=Expected body '100' to match '1631595234858' using equality but did not match, path=/, diff=null)]}, diff=[-100, +1631595234858]) at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactJUnit5VerificationProvider.kt:86)
Can someone please help me with using the right apis. Thank you.