Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Upgrade Spring REST Docs to 2.0.6 (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenz authored Nov 7, 2022
1 parent 9896de3 commit 3028d67
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
Binary file removed lib/spring-restdocs-core-2.0.5.RELEASE-test.jar
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<spring-restdocs.version>2.0.5.RELEASE</spring-restdocs.version>
<spring-restdocs.version>2.0.6.RELEASE</spring-restdocs.version>
<dokka.version>0.10.1</dokka.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Object[]> 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);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -61,18 +60,16 @@
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;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
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;
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions spring-auto-restdocs-docs/contributing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down Expand Up @@ -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]]
Expand Down

0 comments on commit 3028d67

Please sign in to comment.