use of au.com.dius.pact.provider.ProviderVerifier in project pact-jvm by DiUS.
the class AmqpTarget method setupVerifier.
protected ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier();
verifier.setProjectClasspath(new MethodClosure(this, "getClassPathUrls"));
setupReporters(verifier, provider.getName(), interaction.getDescription());
verifier.initialiseReporters(provider);
verifier.reportVerificationForConsumer(consumer, provider);
if (interaction.getProviderState() != null) {
verifier.reportStateForInteraction(interaction.getProviderState(), provider, consumer, true);
}
verifier.reportInteractionDescription(interaction);
return verifier;
}
use of au.com.dius.pact.provider.ProviderVerifier in project pact-jvm by DiUS.
the class HttpTarget method setupVerifier.
@Override
protected ProviderVerifier setupVerifier(Interaction interaction, ProviderInfo provider, ConsumerInfo consumer) {
ProviderVerifier verifier = new ProviderVerifier();
setupReporters(verifier, provider.getName(), interaction.getDescription());
verifier.initialiseReporters(provider);
verifier.reportVerificationForConsumer(consumer, provider);
if (interaction.getProviderState() != null) {
verifier.reportStateForInteraction(interaction.getProviderState(), provider, consumer, true);
}
verifier.reportInteractionDescription(interaction);
return verifier;
}
use of au.com.dius.pact.provider.ProviderVerifier in project pact-jvm by DiUS.
the class HttpTarget method testInteraction.
/**
* {@inheritDoc}
*/
@Override
public void testInteraction(final String consumerName, final Interaction interaction) {
ProviderInfo provider = getProviderInfo();
ConsumerInfo consumer = new ConsumerInfo(consumerName);
ProviderVerifier verifier = setupVerifier(interaction, provider, consumer);
Map<String, Object> failures = new HashMap<>();
verifier.verifyResponseFromProvider(provider, interaction, interaction.getDescription(), failures);
try {
if (!failures.isEmpty()) {
verifier.displayFailures(failures);
throw getAssertionError(failures);
}
} finally {
verifier.finialiseReports();
}
}
use of au.com.dius.pact.provider.ProviderVerifier in project pact-jvm by DiUS.
the class AmqpTarget method testInteraction.
/**
* {@inheritDoc}
*/
@Override
public void testInteraction(final String consumerName, final Interaction interaction) {
ProviderInfo provider = getProviderInfo();
ConsumerInfo consumer = new ConsumerInfo(consumerName);
ProviderVerifier verifier = setupVerifier(interaction, provider, consumer);
Map<String, Object> failures = new HashMap<>();
verifier.verifyResponseByInvokingProviderMethods(provider, consumer, interaction, interaction.getDescription(), failures);
try {
if (!failures.isEmpty()) {
verifier.displayFailures(failures);
throw getAssertionError(failures);
}
} finally {
verifier.finialiseReports();
}
}
use of au.com.dius.pact.provider.ProviderVerifier in project pact-jvm by DiUS.
the class BaseTarget method setupReporters.
protected void setupReporters(ProviderVerifier verifier, String name, String description) {
String reportDirectory = "target/pact/reports";
String[] reports = new String[] {};
boolean reportingEnabled = false;
VerificationReports verificationReports = testClass.getAnnotation(VerificationReports.class);
if (verificationReports != null) {
reportingEnabled = true;
reportDirectory = verificationReports.reportDir();
reports = verificationReports.value();
} else if (valueResolver.propertyDefined("pact.verification.reports")) {
reportingEnabled = true;
reportDirectory = valueResolver.resolveValue("pact.verification.reportDir:" + reportDirectory);
reports = valueResolver.resolveValue("pact.verification.reports:").split(",");
}
if (reportingEnabled) {
File reportDir = new File(reportDirectory);
reportDir.mkdirs();
verifier.setReporters(Seq.of(reports).filter(r -> !r.isEmpty()).map(r -> {
VerifierReporter reporter = ReporterManager.createReporter(r.trim());
reporter.setReportDir(reportDir);
reporter.setReportFile(new File(reportDir, name + " - " + description + reporter.getExt()));
return reporter;
}).toList());
}
}
Aggregations