The consumer test code as it is currently doesn't fetch the message. Instead, we need to modify it with the following:
- Add @PactVerification({"provider name"}) annotation to the @test method
- Remove the args to the test method
- Create one more method with the following code:
public void setMessage(byte[] messageContents) {
System.out.println("Did the call come to setMessage?");
//Set the class member currentMessage value as the arg received from this function
currentMessage = messageContents;
}
This function gets called automatically by Pact during execution and it fetches the message.
- Modify the @test method where all verifications are performed on the stored class variable (which will be set by Pact via setMessage)
For example, the test can have the following code:
Assert.assertNotNull(new String(currentMessage));
The consumer test code as it is currently doesn't fetch the message. Instead, we need to modify it with the following:
public void setMessage(byte[] messageContents) {
System.out.println("Did the call come to setMessage?");
//Set the class member currentMessage value as the arg received from this function
currentMessage = messageContents;
}
This function gets called automatically by Pact during execution and it fetches the message.
For example, the test can have the following code:
Assert.assertNotNull(new String(currentMessage));