diff --git a/pom.xml b/pom.xml
index 4a8dfec2f3..daadd3ce5f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,7 @@
UTF-8
UTF-8
- 1.1.0-M4
+ 1.1.0-M5
1.1.0
1.7
diff --git a/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptions.groovy b/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptions.groovy
deleted file mode 100644
index 98acc8be3d..0000000000
--- a/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptions.groovy
+++ /dev/null
@@ -1,30 +0,0 @@
-package io.codearte.accurest.maven
-
-import groovy.transform.CompileStatic
-import io.codearte.accurest.stubrunner.StubConfiguration
-import io.codearte.accurest.stubrunner.StubRunnerOptions
-
-@CompileStatic
-public class EnhancedStubRunnerOptions {
-
- @Delegate private final StubRunnerOptions options
- private final Collection dependencies
-
- EnhancedStubRunnerOptions(Collection dependencies, StubRunnerOptions options) {
- this.options = options
- this.dependencies = dependencies
- }
-
- EnhancedStubRunnerOptions(Integer minPortValue, Integer maxPortValue, String stubRepositoryRoot, boolean workOffline, String stubsClassifier, Collection dependencies, StubRunnerOptions options) {
- this.options = new StubRunnerOptions(minPortValue, maxPortValue, stubRepositoryRoot, workOffline, stubsClassifier)
- this.dependencies = dependencies
- }
-
- Collection getDependencies() {
- return dependencies
- }
-
- StubRunnerOptions getStubsRunnerOptions() {
- return options
- }
-}
diff --git a/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptionsBuilder.groovy b/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptionsBuilder.groovy
deleted file mode 100644
index cd68d42ec4..0000000000
--- a/src/main/groovy/io/codearte/accurest/maven/EnhancedStubRunnerOptionsBuilder.groovy
+++ /dev/null
@@ -1,59 +0,0 @@
-package io.codearte.accurest.maven
-
-import groovy.transform.CompileStatic
-import io.codearte.accurest.stubrunner.StubConfiguration
-import io.codearte.accurest.stubrunner.StubRunnerOptions
-import io.codearte.accurest.stubrunner.util.StubsParser
-
-@CompileStatic
-public class EnhancedStubRunnerOptionsBuilder {
-
- private LinkedList stubs = new LinkedList<>()
-
- private final StubRunnerOptions options;
-
- EnhancedStubRunnerOptionsBuilder(StubRunnerOptions options) {
- this.options = options
- }
-
- EnhancedStubRunnerOptionsBuilder(Integer minPortValue, Integer maxPortValue, String stubRepositoryRoot,
- boolean workOffline, String stubsClassifier) {
- this.options = new StubRunnerOptions(minPortValue, maxPortValue, stubRepositoryRoot, workOffline, stubsClassifier)
- }
-
- EnhancedStubRunnerOptionsBuilder withStubs(String stubs) {
- addStub(stubsToList(stubs))
- return this
- }
-
- private Collection buildDependencies() {
- return StubsParser.fromString(stubs, options.getStubsClassifier());
- }
-
- private static List stubsToList(String stubIdsToPortMapping) {
- return stubIdsToPortMapping.split(',').collect { it }
- }
-
- private void addStub(List notations) {
- for (String notation : notations) {
- addStub(notation);
- }
- }
-
- private void addStub(String notation) {
- if (StubsParser.hasPort(notation)) {
- addPort(notation);
- stubs.add(StubsParser.ivyFromStringWithPort(notation));
- } else {
- stubs.add(notation);
- }
- }
-
- private void addPort(String notation) {
- options.putStubIdsToPortMapping(StubsParser.fromStringWithPort(notation));
- }
-
- EnhancedStubRunnerOptions build() {
- return new EnhancedStubRunnerOptions(buildDependencies(), options)
- }
-}
diff --git a/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy b/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy
index b644319285..14c6d710b6 100644
--- a/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy
+++ b/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy
@@ -6,6 +6,7 @@ import io.codearte.accurest.maven.stubrunner.RemoteStubRunner
import io.codearte.accurest.stubrunner.BatchStubRunner
import io.codearte.accurest.stubrunner.StubRunner
import io.codearte.accurest.stubrunner.StubRunnerOptions
+import io.codearte.accurest.stubrunner.StubRunnerOptionsBuilder
import org.apache.maven.execution.MavenSession
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugin.MojoExecutionException
@@ -66,14 +67,14 @@ class RunMojo extends AbstractMojo {
return
}
BatchStubRunner batchStubRunner
+ StubRunnerOptionsBuilder optionsBuilder = new StubRunnerOptionsBuilder()
+ .withStubsClassifier(stubsClassifier)
if (!stubs) {
- StubRunnerOptions options = new StubRunnerOptions(httpPort, httpPort, "", false, stubsClassifier)
+ StubRunnerOptions options = optionsBuilder.withPort(httpPort).build()
StubRunner stubRunner = localStubRunner.run(resolveStubsDirectory().absolutePath, options)
batchStubRunner = new BatchStubRunner(Arrays.asList(stubRunner))
} else {
- EnhancedStubRunnerOptions options = new EnhancedStubRunnerOptionsBuilder(minPort, maxPort, "", false, stubsClassifier)
- .withStubs(stubs)
- .build()
+ StubRunnerOptions options = optionsBuilder.withMinMaxPort(minPort, maxPort).build()
batchStubRunner = remoteStubRunner.run(options, repoSession)
}
diff --git a/src/main/groovy/io/codearte/accurest/maven/stubrunner/RemoteStubRunner.groovy b/src/main/groovy/io/codearte/accurest/maven/stubrunner/RemoteStubRunner.groovy
index de1831bfa3..bb2084ef25 100644
--- a/src/main/groovy/io/codearte/accurest/maven/stubrunner/RemoteStubRunner.groovy
+++ b/src/main/groovy/io/codearte/accurest/maven/stubrunner/RemoteStubRunner.groovy
@@ -2,11 +2,7 @@ package io.codearte.accurest.maven.stubrunner
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
-import io.codearte.accurest.maven.EnhancedStubRunnerOptions
-import io.codearte.accurest.stubrunner.AetherStubDownloader
-import io.codearte.accurest.stubrunner.BatchStubRunner
-import io.codearte.accurest.stubrunner.BatchStubRunnerFactory
-import io.codearte.accurest.stubrunner.RunningStubs
+import io.codearte.accurest.stubrunner.*
import org.eclipse.aether.RepositorySystemSession
import javax.inject.Inject
@@ -24,12 +20,11 @@ class RemoteStubRunner {
this.aetherStubDownloaderFactory = aetherStubDownloaderFactory
}
- BatchStubRunner run(EnhancedStubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
+ BatchStubRunner run(StubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
AetherStubDownloader stubDownloader = aetherStubDownloaderFactory.build(repositorySystemSession)
try {
log.debug("Launching StubRunner with args: $options")
- BatchStubRunner stubRunner = new BatchStubRunnerFactory(options.getStubsRunnerOptions(), options.getDependencies(), stubDownloader)
- .buildBatchStubRunner()
+ BatchStubRunner stubRunner = new BatchStubRunnerFactory(options, stubDownloader).buildBatchStubRunner()
RunningStubs runningCollaborators = stubRunner.runStubs()
log.info(runningCollaborators.toString())
return stubRunner
diff --git a/src/test/java/io/codearte/accurest/maven/EnhancedStubRunnerOptionsTest.java b/src/test/java/io/codearte/accurest/maven/EnhancedStubRunnerOptionsTest.java
deleted file mode 100644
index 0e700200c6..0000000000
--- a/src/test/java/io/codearte/accurest/maven/EnhancedStubRunnerOptionsTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package io.codearte.accurest.maven;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import org.junit.Test;
-
-import io.codearte.accurest.stubrunner.StubRunnerOptions;
-
-public class EnhancedStubRunnerOptionsTest {
-
- private EnhancedStubRunnerOptionsBuilder builder = new EnhancedStubRunnerOptionsBuilder(new StubRunnerOptions());
-
- @Test
- public void shouldAddStubCoordinatesWithPort() throws Exception {
-
- //given
- builder.withStubs("foo:bar:8080");
-
- //when
- EnhancedStubRunnerOptions options = builder.build();
-
- //then
- assertThat(options.getDependencies())
- .hasToString("[foo:bar:+:stubs]");
- assertThat(options.getStubIdsToPortMapping())
- .hasToString("{foo:bar:+:stubs=8080}");
- }
-
- @Test
- public void shouldAddStubCoordinatesWithoutPort() throws Exception {
-
- //given
- builder.withStubs("foo:bar");
-
- //when
- EnhancedStubRunnerOptions options = builder.build();
-
- //then
- assertThat(options.getDependencies())
- .hasToString("[foo:bar:+:stubs]");
- assertThat(options.getStubIdsToPortMapping())
- .hasSize(0);
- }
-
- @Test
- public void shouldAddMultipleStubCoordinates() throws Exception {
-
- //given
- builder.withStubs("foo:bar,bar:foo");
-
- //when
- EnhancedStubRunnerOptions options = builder.build();
-
- //then
- assertThat(options.getDependencies())
- .hasSize(2);
- }
-
- @Test
- public void shouldAddStubCoordinatesWithVersion() throws Exception {
-
- //given
- builder.withStubs("foo:1.2.3:bar");
-
- //when
- EnhancedStubRunnerOptions options = builder.build();
-
- //then
- assertThat(options.getDependencies())
- .hasToString("[foo:1.2.3:bar:stubs]");
- }
-}
\ No newline at end of file