Skip to content

Commit cc22dbf

Browse files
committed
Merge branch '1.2.x'
2 parents 0801564 + 508b3d6 commit cc22dbf

File tree

192 files changed

+3376
-5462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+3376
-5462
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ configure(codeProjects) {
131131
checkstyle {
132132
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
133133
configProperties = [ 'checkstyle.config.dir' : rootProject.file('config/checkstyle') ]
134-
toolVersion = '6.10.1'
134+
toolVersion = '8.22'
135135
}
136136

137137
configurations {
@@ -270,4 +270,4 @@ configurations {
270270

271271
artifacts {
272272
archives docsZip
273-
}
273+
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version=2.0.4.BUILD-SNAPSHOT
2-
javaFormatVersion=0.0.7-SNAPSHOT
2+
javaFormatVersion=0.0.15
33
org.gradle.daemon=false
44
asciidoctorj15Version=1.5.8.1
55
asciidoctorj16Version=1.6.2

spring-restdocs-asciidoctor-1.5/src/main/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ15Preprocessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ final class DefaultAttributesAsciidoctorJ15Preprocessor extends Preprocessor {
3232

3333
@Override
3434
public PreprocessorReader process(Document document, PreprocessorReader reader) {
35-
document.setAttr("snippets", this.snippetsDirectoryResolver
36-
.getSnippetsDirectory(document.getAttributes()), false);
35+
document.setAttr("snippets", this.snippetsDirectoryResolver.getSnippetsDirectory(document.getAttributes()),
36+
false);
3737
return reader;
3838
}
3939

spring-restdocs-asciidoctor-1.5/src/main/java/org/springframework/restdocs/asciidoctor/RestDocsAsciidoctorJ15ExtensionRegistry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public void register(Asciidoctor asciidoctor) {
3131
if (!asciidoctorJ15()) {
3232
return;
3333
}
34-
asciidoctor.javaExtensionRegistry()
35-
.preprocessor(new DefaultAttributesAsciidoctorJ15Preprocessor());
34+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ15Preprocessor());
3635
asciidoctor.rubyExtensionRegistry()
3736
.loadClass(RestDocsAsciidoctorJ15ExtensionRegistry.class
3837
.getResourceAsStream("/extensions/operation_block_macro.rb"))
@@ -41,8 +40,7 @@ public void register(Asciidoctor asciidoctor) {
4140

4241
private boolean asciidoctorJ15() {
4342
try {
44-
return !Class.forName("org.asciidoctor.extension.JavaExtensionRegistry")
45-
.isInterface();
43+
return !Class.forName("org.asciidoctor.extension.JavaExtensionRegistry").isInterface();
4644
}
4745
catch (Throwable ex) {
4846
return false;

spring-restdocs-asciidoctor-1.5/src/test/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ15PreprocessorTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public class DefaultAttributesAsciidoctorJ15PreprocessorTests {
3434

3535
@Test
3636
public void snippetsAttributeIsSet() {
37-
String converted = createAsciidoctor().convert("{snippets}",
38-
createOptions("projectdir=../../.."));
39-
assertThat(converted)
40-
.contains("build" + File.separatorChar + "generated-snippets");
37+
String converted = createAsciidoctor().convert("{snippets}", createOptions("projectdir=../../.."));
38+
assertThat(converted).contains("build" + File.separatorChar + "generated-snippets");
4139
}
4240

4341
@Test
@@ -62,8 +60,7 @@ private Options createOptions(String attributes) {
6260

6361
private Asciidoctor createAsciidoctor() {
6462
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
65-
asciidoctor.javaExtensionRegistry()
66-
.preprocessor(new DefaultAttributesAsciidoctorJ15Preprocessor());
63+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ15Preprocessor());
6764
return asciidoctor;
6865
}
6966

spring-restdocs-asciidoctor-1.6/src/main/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ16Preprocessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ final class DefaultAttributesAsciidoctorJ16Preprocessor extends Preprocessor {
3232

3333
@Override
3434
public void process(Document document, PreprocessorReader reader) {
35-
document.setAttribute("snippets", this.snippetsDirectoryResolver
36-
.getSnippetsDirectory(document.getAttributes()), false);
35+
document.setAttribute("snippets", this.snippetsDirectoryResolver.getSnippetsDirectory(document.getAttributes()),
36+
false);
3737
}
3838

3939
}

spring-restdocs-asciidoctor-1.6/src/main/java/org/springframework/restdocs/asciidoctor/RestDocsAsciidoctorJ16ExtensionRegistry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public void register(Asciidoctor asciidoctor) {
3131
if (!asciidoctorJ16()) {
3232
return;
3333
}
34-
asciidoctor.javaExtensionRegistry()
35-
.preprocessor(new DefaultAttributesAsciidoctorJ16Preprocessor());
34+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ16Preprocessor());
3635
asciidoctor.rubyExtensionRegistry()
3736
.loadClass(RestDocsAsciidoctorJ16ExtensionRegistry.class
3837
.getResourceAsStream("/extensions/operation_block_macro.rb"))
@@ -41,8 +40,7 @@ public void register(Asciidoctor asciidoctor) {
4140

4241
private boolean asciidoctorJ16() {
4342
try {
44-
return Class.forName("org.asciidoctor.extension.JavaExtensionRegistry")
45-
.isInterface();
43+
return Class.forName("org.asciidoctor.extension.JavaExtensionRegistry").isInterface();
4644
}
4745
catch (Throwable ex) {
4846
return false;

spring-restdocs-asciidoctor-1.6/src/test/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ16PreprocessorTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public class DefaultAttributesAsciidoctorJ16PreprocessorTests {
3434

3535
@Test
3636
public void snippetsAttributeIsSet() {
37-
String converted = createAsciidoctor().convert("{snippets}",
38-
createOptions("projectdir=../../.."));
39-
assertThat(converted)
40-
.contains("build" + File.separatorChar + "generated-snippets");
37+
String converted = createAsciidoctor().convert("{snippets}", createOptions("projectdir=../../.."));
38+
assertThat(converted).contains("build" + File.separatorChar + "generated-snippets");
4139
}
4240

4341
@Test
@@ -62,8 +60,7 @@ private Options createOptions(String attributes) {
6260

6361
private Asciidoctor createAsciidoctor() {
6462
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
65-
asciidoctor.javaExtensionRegistry()
66-
.preprocessor(new DefaultAttributesAsciidoctorJ16Preprocessor());
63+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ16Preprocessor());
6764
return asciidoctor;
6865
}
6966

spring-restdocs-asciidoctor-2.0/src/main/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ20Preprocessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ final class DefaultAttributesAsciidoctorJ20Preprocessor extends Preprocessor {
3232

3333
@Override
3434
public void process(Document document, PreprocessorReader reader) {
35-
document.setAttribute("snippets", this.snippetsDirectoryResolver
36-
.getSnippetsDirectory(document.getAttributes()), false);
35+
document.setAttribute("snippets", this.snippetsDirectoryResolver.getSnippetsDirectory(document.getAttributes()),
36+
false);
3737
}
3838

3939
}

spring-restdocs-asciidoctor-2.0/src/main/java/org/springframework/restdocs/asciidoctor/RestDocsAsciidoctorJ20ExtensionRegistry.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public final class RestDocsAsciidoctorJ20ExtensionRegistry implements ExtensionR
2828

2929
@Override
3030
public void register(Asciidoctor asciidoctor) {
31-
asciidoctor.javaExtensionRegistry()
32-
.preprocessor(new DefaultAttributesAsciidoctorJ20Preprocessor());
31+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ20Preprocessor());
3332
asciidoctor.rubyExtensionRegistry()
3433
.loadClass(RestDocsAsciidoctorJ20ExtensionRegistry.class
3534
.getResourceAsStream("/extensions/operation_block_macro.rb"))

spring-restdocs-asciidoctor-2.0/src/test/java/org/springframework/restdocs/asciidoctor/DefaultAttributesAsciidoctorJ20PreprocessorTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public class DefaultAttributesAsciidoctorJ20PreprocessorTests {
3434

3535
@Test
3636
public void snippetsAttributeIsSet() {
37-
String converted = createAsciidoctor().convert("{snippets}",
38-
createOptions("projectdir=../../.."));
39-
assertThat(converted)
40-
.contains("build" + File.separatorChar + "generated-snippets");
37+
String converted = createAsciidoctor().convert("{snippets}", createOptions("projectdir=../../.."));
38+
assertThat(converted).contains("build" + File.separatorChar + "generated-snippets");
4139
}
4240

4341
@Test
@@ -62,8 +60,7 @@ private Options createOptions(String attributes) {
6260

6361
private Asciidoctor createAsciidoctor() {
6462
Asciidoctor asciidoctor = Asciidoctor.Factory.create();
65-
asciidoctor.javaExtensionRegistry()
66-
.preprocessor(new DefaultAttributesAsciidoctorJ20Preprocessor());
63+
asciidoctor.javaExtensionRegistry().preprocessor(new DefaultAttributesAsciidoctorJ20Preprocessor());
6764
return asciidoctor;
6865
}
6966

spring-restdocs-asciidoctor-support/src/main/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolver.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ File getSnippetsDirectory(Map<String, Object> attributes) {
4141

4242
private File getMavenSnippetsDirectory(Map<String, Object> attributes) {
4343
Path docdir = Paths.get(getRequiredAttribute(attributes, "docdir"));
44-
return new File(docdir.relativize(findPom(docdir).getParent()).toFile(),
45-
"target/generated-snippets");
44+
return new File(docdir.relativize(findPom(docdir).getParent()).toFile(), "target/generated-snippets");
4645
}
4746

4847
private Path findPom(Path docdir) {
@@ -58,18 +57,15 @@ private Path findPom(Path docdir) {
5857
}
5958

6059
private File getGradleSnippetsDirectory(Map<String, Object> attributes) {
61-
return new File(
62-
getRequiredAttribute(attributes, "gradle-projectdir",
63-
() -> getRequiredAttribute(attributes, "projectdir")),
64-
"build/generated-snippets");
60+
return new File(getRequiredAttribute(attributes, "gradle-projectdir",
61+
() -> getRequiredAttribute(attributes, "projectdir")), "build/generated-snippets");
6562
}
6663

6764
private String getRequiredAttribute(Map<String, Object> attributes, String name) {
6865
return getRequiredAttribute(attributes, name, null);
6966
}
7067

71-
private String getRequiredAttribute(Map<String, Object> attributes, String name,
72-
Supplier<String> fallback) {
68+
private String getRequiredAttribute(Map<String, Object> attributes, String name, Supplier<String> fallback) {
7369
String attribute = (String) attributes.get(name);
7470
if (attribute == null || attribute.length() == 0) {
7571
if (fallback != null) {

spring-restdocs-asciidoctor-support/src/test/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolverTests.java

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,49 +43,39 @@ public class SnippetsDirectoryResolverTests {
4343
public ExpectedException thrown = ExpectedException.none();
4444

4545
@Test
46-
public void mavenProjectsUseTargetGeneratedSnippetsRelativeToDocdir()
47-
throws IOException {
46+
public void mavenProjectsUseTargetGeneratedSnippetsRelativeToDocdir() throws IOException {
4847
this.temporaryFolder.newFile("pom.xml");
4948
Map<String, Object> attributes = new HashMap<>();
50-
attributes.put("docdir",
51-
new File(this.temporaryFolder.getRoot(), "src/main/asciidoc")
52-
.getAbsolutePath());
49+
attributes.put("docdir", new File(this.temporaryFolder.getRoot(), "src/main/asciidoc").getAbsolutePath());
5350
File snippetsDirectory = getMavenSnippetsDirectory(attributes);
5451
assertThat(snippetsDirectory).isRelative();
55-
assertThat(snippetsDirectory)
56-
.isEqualTo(new File("../../../target/generated-snippets"));
52+
assertThat(snippetsDirectory).isEqualTo(new File("../../../target/generated-snippets"));
5753
}
5854

5955
@Test
6056
public void illegalStateExceptionWhenMavenPomCannotBeFound() throws IOException {
6157
Map<String, Object> attributes = new HashMap<>();
62-
String docdir = new File(this.temporaryFolder.getRoot(), "src/main/asciidoc")
63-
.getAbsolutePath();
58+
String docdir = new File(this.temporaryFolder.getRoot(), "src/main/asciidoc").getAbsolutePath();
6459
attributes.put("docdir", docdir);
6560
this.thrown.expect(IllegalStateException.class);
66-
this.thrown
67-
.expectMessage(equalTo("pom.xml not found in '" + docdir + "' or above"));
61+
this.thrown.expectMessage(equalTo("pom.xml not found in '" + docdir + "' or above"));
6862
getMavenSnippetsDirectory(attributes);
6963
}
7064

7165
@Test
72-
public void illegalStateWhenDocdirAttributeIsNotSetInMavenProject()
73-
throws IOException {
66+
public void illegalStateWhenDocdirAttributeIsNotSetInMavenProject() throws IOException {
7467
Map<String, Object> attributes = new HashMap<>();
7568
this.thrown.expect(IllegalStateException.class);
7669
this.thrown.expectMessage(equalTo("docdir attribute not found"));
7770
getMavenSnippetsDirectory(attributes);
7871
}
7972

8073
@Test
81-
public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdir()
82-
throws IOException {
74+
public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdir() throws IOException {
8375
Map<String, Object> attributes = new HashMap<>();
8476
attributes.put("gradle-projectdir", "project/dir");
85-
File snippetsDirectory = new SnippetsDirectoryResolver()
86-
.getSnippetsDirectory(attributes);
87-
assertThat(snippetsDirectory)
88-
.isEqualTo(new File("project/dir/build/generated-snippets"));
77+
File snippetsDirectory = new SnippetsDirectoryResolver().getSnippetsDirectory(attributes);
78+
assertThat(snippetsDirectory).isEqualTo(new File("project/dir/build/generated-snippets"));
8979
}
9080

9181
@Test
@@ -94,26 +84,21 @@ public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdirWhenBo
9484
Map<String, Object> attributes = new HashMap<>();
9585
attributes.put("gradle-projectdir", "project/dir");
9686
attributes.put("projectdir", "fallback/dir");
97-
File snippetsDirectory = new SnippetsDirectoryResolver()
98-
.getSnippetsDirectory(attributes);
99-
assertThat(snippetsDirectory)
100-
.isEqualTo(new File("project/dir/build/generated-snippets"));
87+
File snippetsDirectory = new SnippetsDirectoryResolver().getSnippetsDirectory(attributes);
88+
assertThat(snippetsDirectory).isEqualTo(new File("project/dir/build/generated-snippets"));
10189
}
10290

10391
@Test
10492
public void gradleProjectsUseBuildGeneratedSnippetsBeneathProjectdirWhenGradleProjectdirIsNotSet()
10593
throws IOException {
10694
Map<String, Object> attributes = new HashMap<>();
10795
attributes.put("projectdir", "project/dir");
108-
File snippetsDirectory = new SnippetsDirectoryResolver()
109-
.getSnippetsDirectory(attributes);
110-
assertThat(snippetsDirectory)
111-
.isEqualTo(new File("project/dir/build/generated-snippets"));
96+
File snippetsDirectory = new SnippetsDirectoryResolver().getSnippetsDirectory(attributes);
97+
assertThat(snippetsDirectory).isEqualTo(new File("project/dir/build/generated-snippets"));
11298
}
11399

114100
@Test
115-
public void illegalStateWhenGradleProjectdirAndProjectdirAttributesAreNotSetInGradleProject()
116-
throws IOException {
101+
public void illegalStateWhenGradleProjectdirAndProjectdirAttributesAreNotSetInGradleProject() throws IOException {
117102
Map<String, Object> attributes = new HashMap<>();
118103
this.thrown.expect(IllegalStateException.class);
119104
this.thrown.expectMessage(equalTo("projectdir attribute not found"));

0 commit comments

Comments
 (0)