diff --git a/README.adoc b/README.adoc index 68551ca80d..2fef004505 100644 --- a/README.adoc +++ b/README.adoc @@ -1583,7 +1583,7 @@ Spring Boot container if there is one. https://projects.spring.io/spring-restdocs[Spring RestDocs] can be used to generate documentation (e.g. in asciidoctor format) for an -HTTP API with Spring MockMvc or RestEasy. At the same time as you +HTTP API with Spring MockMvc or Rest Assured. At the same time as you generate documentation for your API, you can also generate WireMock stubs, by using Spring Cloud Contract WireMock. Just write your normal RestDocs test cases and use `@AutoConfigureRestDocs` to have stubs diff --git a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRepository.java b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRepository.java index 5ebdaee272..b92923a88e 100644 --- a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRepository.java +++ b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/StubRepository.java @@ -63,8 +63,8 @@ class StubRepository { } this.httpServerStubs = httpServerStubs; this.path = repository; - this.stubs = stubs(); this.options = options; + this.stubs = stubs(); this.contracts = contracts(); } diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRepositorySpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRepositorySpec.groovy index 6e22b79dc0..c8ef417eb1 100644 --- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRepositorySpec.groovy +++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRepositorySpec.groovy @@ -24,7 +24,8 @@ class StubRepositorySpec extends Specification { def 'should retrieve all descriptors for given project'() { given: - StubRepository repository = new StubRepository(REPOSITORY_LOCATION, new StubRunnerOptionsBuilder().build()) + StubRepository repository = new StubRepository(REPOSITORY_LOCATION, + [], new StubRunnerOptionsBuilder().build()) int expectedDescriptorsSize = 8 when: List descriptors = repository.getStubs() @@ -34,7 +35,8 @@ class StubRepositorySpec extends Specification { def 'should return empty list if files are missing'() { given: - StubRepository repository = new StubRepository(new File('src/test/resources/emptyrepo'), new StubRunnerOptionsBuilder().build()) + StubRepository repository = new StubRepository(new File('src/test/resources/emptyrepo'), + [], new StubRunnerOptionsBuilder().build()) when: List descriptors = repository.getStubs() then: @@ -43,7 +45,8 @@ class StubRepositorySpec extends Specification { def 'should throw an exception if directory with mappings is missing'() { when: - new StubRepository(new File('src/test/resources/nonexistingrepo'), new StubRunnerOptionsBuilder().build()) + new StubRepository(new File('src/test/resources/nonexistingrepo'), [], + new StubRunnerOptionsBuilder().build()) then: thrown(IllegalArgumentException) } @@ -51,12 +54,12 @@ class StubRepositorySpec extends Specification { def 'should retrieve only those mappings that contain the consumer name'() { given: StubRepository repository = new StubRepository(REPOSITORY_LOCATION, - new StubRunnerOptionsBuilder() + [], new StubRunnerOptionsBuilder() .withStubPerConsumer(true) .withConsumerName("ping").build()) int expectedDescriptorsSize = 1 when: - List descriptors = repository.getProjectDescriptors() + List descriptors = repository.stubs then: descriptors.size() == expectedDescriptorsSize } diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy index 44a65be11b..fdcfbf5f29 100644 --- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy +++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy @@ -38,7 +38,8 @@ class StubRunnerExecutorSpec extends Specification { def setup() { portScanner = new AvailablePortScanner(MIN_PORT, MAX_PORT) - repository = new StubRepository(new File('src/test/resources/repository'), new StubRunnerOptionsBuilder().build()) + repository = new StubRepository(new File('src/test/resources/repository'), + [], new StubRunnerOptionsBuilder().build()) } def 'should provide URL for given relative path of stub'() { @@ -123,7 +124,7 @@ class StubRunnerExecutorSpec extends Specification { when: executor.runStubs(stubRunnerOptions, new StubRepository(new File('src/test/resources/repository/httpcontract'), - new StubRunnerOptionsBuilder().build()), stubConf) + [], new StubRunnerOptionsBuilder().build()), stubConf) then: !executor.trigger() !executor.trigger("missing", "label") @@ -139,7 +140,7 @@ class StubRunnerExecutorSpec extends Specification { when: RunningStubs stubs = executor.runStubs(stubRunnerOptions, new StubRepository(new File('src/test/resources/emptyrepo'), - new StubRunnerOptionsBuilder().build()), stubConf) + [], new StubRunnerOptionsBuilder().build()), stubConf) then: stubs.getPort('asd') == -1 cleanup: