From 80ee8afef7206f74a4fd99a889f79ccd766613cb Mon Sep 17 00:00:00 2001 From: Mariusz Smykula Date: Sat, 2 Apr 2016 01:01:32 +0200 Subject: [PATCH] tests for convert goal --- .../accurest/maven/PluginIntegrationTest.java | 39 +++---- .../accurest/maven/PluginUnitTest.java | 1 + .../projects/basic-with-execution/pom.xml | 103 ------------------ .../contracts => pomless}/Sample.groovy | 0 4 files changed, 21 insertions(+), 122 deletions(-) delete mode 100644 maven-plugin/src/test/projects/basic-with-execution/pom.xml rename maven-plugin/src/test/projects/{basic-with-execution/src/test/resources/contracts => pomless}/Sample.groovy (100%) diff --git a/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java b/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java index 9cb929fd10..40bd3f697d 100644 --- a/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java +++ b/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginIntegrationTest.java @@ -6,6 +6,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import io.takari.maven.testing.TestProperties; import io.takari.maven.testing.TestResources; import io.takari.maven.testing.executor.MavenRuntime; import io.takari.maven.testing.executor.MavenVersions; @@ -18,6 +19,8 @@ public class PluginIntegrationTest { @Rule public final TestResources resources = new TestResources(); + private final TestProperties properties = new TestProperties(); + private final MavenRuntime maven; public PluginIntegrationTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exception { @@ -25,29 +28,27 @@ public class PluginIntegrationTest { } @Test - public void shouldCreateStubs() throws Exception { - File basedir = resources.getBasedir("basic-with-execution"); - maven.forProject(basedir) - .withCliOption("-X") - .execute("package") - .assertLogText("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion"); - } - - @Test - public void shouldCreateSpecs() throws Exception { - File basedir = resources.getBasedir("basic-with-execution"); - maven.forProject(basedir) - .execute("package") - .assertLogText("Accurest Plugin: Invoking test sources generation"); - } - - @Test - public void shouldBuildAndTestSimpleBootProject() throws Exception { + public void shouldBuildSimpleBootWIthAccurtesProject() throws Exception { File basedir = resources.getBasedir("bootSimple"); maven.forProject(basedir) .execute("package") .assertErrorFreeLog() .assertLogText("Accurest Plugin: Invoking test sources generation") - .assertLogText("Generated 1 test classes."); + .assertLogText("Generated 1 test classes.") + .assertLogText("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion") + .assertLogText("Creating new json") + .assertErrorFreeLog(); + } + + @Test + public void shouldConvertAccurestToWireMockStubs() throws Exception { + File basedir = resources.getBasedir("pomless"); + properties.getPluginVersion(); + maven.forProject(basedir) + .withCliOption("-X") + .execute(String.format("io.codearte.accurest:accurest-maven-plugin:%s:convert", properties.getPluginVersion())) + .assertLogText("Converting from accurest contracts written in GroovyDSL to WireMock stubs mappings") + .assertLogText("Creating new json") + .assertErrorFreeLog(); } } \ No newline at end of file diff --git a/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginUnitTest.java b/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginUnitTest.java index 71ed604edf..864b844cd8 100644 --- a/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginUnitTest.java +++ b/maven-plugin/src/test/java/io/codearte/accurest/maven/PluginUnitTest.java @@ -46,4 +46,5 @@ public class PluginUnitTest { assertFilesPresent(basedir, "target/generated-test-sources/accurest/io/codearte/accurest/tests/AccurestSpec.groovy"); } + } diff --git a/maven-plugin/src/test/projects/basic-with-execution/pom.xml b/maven-plugin/src/test/projects/basic-with-execution/pom.xml deleted file mode 100644 index 40d5b17c72..0000000000 --- a/maven-plugin/src/test/projects/basic-with-execution/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - 4.0.0 - - io.codearte.accurest.sample - sample-project - 0.1 - - - - - org.spockframework - spock-core - 1.0-groovy-2.4 - test - - - com.jayway.restassured - rest-assured - 2.9.0 - test - - - com.jayway.restassured - spring-mock-mvc - 2.9.0 - test - - - com.github.tomakehurst - wiremock - 2.0.4-beta - test - - - com.toomuchcoding.jsonassert - jsonassert - 0.2.2 - test - - - org.assertj - assertj-core - 2.3.0 - - - - - - - io.codearte.accurest - accurest-maven-plugin - ${it-plugin.version} - - - - generateStubs - generateSpecs - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - 1.5 - - - - testCompile - - - - - - - ${project.basedir}/src/test/groovy - - **/*.groovy - - - - ${project.build.directory}/generated-test-sources/accurest - - **/*.groovy - - - - - - - maven-surefire-plugin - 2.19 - - - **/*Spec.java - - - - - - \ No newline at end of file diff --git a/maven-plugin/src/test/projects/basic-with-execution/src/test/resources/contracts/Sample.groovy b/maven-plugin/src/test/projects/pomless/Sample.groovy similarity index 100% rename from maven-plugin/src/test/projects/basic-with-execution/src/test/resources/contracts/Sample.groovy rename to maven-plugin/src/test/projects/pomless/Sample.groovy