Given:
a defined contract with Spring Cloud Contract Messaging.
https://github.com/nusmanov/producer/blob/master/src/test/resources/contracts/user-presence.yaml
Question:
assert user == joe
assert user has characters
Producer: https://github.com/nusmanov/producer
Consumer: https://github.com/nusmanov/consumer
Yes, you can. Please read the documentation here https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#contract-dsl-dynamic-properties . Example of a messaging contract with matchers can be found here https://github.com/spring-cloud/spring-cloud-contract/blob/e91b91efba60c52c3e8a6e65171a9f6dd18cb276/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/messaging/integration/StubRunnerIntegrationMessageSelectorSpec.groovy#L198-L220 . I'm pasting it for your convenience
Contract.make {
input {
messageFrom "foo"
messageHeaders {
header("foo", $(anyUuid()))
}
messageBody(foo: 123)
}
}