Merge branch '2.0.x'

This commit is contained in:
Andy Wilkinson
2022-01-13 12:37:09 +00:00
19 changed files with 675 additions and 453 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2021 the original author or authors.
* Copyright 2014-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,11 +23,10 @@ import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* Tests for {@link SnippetsDirectoryResolver}.
@@ -39,9 +38,6 @@ public class SnippetsDirectoryResolverTests {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void mavenProjectsUseTargetGeneratedSnippetsRelativeToDocdir() throws IOException {
this.temporaryFolder.newFile("pom.xml");
@@ -57,17 +53,15 @@ public class SnippetsDirectoryResolverTests {
Map<String, Object> attributes = new HashMap<>();
String docdir = new File(this.temporaryFolder.getRoot(), "src/main/asciidoc").getAbsolutePath();
attributes.put("docdir", docdir);
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage(equalTo("pom.xml not found in '" + docdir + "' or above"));
getMavenSnippetsDirectory(attributes);
assertThatIllegalStateException().isThrownBy(() -> getMavenSnippetsDirectory(attributes))
.withMessage("pom.xml not found in '" + docdir + "' or above");
}
@Test
public void illegalStateWhenDocdirAttributeIsNotSetInMavenProject() throws IOException {
Map<String, Object> attributes = new HashMap<>();
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage(equalTo("docdir attribute not found"));
getMavenSnippetsDirectory(attributes);
assertThatIllegalStateException().isThrownBy(() -> getMavenSnippetsDirectory(attributes))
.withMessage("docdir attribute not found");
}
@Test
@@ -100,9 +94,9 @@ public class SnippetsDirectoryResolverTests {
@Test
public void illegalStateWhenGradleProjectdirAndProjectdirAttributesAreNotSetInGradleProject() throws IOException {
Map<String, Object> attributes = new HashMap<>();
this.thrown.expect(IllegalStateException.class);
this.thrown.expectMessage(equalTo("projectdir attribute not found"));
new SnippetsDirectoryResolver().getSnippetsDirectory(attributes);
assertThatIllegalStateException()
.isThrownBy(() -> new SnippetsDirectoryResolver().getSnippetsDirectory(attributes))
.withMessage("projectdir attribute not found");
}
private File getMavenSnippetsDirectory(Map<String, Object> attributes) {