accurest 1.1.0-M3 and simplified configuration with <extension> (#19)
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -35,7 +35,7 @@
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<accurest.version>1.1.0-M2</accurest.version>
|
||||
<accurest.version>1.1.0-M3</accurest.version>
|
||||
|
||||
<aetherVersion>1.1.0</aetherVersion>
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class ConvertMojo extends AbstractMojo {
|
||||
|
||||
AccurestConfigProperties config = new AccurestConfigProperties()
|
||||
config.contractsDslDir = insideProject ? contractsDirectory : source
|
||||
config.stubsOutputDir = insideProject ? new File(outputDirectory, 'mappings') : destination
|
||||
config.stubsOutputDir = insideProject ? new File(outputDirectory, 'mappings') : destination
|
||||
|
||||
log.info('Converting from accurest contracts written in GroovyDSL to WireMock stubs mappings')
|
||||
log.info(" Accurest contracts directory: ${config.contractsDslDir}")
|
||||
|
||||
@@ -10,11 +10,12 @@ import org.apache.maven.plugin.MojoExecutionException
|
||||
import org.apache.maven.plugin.MojoFailureException
|
||||
import org.apache.maven.plugins.annotations.Mojo
|
||||
import org.apache.maven.plugins.annotations.Parameter
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope
|
||||
import org.eclipse.aether.RepositorySystemSession
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
@Mojo(name = 'run', requiresProject = false)
|
||||
@Mojo(name = 'run', requiresProject = false, requiresDependencyResolution = ResolutionScope.RUNTIME)
|
||||
@CompileStatic
|
||||
class RunMojo extends AbstractMojo {
|
||||
|
||||
|
||||
27
src/main/resources/META-INF/plexus/components.xml
Normal file
27
src/main/resources/META-INF/plexus/components.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.Lifecycle</role>
|
||||
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
|
||||
<role-hint>accurest</role-hint>
|
||||
<configuration>
|
||||
<id>accurest</id>
|
||||
<phases>
|
||||
<phase>accurest-not-used-phase</phase>
|
||||
</phases>
|
||||
<default-phases>
|
||||
<process-test-resources>
|
||||
io.codearte.accurest:accurest-maven-plugin:${project.version}:convert
|
||||
</process-test-resources>
|
||||
<generate-test-sources>
|
||||
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateTests
|
||||
</generate-test-sources>
|
||||
<package>
|
||||
io.codearte.accurest:accurest-maven-plugin:${project.version}:generateStubs
|
||||
</package>
|
||||
</default-phases>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
||||
@@ -57,6 +57,20 @@ public class PluginIT {
|
||||
.assertErrorFreeLog();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_build_project_with_plugin_extension() throws Exception {
|
||||
File basedir = resources.getBasedir("plugin-extension");
|
||||
maven.forProject(basedir)
|
||||
.execute("package")
|
||||
.assertErrorFreeLog()
|
||||
.assertLogText("Generating server tests source code for Accurest contract verification")
|
||||
.assertLogText("Generated 1 test classes.")
|
||||
.assertLogText("Converting from accurest contracts written in GroovyDSL to WireMock stubs mappings")
|
||||
.assertLogText("Creating new json")
|
||||
.assertLogText("Running io.codearte.accurest.tests.AccurestTest")
|
||||
.assertErrorFreeLog();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Ignored, because of bug accurest#245")
|
||||
public void should_build_project_project_with_complex_configuration() throws Exception {
|
||||
|
||||
84
src/test/projects/plugin-extension/pom.xml
Normal file
84
src/test/projects/plugin-extension/pom.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>gs-rest-service</artifactId>
|
||||
<version>0.1.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.3.3.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- accurest test dependencies -->
|
||||
<!-- tag::dependencies[] -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- end::dependencies[] -->
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<accurest-plugin.version>${it-plugin.version}</accurest-plugin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- tag::plugin[] -->
|
||||
<plugin>
|
||||
<groupId>io.codearte.accurest</groupId>
|
||||
<artifactId>accurest-maven-plugin</artifactId>
|
||||
<version>${accurest-plugin.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<baseClassForTests>hello.BaseAccurest</baseClassForTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- end::plugin[] -->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,12 @@
|
||||
package hello;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package hello;
|
||||
|
||||
public class Greeting {
|
||||
|
||||
private final long id;
|
||||
private final String content;
|
||||
|
||||
public Greeting(long id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package hello;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class GreetingController {
|
||||
|
||||
private static final String template = "Hello, %s!";
|
||||
private final AtomicLong counter = new AtomicLong();
|
||||
|
||||
@RequestMapping("/greeting")
|
||||
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
|
||||
return new Greeting(counter.incrementAndGet(),
|
||||
String.format(template, name));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
priority 2
|
||||
request {
|
||||
method 'GET'
|
||||
urlPath('/greeting') {
|
||||
queryParameters {
|
||||
parameter 'name': 'Something'
|
||||
}
|
||||
}
|
||||
headers {
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body(
|
||||
id: 1,
|
||||
content: "Hello, Something!"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
io.codearte.accurest.dsl.GroovyDsl.make {
|
||||
priority 2
|
||||
request {
|
||||
method 'GET'
|
||||
url('/greeting')
|
||||
headers {
|
||||
header 'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
body(
|
||||
id: 1,
|
||||
content: "Hello, World!"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package hello;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import org.junit.Before;
|
||||
|
||||
public class BaseAccurest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
RestAssuredMockMvc.standaloneSetup(new GreetingController());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user