Feature/one module project
* project refactor * switch to beta classifier for auto builds
This commit is contained in:
68
src/test/java/io/codearte/accurest/maven/PluginIT.java
Normal file
68
src/test/java/io/codearte/accurest/maven/PluginIT.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package io.codearte.accurest.maven;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
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;
|
||||
import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
|
||||
|
||||
@RunWith(MavenJUnitTestRunner.class)
|
||||
@MavenVersions({ "3.3.3" })
|
||||
public class PluginIT {
|
||||
|
||||
@Rule
|
||||
public final TestResources resources = new TestResources();
|
||||
|
||||
private final TestProperties properties = new TestProperties();
|
||||
|
||||
private final MavenRuntime maven;
|
||||
|
||||
public PluginIT(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exception {
|
||||
this.maven = mavenBuilder.withCliOptions("-B", "-U").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_project_Spring_Boot_Groovy_with_Accurest() throws Exception {
|
||||
File basedir = resources.getBasedir("spring-boot-groovy");
|
||||
maven.forProject(basedir)
|
||||
.execute("package")
|
||||
.assertErrorFreeLog()
|
||||
.assertLogText("Generating server tests source code for Accurest contract verification")
|
||||
.assertLogText("Generated 1 test classes.")
|
||||
.assertLogText("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion")
|
||||
.assertLogText("Creating new json")
|
||||
.assertErrorFreeLog();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_project_Spring_Boot_Java_with_Accurest() throws Exception {
|
||||
File basedir = resources.getBasedir("spring-boot-java");
|
||||
maven.forProject(basedir)
|
||||
.execute("package")
|
||||
.assertErrorFreeLog()
|
||||
.assertLogText("Generating server tests source code for Accurest contract verification")
|
||||
.assertLogText("Generated 1 test classes.")
|
||||
.assertLogText("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion")
|
||||
.assertLogText("Creating new json")
|
||||
.assertErrorFreeLog();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_convert_Accurest_Contracts_to_WireMock_Stubs_mappings() 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();
|
||||
}
|
||||
}
|
||||
59
src/test/java/io/codearte/accurest/maven/PluginUnitTest.java
Normal file
59
src/test/java/io/codearte/accurest/maven/PluginUnitTest.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package io.codearte.accurest.maven;
|
||||
|
||||
import static io.takari.maven.testing.TestMavenRuntime.newParameter;
|
||||
import static io.takari.maven.testing.TestResources.assertFilesPresent;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.takari.maven.testing.TestMavenRuntime;
|
||||
import io.takari.maven.testing.TestResources;
|
||||
|
||||
public class PluginUnitTest {
|
||||
|
||||
@Rule
|
||||
public final TestResources resources = new TestResources();
|
||||
|
||||
@Rule
|
||||
public final TestMavenRuntime maven = new TestMavenRuntime();
|
||||
|
||||
@Test
|
||||
public void shouldGenerateWireMockStubsInDefaultLocation() throws Exception {
|
||||
File basedir = resources.getBasedir("basic");
|
||||
maven.executeMojo(basedir, "generateStubs");
|
||||
assertFilesPresent(basedir, "target/mappings/Sample.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateWireMockFromStubsDirectory() throws Exception {
|
||||
File basedir = resources.getBasedir("withStubs");
|
||||
maven.executeMojo(basedir, "generateStubs", newParameter("contractsDir", "/src/test/resources/stubs"));
|
||||
assertFilesPresent(basedir, "target/mappings/Sample.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateWireMockStubsInSelectedLocation() throws Exception {
|
||||
File basedir = resources.getBasedir("basic");
|
||||
maven.executeMojo(basedir, "generateStubs", newParameter("mappingsDir", "foo"));
|
||||
assertFilesPresent(basedir, "target/foo/Sample.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateContractSpecificationInDefaultLocation() throws Exception {
|
||||
File basedir = resources.getBasedir("basic");
|
||||
maven.executeMojo(basedir, "generateTests", newParameter("testFramework", "SPOCK"));
|
||||
assertFilesPresent(basedir,
|
||||
"target/generated-test-sources/accurest/io/codearte/accurest/tests/AccurestSpec.groovy");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGenerateContractTestsInDefaultLocation() throws Exception {
|
||||
File basedir = resources.getBasedir("basic");
|
||||
maven.executeMojo(basedir, "generateTests");
|
||||
assertFilesPresent(basedir,
|
||||
"target/generated-test-sources/accurest/io/codearte/accurest/tests/AccurestTest.java");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user