From 177ef1ddbbbccbb4b391220eeda2a2a2a97b54c5 Mon Sep 17 00:00:00 2001 From: Mariusz Smykula Date: Fri, 1 Apr 2016 21:36:52 +0200 Subject: [PATCH] target framework and mode support --- .../accurest/maven/GenerateSpecsMojo.java | 18 ++++++++++++++---- .../accurest/maven/GenerateStubsMojo.java | 8 +++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java b/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java index 0634c94508..2e5ed587c5 100644 --- a/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java +++ b/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateSpecsMojo.java @@ -14,6 +14,8 @@ import org.apache.maven.plugins.annotations.Parameter; import io.codearte.accurest.AccurestException; import io.codearte.accurest.TestGenerator; import io.codearte.accurest.config.AccurestConfigProperties; +import io.codearte.accurest.config.TestFramework; +import io.codearte.accurest.config.TestMode; @Mojo(name = "generateSpecs", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES) public class GenerateSpecsMojo extends AbstractMojo { @@ -24,18 +26,24 @@ public class GenerateSpecsMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}", readonly = true) private File projectBuildDirectory; - @Parameter(property = "contractsDir", defaultValue = "/src/test/resources/contracts") + @Parameter(defaultValue = "/src/test/resources/contracts") private String contractsDir; - @Parameter(property = "generatedTestSourcesDir", defaultValue = "/generated-test-sources/accurest") + @Parameter(defaultValue = "/generated-test-sources/accurest") private String generatedTestSourcesDir; - @Parameter(property = "basePackageForTests", defaultValue = "io.codearte.accurest.tests") + @Parameter(defaultValue = "io.codearte.accurest.tests") private String basePackageForTests; - @Parameter(property = "baseClassForTests") + @Parameter private String baseClassForTests; + @Parameter(defaultValue = "SPOCK") + private TestFramework targetFramework; + + @Parameter(defaultValue = "MOCKMVC") + private TestMode testMode; + public GenerateSpecsMojo() { } @@ -46,6 +54,8 @@ public class GenerateSpecsMojo extends AbstractMojo { config.setBasePackageForTests(basePackageForTests); config.setGeneratedTestSourcesDir(new File(projectBuildDirectory, generatedTestSourcesDir)); config.setBaseClassForTests(baseClassForTests); + config.setTargetFramework(targetFramework); + config.setTestMode(testMode); getLog().info("Accurest Plugin: Invoking test sources generation"); getLog().info(format("Using %s as test source directory", config.getGeneratedTestSourcesDir())); diff --git a/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateStubsMojo.java b/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateStubsMojo.java index 608cb18d3b..603f23120f 100644 --- a/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateStubsMojo.java +++ b/maven-plugin/src/main/java/io/codearte/accurest/maven/GenerateStubsMojo.java @@ -1,5 +1,7 @@ package io.codearte.accurest.maven; +import static java.lang.String.format; + import java.io.File; import org.apache.maven.plugin.AbstractMojo; @@ -22,10 +24,10 @@ public class GenerateStubsMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}", readonly = true) private File projectBuildDirectory; - @Parameter(property = "contractsDir", defaultValue = "/src/test/resources/contracts") + @Parameter(defaultValue = "/src/test/resources/contracts") private String contractsDir; - @Parameter(property = "mappingsDir", defaultValue = "mappings") + @Parameter(defaultValue = "mappings") private String mappingsDir; public void execute() throws MojoExecutionException, MojoFailureException { @@ -34,7 +36,7 @@ public class GenerateStubsMojo extends AbstractMojo { config.setStubsOutputDir(new File(projectBuildDirectory, mappingsDir)); getLog().info("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion"); - getLog().info(String.format("From '%s' to '%s'", config.getContractsDslDir(), config.getStubsOutputDir())); + getLog().info(format("From '%s' to '%s'", config.getContractsDslDir(), config.getStubsOutputDir())); RecursiveFilesConverter converter = new RecursiveFilesConverter(new DslToWireMockClientConverter(), config); converter.processFiles();