Search in sources :

Example 1 with VerifierReporter

use of au.com.dius.pact.provider.reporters.VerifierReporter 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());
    }
}
Also used : SystemPropertyResolver(au.com.dius.pact.provider.junit.sysprops.SystemPropertyResolver) ConsumerInfo(au.com.dius.pact.provider.ConsumerInfo) ValueResolver(au.com.dius.pact.provider.junit.sysprops.ValueResolver) Interaction(au.com.dius.pact.model.Interaction) Seq(org.jooq.lambda.Seq) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) File(java.io.File) Tuple2(org.jooq.lambda.tuple.Tuple2) ProviderVerifier(au.com.dius.pact.provider.ProviderVerifier) TestClass(org.junit.runners.model.TestClass) ProviderInfo(au.com.dius.pact.provider.ProviderInfo) Map(java.util.Map) Optional(java.util.Optional) VerifierReporter(au.com.dius.pact.provider.reporters.VerifierReporter) VerificationReports(au.com.dius.pact.provider.junit.VerificationReports) ReporterManager(au.com.dius.pact.provider.reporters.ReporterManager) VerificationReports(au.com.dius.pact.provider.junit.VerificationReports) VerifierReporter(au.com.dius.pact.provider.reporters.VerifierReporter) File(java.io.File)

Aggregations

Interaction (au.com.dius.pact.model.Interaction)1 ConsumerInfo (au.com.dius.pact.provider.ConsumerInfo)1 ProviderInfo (au.com.dius.pact.provider.ProviderInfo)1 ProviderVerifier (au.com.dius.pact.provider.ProviderVerifier)1 VerificationReports (au.com.dius.pact.provider.junit.VerificationReports)1 SystemPropertyResolver (au.com.dius.pact.provider.junit.sysprops.SystemPropertyResolver)1 ValueResolver (au.com.dius.pact.provider.junit.sysprops.ValueResolver)1 ReporterManager (au.com.dius.pact.provider.reporters.ReporterManager)1 VerifierReporter (au.com.dius.pact.provider.reporters.VerifierReporter)1 File (java.io.File)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Seq (org.jooq.lambda.Seq)1 Tuple2 (org.jooq.lambda.tuple.Tuple2)1 TestClass (org.junit.runners.model.TestClass)1