-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New verification type: FUNCTION #1379
Comments
How are the functions going to be specified in the test class? |
@uglyog open to suggestions, but maybe something like: interface IProviderVerifier {
var verificationFunction: Function<String, Any>
} Really just need one method that can take in the description and return the appropriate response. |
I was more referring to the user's test class. Will it need to be a public instance? The verifier class is not directly exposed to user code. We will need to support it across the implementations: Groovy, JUnit 4, JUnit 5, etc. |
@uglyog it would need to be supplied to the |
I am hoping we can apply this change first to the underlying |
Maybe a better name is |
Pact-JS uses |
It's probably best to support |
As long as it's |
4.1.25 released |
Currently there exist two verification types:
PactVerification.REQUEST_RESPONSE
-- verifies an HTTP response from a requestPactVerification.ANNOTATED_METHOD
-- can be used to verify either an HTTP response, or a message and metadataI would like to propose a third verification type,
PactVerification.FUNCTION
, which would be similar toPactVerification.ANNOTATED_METHOD
except that:String
->Any
(but really, it would return specific types that the library already understands, likeMessageAndMetadata
).ProviderVerifier
instead of via scanning the classpath for annotated methodsjava.lang.reflect.Method.invoke()
), it would just be called normally like any other callback method in theProviderVerifier
. this means the method scope would be the same as any method in the test class instead of having to provide a specific instance for invocation.This could be used for both messages and request/response, although the return types would need to vary depending on the interaction type. Probably the return value can be the same as the return values that are currently supported by the
PactVerification.ANNOTATED_METHOD
type.My guess is the easiest way to implement this is to have another bifurcation in
ProviderVerifier.verifyInteraction
which would call a different method if the verification type isFUNCTION
, for exampleverifyResponseByFunction
, and define a new property on theProviderVerifier
that would contain the available function to call (verificationFunction: Function<String, Any>
, or something like that). There can probably be some refactoring aroundverifyResponseByInvokingProviderMethods
andverifyMessage
to split common functionality into common methods, since mostly the only change is how to call the method and get the return value.The text was updated successfully, but these errors were encountered: