use of au.com.dius.pact.provider.spring.MvcProviderVerifier in project pact-jvm by DiUS.
the class MockMvcTarget method testInteraction.
/**
* {@inheritDoc}
*/
@Override
public void testInteraction(final String consumerName, final Interaction interaction) {
ProviderInfo provider = getProviderInfo();
ConsumerInfo consumer = new ConsumerInfo(consumerName);
provider.setVerificationType(PactVerification.ANNOTATED_METHOD);
MockMvc mockMvc = standaloneSetup(controllers.toArray()).setControllerAdvice(controllerAdvice.toArray()).build();
MvcProviderVerifier verifier = (MvcProviderVerifier) setupVerifier(interaction, provider, consumer);
Map<String, Object> failures = new HashMap<>();
for (int i = 0; i < runTimes; i++) {
verifier.verifyResponseFromProvider(provider, interaction, interaction.getDescription(), failures, mockMvc);
}
try {
if (!failures.isEmpty()) {
verifier.displayFailures(failures);
throw getAssertionError(failures);
}
} finally {
verifier.finialiseReports();
}
}
use of au.com.dius.pact.provider.spring.MvcProviderVerifier in project pact-jvm by DiUS.
the class MockMvcTarget method setupVerifier.
@Override
protected ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
MvcProviderVerifier verifier = new MvcProviderVerifier();
verifier.setDebugRequestResponse(printRequestResponse);
setupReporters(verifier, provider.getName(), interaction.getDescription());
verifier.setProjectClasspath(new MethodClosure(this, "getClassPathUrls"));
verifier.initialiseReporters(provider);
verifier.reportVerificationForConsumer(consumer, provider);
if (interaction.getProviderState() != null) {
verifier.reportStateForInteraction(interaction.getProviderState(), provider, consumer, true);
}
verifier.reportInteractionDescription(interaction);
return verifier;
}
Aggregations