Hi
I am trying to understand the expected behaviour and use cases for provider state parameters.
I've read through:
•
https://docs.pact.io/getting_started/provider_states
•
https://docs.pact.io/implementation_guides/jvm/consumer (Having values injected from provider state callbacks)
•
https://docs.pact.io/implementation_guides/jvm/provider/junit#provider-state-callback-methods
and some of our own usages of this functionality and I still have some questions about both the concept and potentially the pact-jvm implementation.
Questions:
1. The consumer docs above suggest the use case of the params is where the provider actually generates some identifiers that appear in the interaction.
a. Since the consumer in pact-jvm always must specify an example when using the xxxFromProviderState() methods and the provider must always return those parameters from a state method as a populated map, what is the use case for the consumer to define concrete values in the pact itself if the provider won't read them and the consumer can't read them?
b. Shouldn't those concrete values just be used instead of the examples when calling xxxFromProviderState() methods?
c. What is the use case for the provider to accept an incoming map of params in their implementation of the state methods if the provider is expected to generate these values and return them?
2. I have started to see some pacts define many identifiers and interesting values in the provider state params that are then expected to populate all the fields in a json response body. The expectation here is these values are then taken by the provider in their state method to prime test data.
a. Is this a valid use case of provider state params or is this too much coupling between pacticipants?
b. Specifically with the pact-jvm implementation, it seems unnecessary in such a use case for the provider to need to return a new map of provider state params if its just going to prime using all the incoming params. The API however requires you to effectively return the incoming map otherwise the params used in the test will be an empty map.
3. Are there any documentation/talks that discuss the use of provider state parameters in more detail outside the links above? I can't seem to find any discussion of why they were being introduced in the pact v3 spec.
I realise there is quite a lot here, but I would like to understand how I should be using this functionality.
Cheers