Hi team, in the consumer side message level contra...
# pact-jvm
q
Hi team, in the consumer side message level contract test, we use the MessagePactBuilder to build a message wrapped in a MessagePact type. And store the message into PACT broker. However, in the producer side test, under the @*PactVerifyProvider,* provider will wrap the message in a MessageAndMetadata type. And then we pass this back to PACT which will compare it to what is held in the PACT broker. I'm wondering since the message generated by consumer is wrapped in MessagePact and the message generated by provider is wrapped in MessageAndMetadata. How could we compare these two different type of object? Thanks!
u
Those are two different things.
MessagePact
represents the Pact file and what is stored in the broker. When the Pact is verified, the pact file will be fetched from the broker, loaded as a
MessagePact
class, then the provider method will be called which will return the message data as a
MessageAndMetadata
class. The Pact framework will then do the comparison based on the values of these two classes.
thankyou 3 1
q
Thanks @uglyog, I have another question that under the @Pact annotation, the consumer will define the expected interaction between consumer and provider. Will the pact annotation also generate the PACT, the mock service for the consumer side verification test to use?