diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7bc0a64d..e0e771be 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -41,10 +41,10 @@ jobs: - name: Prepare dependencies run: | mvn install:install-file \ - -Dfile=lib/spring-restdocs-core-2.0.5.RELEASE-test.jar \ + -Dfile=lib/spring-restdocs-core-2.0.6.RELEASE-test-fixtures.jar \ -DgroupId=org.springframework.restdocs \ -DartifactId=spring-restdocs-core \ - -Dversion=2.0.5.RELEASE \ + -Dversion=2.0.6.RELEASE \ -Dpackaging=jar \ -Dclassifier=test mvn install:install-file \ diff --git a/lib/spring-restdocs-core-2.0.5.RELEASE-test.jar b/lib/spring-restdocs-core-2.0.5.RELEASE-test.jar deleted file mode 100644 index ff9371c4..00000000 Binary files a/lib/spring-restdocs-core-2.0.5.RELEASE-test.jar and /dev/null differ diff --git a/lib/spring-restdocs-core-2.0.6.RELEASE-test-fixtures.jar b/lib/spring-restdocs-core-2.0.6.RELEASE-test-fixtures.jar new file mode 100644 index 00000000..16f82500 Binary files /dev/null and b/lib/spring-restdocs-core-2.0.6.RELEASE-test-fixtures.jar differ diff --git a/pom.xml b/pom.xml index 90df53d9..23c9cd99 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ UTF-8 ${project.build.directory}/generated-snippets - 2.0.5.RELEASE + 2.0.6.RELEASE 0.10.1 diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/AbstractSnippetTests.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/AbstractSnippetTests.java new file mode 100644 index 00000000..645e93d5 --- /dev/null +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/AbstractSnippetTests.java @@ -0,0 +1,62 @@ +/*- + * #%L + * Spring Auto REST Docs Core + * %% + * Copyright (C) 2015 - 2022 Scalable Capital GmbH + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package capital.scalable.restdocs; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Rule; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.springframework.restdocs.templates.TemplateFormat; +import org.springframework.restdocs.templates.TemplateFormats; +import org.springframework.restdocs.testfixtures.GeneratedSnippets; +import org.springframework.restdocs.testfixtures.OperationBuilder; +import org.springframework.restdocs.testfixtures.SnippetConditions; + +@RunWith(Parameterized.class) +public abstract class AbstractSnippetTests { + + protected final TemplateFormat templateFormat; + + @Rule + public GeneratedSnippets generatedSnippets; + + @Rule + public OperationBuilder operationBuilder; + + @Parameters(name = "{0}") + public static List parameters() { + return Arrays.asList(new Object[] { "Asciidoctor", TemplateFormats.asciidoctor() }, + new Object[] { "Markdown", TemplateFormats.markdown() }); + } + + public AbstractSnippetTests(String name, TemplateFormat templateFormat) { + this.generatedSnippets = new GeneratedSnippets(templateFormat); + this.templateFormat = templateFormat; + this.operationBuilder = new OperationBuilder(this.templateFormat); + } + + public SnippetConditions.TableCondition tableWithHeader(String... headers) { + return SnippetConditions.tableWithHeader(this.templateFormat, headers); + } +} + diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java index 5b97f292..161871c2 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/EmbeddedSnippetTest.java @@ -26,6 +26,7 @@ import java.util.List; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.javadoc.JavadocReader; import com.fasterxml.jackson.annotation.JsonAutoDetect; @@ -34,7 +35,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.method.HandlerMethod; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java index b6e91c8c..52e4bf79 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/hypermedia/LinksSnippetTest.java @@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.javadoc.JavadocReader; import com.fasterxml.jackson.annotation.JsonAutoDetect; @@ -32,7 +33,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.method.HandlerMethod; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java index e9f9f788..c919158d 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/AuthorizationSnippetTest.java @@ -22,8 +22,8 @@ import static capital.scalable.restdocs.SnippetRegistry.AUTO_AUTHORIZATION; import static org.assertj.core.api.Assertions.assertThat; +import capital.scalable.restdocs.AbstractSnippetTests; import org.junit.Test; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.templates.TemplateFormat; public class AuthorizationSnippetTest extends AbstractSnippetTests { diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java index e2989267..562b90c6 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/DescriptionSnippetTest.java @@ -24,9 +24,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.javadoc.JavadocReader; import org.junit.Test; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.method.HandlerMethod; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java index da2b2905..1af540aa 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/misc/MethodAndPathSnippetTest.java @@ -23,8 +23,8 @@ import static capital.scalable.restdocs.SnippetRegistry.AUTO_METHOD_PATH; import static org.assertj.core.api.Assertions.assertThat; +import capital.scalable.restdocs.AbstractSnippetTests; import org.junit.Test; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.restdocs.templates.TemplateFormats; import org.springframework.web.method.HandlerMethod; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippetTest.java index c53ebf37..ae08ef83 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonModelAttributeSnippetTest.java @@ -34,6 +34,7 @@ import javax.validation.constraints.Size; import java.util.List; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.jackson.SardObjectMapper; import capital.scalable.restdocs.javadoc.JavadocReader; @@ -47,7 +48,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.bind.annotation.ModelAttribute; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java index b7745978..6f438f83 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonRequestFieldSnippetTest.java @@ -33,6 +33,7 @@ import javax.validation.constraints.Size; import java.util.List; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.jackson.SardObjectMapper; import capital.scalable.restdocs.javadoc.JavadocReader; @@ -45,7 +46,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.bind.annotation.RequestBody; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java index c5ac8c08..900787d4 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/JacksonResponseFieldSnippetTest.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.stream.Stream; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.jackson.SardObjectMapper; import capital.scalable.restdocs.javadoc.JavadocReader; @@ -65,7 +66,6 @@ import org.springframework.hateoas.core.EmbeddedWrapper; import org.springframework.hateoas.core.EmbeddedWrappers; import org.springframework.http.ResponseEntity; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.method.HandlerMethod; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/TableWithPrefixMatcher.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/TableWithPrefixMatcher.java index 294e0b5f..a3abcf53 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/TableWithPrefixMatcher.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/payload/TableWithPrefixMatcher.java @@ -20,7 +20,7 @@ package capital.scalable.restdocs.payload; import org.assertj.core.api.Condition; -import org.springframework.restdocs.test.SnippetConditions.TableCondition; +import org.springframework.restdocs.testfixtures.SnippetConditions.TableCondition; public class TableWithPrefixMatcher extends Condition { diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java index aa0584ff..88e8a5d7 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/PathParametersSnippetTest.java @@ -27,6 +27,7 @@ import java.util.Optional; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.javadoc.JavadocReader; import org.junit.Before; @@ -35,7 +36,6 @@ import org.junit.rules.ExpectedException; import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.bind.annotation.GetMapping; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java index 52603c82..7d9fbd0c 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestHeaderSnippetTest.java @@ -26,6 +26,7 @@ import java.util.Optional; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.javadoc.JavadocReader; import org.junit.Before; @@ -34,7 +35,6 @@ import org.junit.rules.ExpectedException; import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.bind.annotation.RequestHeader; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java index 98664a44..8430346f 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/request/RequestParametersSnippetTest.java @@ -30,6 +30,7 @@ import java.util.Locale; import java.util.Optional; +import capital.scalable.restdocs.AbstractSnippetTests; import capital.scalable.restdocs.constraints.ConstraintReader; import capital.scalable.restdocs.javadoc.JavadocReader; import org.junit.Before; @@ -39,7 +40,6 @@ import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.data.domain.Pageable; -import org.springframework.restdocs.AbstractSnippetTests; import org.springframework.restdocs.snippet.SnippetException; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.web.bind.annotation.RequestParam; diff --git a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java index 0d8a138f..1b01326d 100644 --- a/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java +++ b/spring-auto-restdocs-core/src/test/java/capital/scalable/restdocs/section/SectionSnippetTest.java @@ -43,7 +43,6 @@ import static capital.scalable.restdocs.SnippetRegistry.RESPONSE_HEADERS; import static capital.scalable.restdocs.section.SectionSnippet.SECTION; import static capital.scalable.restdocs.util.FormatUtil.fixLineSeparator; -import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.list; @@ -61,9 +60,7 @@ import capital.scalable.restdocs.i18n.SnippetTranslationResolver; import capital.scalable.restdocs.i18n.TranslationRule; import capital.scalable.restdocs.javadoc.JavadocReader; -import capital.scalable.restdocs.payload.JacksonModelAttributeSnippet; import com.fasterxml.jackson.databind.ObjectMapper; -import org.assertj.core.util.Lists; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -71,8 +68,8 @@ import org.springframework.restdocs.http.HttpDocumentation; import org.springframework.restdocs.templates.TemplateFormat; import org.springframework.restdocs.templates.TemplateFormats; -import org.springframework.restdocs.test.GeneratedSnippets; -import org.springframework.restdocs.test.OperationBuilder; +import org.springframework.restdocs.testfixtures.GeneratedSnippets; +import org.springframework.restdocs.testfixtures.OperationBuilder; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; @@ -81,7 +78,6 @@ import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.annotation.RequestParamMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver; import org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor; import org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor; diff --git a/spring-auto-restdocs-docs/contributing.adoc b/spring-auto-restdocs-docs/contributing.adoc index 078dae95..3ca2c882 100644 --- a/spring-auto-restdocs-docs/contributing.adoc +++ b/spring-auto-restdocs-docs/contributing.adoc @@ -21,7 +21,7 @@ The test JAR is located in the lib folder and can be installed as follows: .Bash [source,bash] ---- -mvn install:install-file -Dfile=lib/spring-restdocs-core-${spring-restdocs.version}-test.jar \ +mvn install:install-file -Dfile=lib/spring-restdocs-core-${spring-restdocs.version}-test-fixtures.jar \ -DgroupId=org.springframework.restdocs -DartifactId=spring-restdocs-core \ -Dversion=${spring-restdocs.version} -Dpackaging=test-jar -Dclassifier=test ---- @@ -76,7 +76,7 @@ git checkout tags/v${spring-restdocs.version} ---- Afterwards the test JAR is located at -`spring-restdocs/spring-restdocs-core/build/libs/spring-restdocs-core-${spring-restdocs.version}-test.jar` +`spring-restdocs/spring-restdocs-core/build/libs/spring-restdocs-core-${spring-restdocs.version}-test-fixtures.jar` and has to be installed with the Maven command shown in the section above. [[contributing-building-dokka-testjar]]