From 1778c150934536a8b04ac8195d5faa129e2a15fc Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sat, 17 Jun 2023 22:13:55 +0200 Subject: [PATCH] Formatting and Java 11 refactors * Removed custom 'map()' constructors * Several minor refactors * Add unit testing for AsciidoctorHelper * Removed 'public' modifiers from tests * Deleted unused class AsciidoctorConversionException * Removed unused 'sourceDirectory' from MemoryLogHandler --- .../site/AsciidoctorConverterDoxiaParser.java | 2 +- .../AsciidoctorConverterDoxiaParserTest.java | 22 ++-- .../maven/commons/AsciidoctorHelper.java | 1 - .../log/AsciidoctorConversionException.java | 13 --- .../maven/log/MemoryLogHandler.java | 45 ++++---- .../maven/commons/AsciidoctorHelperTest.java | 43 +++++++ .../maven/commons/StringUtilsTest.java | 2 +- .../maven/log/LogRecordFormatterTest.java | 18 +-- ...SiteConversionConfigurationParserTest.java | 41 ++++--- .../site/SiteLogHandlerDeserializerTest.java | 24 ++-- .../asciidoctor/maven/AsciidoctorMojo.java | 2 +- .../maven/AsciidoctorHttpMojoTest.java | 13 +-- .../maven/AsciidoctorIntegrationTest.java | 63 +++++----- .../maven/AsciidoctorMojoExtensionsTest.java | 65 +++++------ .../maven/AsciidoctorMojoLogHandlerTest.java | 35 ++---- .../maven/AsciidoctorMojoTest.java | 108 +++++++++--------- .../maven/AsciidoctorRefreshMojoTest.java | 38 +++--- .../maven/AsciidoctorZipMojoTest.java | 8 +- .../maven/SourceDirectoryFinderTest.java | 24 ++-- .../java/org/asciidoctor/maven/TestUtils.java | 34 ++---- .../AsciidoctorJExtensionRegistryTest.java | 2 +- .../maven/http/AsciidoctorHttpServerTest.java | 18 +-- .../io/StringsCollectionsInputStream.java | 4 +- .../asciidoctor/maven/io/TestFilesHelper.java | 3 +- .../process/CopyResourcesProcessorTest.java | 1 - .../process/SourceDocumentFinderTest.java | 20 ++-- ...CopyFileAlterationListenerAdaptorTest.java | 11 +- .../refresh/ResourcesPatternBuilderTest.java | 9 +- .../processors/AutoregisteredProcessor.java | 9 +- .../ChangeAttributeValuePreprocessor.java | 12 +- .../test/processors/DummyPostprocessor.java | 10 +- .../test/processors/DummyTreeprocessor.java | 14 +-- .../test/processors/FailingPreprocessor.java | 5 +- .../processors/GistBlockMacroProcessor.java | 13 +-- .../ManpageInlineMacroProcessor.java | 3 +- .../test/processors/MetaDocinfoProcessor.java | 10 +- .../RequireCheckerTreeprocessor.java | 3 +- .../test/processors/UriIncludeProcessor.java | 48 +++----- .../test/processors/YellBlockProcessor.java | 26 ++--- .../site/ast/AsciidoctorAstDoxiaParser.java | 2 +- .../ast/AsciidoctorAstDoxiaParserTest.java | 14 +-- .../maven/site/ast/NodeSinkerTest.java | 2 +- .../processors/DocumentNodeProcessorTest.java | 2 +- .../processors/ImageNodeProcessorTest.java | 2 +- .../processors/ListItemNodeProcessorTest.java | 2 +- .../processors/ListingNodeProcessorTest.java | 2 +- .../processors/LiteralNodeProcessorTest.java | 2 +- .../OrderedListNodeProcessorTest.java | 2 +- .../ParagraphNodeProcessorTest.java | 2 +- .../processors/PreambleNodeProcessorTest.java | 2 +- .../processors/SectionNodeProcessorTest.java | 2 +- .../processors/TableNodeProcessorTest.java | 2 +- .../UnorderedListNodeProcessorTest.java | 2 +- 53 files changed, 398 insertions(+), 464 deletions(-) delete mode 100644 asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/AsciidoctorConversionException.java create mode 100644 asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/AsciidoctorHelperTest.java diff --git a/asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParser.java b/asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParser.java index 3c34fe75..98b301e3 100644 --- a/asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParser.java +++ b/asciidoctor-converter-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParser.java @@ -90,7 +90,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept private MemoryLogHandler asciidoctorLoggingSetup(Asciidoctor asciidoctor, LogHandler logHandler, File siteDirectory) { - final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), siteDirectory, + final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory))); asciidoctor.registerLogHandler(memoryLogHandler); // disable default console output of AsciidoctorJ diff --git a/asciidoctor-converter-doxia-module/src/test/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParserTest.java b/asciidoctor-converter-doxia-module/src/test/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParserTest.java index 32ccedd2..c219536a 100644 --- a/asciidoctor-converter-doxia-module/src/test/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParserTest.java +++ b/asciidoctor-converter-doxia-module/src/test/java/org/asciidoctor/maven/site/AsciidoctorConverterDoxiaParserTest.java @@ -17,12 +17,12 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -public class AsciidoctorConverterDoxiaParserTest { +class AsciidoctorConverterDoxiaParserTest { private static final String TEST_DOCS_PATH = "src/test/resources/"; @Test - public void should_convert_html_without_any_configuration() throws FileNotFoundException, ParseException { + void should_convert_html_without_any_configuration() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); final Sink sink = createSinkMock(); @@ -39,7 +39,7 @@ public void should_convert_html_without_any_configuration() throws FileNotFoundE } @Test - public void should_convert_html_with_an_attribute() throws FileNotFoundException, ParseException { + void should_convert_html_with_an_attribute() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); Reader reader = new FileReader(srcAsciidoc); @@ -60,7 +60,7 @@ public void should_convert_html_with_an_attribute() throws FileNotFoundException } @Test - public void should_convert_html_with_baseDir_option() throws FileNotFoundException, ParseException { + void should_convert_html_with_baseDir_option() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "main-document.adoc"); final Sink sink = createSinkMock(); @@ -80,7 +80,7 @@ public void should_convert_html_with_baseDir_option() throws FileNotFoundExcepti } @Test - public void should_convert_html_with_relative_baseDir_option() throws FileNotFoundException, ParseException { + void should_convert_html_with_relative_baseDir_option() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "main-document.adoc"); final Sink sink = createSinkMock(); @@ -100,7 +100,7 @@ public void should_convert_html_with_relative_baseDir_option() throws FileNotFou } @Test - public void should_convert_html_with_templateDir_option() throws FileNotFoundException, ParseException { + void should_convert_html_with_templateDir_option() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); final Sink sink = createSinkMock(); @@ -121,7 +121,7 @@ public void should_convert_html_with_templateDir_option() throws FileNotFoundExc } @Test - public void should_convert_html_with_attributes_and_baseDir_option() throws FileNotFoundException, ParseException { + void should_convert_html_with_attributes_and_baseDir_option() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "main-document.adoc"); final Sink sink = createSinkMock(); @@ -149,7 +149,7 @@ public void should_convert_html_with_attributes_and_baseDir_option() throws File } @Test - public void should_process_empty_selfclosing_XML_attributes() throws FileNotFoundException, ParseException { + void should_process_empty_selfclosing_XML_attributes() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); final Sink sink = createSinkMock(); @@ -170,7 +170,7 @@ public void should_process_empty_selfclosing_XML_attributes() throws FileNotFoun } @Test - public void should_process_empty_value_XML_attributes() throws FileNotFoundException, ParseException { + void should_process_empty_value_XML_attributes() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); final Sink sink = createSinkMock(); @@ -191,7 +191,7 @@ public void should_process_empty_value_XML_attributes() throws FileNotFoundExcep } @Test - public void should_fail_when_logHandler_failIf_is_WARNING() { + void should_fail_when_logHandler_failIf_is_WARNING() { final File srcAsciidoc = new File(TEST_DOCS_PATH, "errors/document-with-missing-include.adoc"); final Sink sink = createSinkMock(); @@ -243,7 +243,7 @@ private Sink createSinkMock() { } class TextProviderSink extends AbstractTextSink { - public String text; + String text; @Override public void rawText(String text) { diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/commons/AsciidoctorHelper.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/commons/AsciidoctorHelper.java index 8f6588c8..8ae820e9 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/commons/AsciidoctorHelper.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/commons/AsciidoctorHelper.java @@ -66,5 +66,4 @@ else if (value instanceof Boolean) { attributesBuilder.attribute(attribute, value); } } - } diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/AsciidoctorConversionException.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/AsciidoctorConversionException.java deleted file mode 100644 index 1ba97425..00000000 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/AsciidoctorConversionException.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.asciidoctor.maven.log; - -import org.asciidoctor.log.LogRecord; - -public class AsciidoctorConversionException extends Exception { - - private final LogRecord logRecord; - - public AsciidoctorConversionException(String message, LogRecord logRecord) { - super(message); - this.logRecord = logRecord; - } -} diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/MemoryLogHandler.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/MemoryLogHandler.java index 965fc245..97ed6d1b 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/MemoryLogHandler.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/MemoryLogHandler.java @@ -4,10 +4,10 @@ import org.asciidoctor.log.LogRecord; import org.asciidoctor.log.Severity; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; /** @@ -20,12 +20,10 @@ public class MemoryLogHandler implements LogHandler { final List records = new ArrayList<>(); private final Boolean outputToConsole; - private final File sourceDirectory; private final Consumer recordConsumer; - public MemoryLogHandler(Boolean outputToConsole, File sourceDirectory, Consumer recordConsumer) { + public MemoryLogHandler(Boolean outputToConsole, Consumer recordConsumer) { this.outputToConsole = outputToConsole == null ? Boolean.FALSE : outputToConsole; - this.sourceDirectory = sourceDirectory; this.recordConsumer = recordConsumer; } @@ -43,17 +41,13 @@ public void clear() { /** * Returns LogRecords that are equal or above the severity level. * - * @param severity Asciidoctor severity level + * @param severity Asciidoctor's severity level * @return list of filtered logRecords */ public List filter(Severity severity) { - // FIXME: find better name or replace with stream - final List records = new ArrayList<>(); - for (LogRecord record : this.records) { - if (record.getSeverity().ordinal() >= severity.ordinal()) - records.add(record); - } - return records; + return this.records.stream() + .filter(record -> severityIsHigher(record, severity)) + .collect(Collectors.toList()); } /** @@ -63,28 +57,29 @@ public List filter(Severity severity) { * @return list of filtered logRecords */ public List filter(String text) { - final List records = new ArrayList<>(); - for (LogRecord record : this.records) { - if (record.getMessage().contains(text)) - records.add(record); - } - return records; + return this.records.stream() + .filter(record -> messageContains(record, text)) + .collect(Collectors.toList()); } /** * Returns LogRecords that are equal or above the severity level and whose message contains text. * - * @param severity Asciidoctor severity level + * @param severity Asciidoctor's severity level * @param text text to search for in the LogRecords * @return list of filtered logRecords */ public List filter(Severity severity, String text) { - final List records = new ArrayList<>(); - for (LogRecord record : this.records) { - if (record.getSeverity().ordinal() >= severity.ordinal() && record.getMessage().contains(text)) - records.add(record); - } - return records; + return this.records.stream() + .filter(record -> severityIsHigher(record, severity) && messageContains(record, text)) + .collect(Collectors.toList()); } + private static boolean severityIsHigher(LogRecord record, Severity severity) { + return record.getSeverity().ordinal() >= severity.ordinal(); + } + + private static boolean messageContains(LogRecord record, String text) { + return record.getMessage().contains(text); + } } diff --git a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/AsciidoctorHelperTest.java b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/AsciidoctorHelperTest.java new file mode 100644 index 00000000..3b34126c --- /dev/null +++ b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/AsciidoctorHelperTest.java @@ -0,0 +1,43 @@ +package org.asciidoctor.maven.commons; + +import org.asciidoctor.Attributes; +import org.asciidoctor.AttributesBuilder; +import org.assertj.core.data.MapEntry; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import static org.asciidoctor.maven.commons.AsciidoctorHelper.addAttributes; +import static org.assertj.core.api.Assertions.assertThat; + +public class AsciidoctorHelperTest { + + @ParameterizedTest + @MethodSource("specialAttributes") + void should_add_attributes_with_special_values(Object actual, String expected) { + final Map attributes = new HashMap<>(); + attributes.put("toc", actual); + final AttributesBuilder attributesBuilder = Attributes.builder(); + + addAttributes(attributes, attributesBuilder); + + var attributesAsMap = attributesBuilder.build().map(); + assertThat(attributesAsMap) + .containsExactly(MapEntry.entry("toc", expected)); + } + + private static Stream specialAttributes() { + return Stream.of( + Arguments.of(null, ""), + Arguments.of("", ""), + Arguments.of("true", ""), + Arguments.of("false", null), + Arguments.of(true, ""), + Arguments.of(false, null) + ); + } +} diff --git a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/StringUtilsTest.java b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/StringUtilsTest.java index 4af799e8..4513c3b0 100644 --- a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/StringUtilsTest.java +++ b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/commons/StringUtilsTest.java @@ -7,7 +7,7 @@ import static org.asciidoctor.maven.commons.StringUtils.isBlank; import static org.assertj.core.api.Assertions.assertThat; -public class StringUtilsTest { +class StringUtilsTest { @Test void should_detect_null_as_blank_string() { diff --git a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/LogRecordFormatterTest.java b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/LogRecordFormatterTest.java index 9476f5ca..db5ab5be 100644 --- a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/LogRecordFormatterTest.java +++ b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/log/LogRecordFormatterTest.java @@ -12,12 +12,12 @@ import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -public class LogRecordFormatterTest { +class LogRecordFormatterTest { private static final String PROJECT_NAME = "asciidoctor-maven-commons"; @Test - public void should_apply_full_format_logRecord_with_all_data() { + void should_apply_full_format_logRecord_with_all_data() { // given final Cursor cursor = new TestCursor(new File("file.adoc").getAbsolutePath(), 3, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -29,7 +29,7 @@ public void should_apply_full_format_logRecord_with_all_data() { } @Test - public void should_apply_simple_format_when_cursor_is_null() { + void should_apply_simple_format_when_cursor_is_null() { // given final LogRecord logRecord = new LogRecord(Severity.INFO, null, "a message"); // when @@ -39,7 +39,7 @@ public void should_apply_simple_format_when_cursor_is_null() { } @Test - public void should_apply_simple_format_when_cursor_is_empty() { + void should_apply_simple_format_when_cursor_is_empty() { // given final Cursor cursor = new TestCursor(null, 0, null, null); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -50,7 +50,7 @@ public void should_apply_simple_format_when_cursor_is_empty() { } @Test - public void should_format_full_logRecord_with_file_absolute_path_when_sourceDir_is_not_valid() throws IOException { + void should_format_full_logRecord_with_file_absolute_path_when_sourceDir_is_not_valid() throws IOException { // given final Cursor cursor = new TestCursor(new File("file.adoc").getAbsolutePath(), 3, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -63,7 +63,7 @@ public void should_format_full_logRecord_with_file_absolute_path_when_sourceDir_ } @Test - public void should_format_logRecords_with_empty_lineNumber_absolute_path_when_sourceDir_is_not_valid() throws IOException { + void should_format_logRecords_with_empty_lineNumber_absolute_path_when_sourceDir_is_not_valid() throws IOException { // given final Cursor cursor = new TestCursor(new File("file.adoc").getAbsolutePath(), 0, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -76,7 +76,7 @@ public void should_format_logRecords_with_empty_lineNumber_absolute_path_when_so } @Test - public void should_format_logRecords_when_source_is_not_under_sourceDir() { + void should_format_logRecords_when_source_is_not_under_sourceDir() { // given final Cursor cursor = new TestCursor(new File("..", "../file.adoc").toString(), 2, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -88,7 +88,7 @@ public void should_format_logRecords_when_source_is_not_under_sourceDir() { } @Test - public void should_format_full_logRecord_when_cursor_is_http_source() { + void should_format_full_logRecord_when_cursor_is_http_source() { // given final TestCursor cursor = new TestCursor("http://something/source.adoc", 3, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); @@ -99,7 +99,7 @@ public void should_format_full_logRecord_when_cursor_is_http_source() { } @Test - public void should_format_full_logRecord_when_cursor_is_https_source() { + void should_format_full_logRecord_when_cursor_is_https_source() { // given final TestCursor cursor = new TestCursor("https://something/source.adoc", 3, "path", "dir"); final LogRecord logRecord = new LogRecord(Severity.INFO, cursor, "a message"); diff --git a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteConversionConfigurationParserTest.java b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteConversionConfigurationParserTest.java index a381bf71..ea986852 100644 --- a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteConversionConfigurationParserTest.java +++ b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteConversionConfigurationParserTest.java @@ -18,10 +18,10 @@ import static org.asciidoctor.Options.*; import static org.assertj.core.api.Assertions.assertThat; -public class SiteConversionConfigurationParserTest { +class SiteConversionConfigurationParserTest { @Test - public void should_return_default_configuration_when_site_xml_is_null() { + void should_return_default_configuration_when_site_xml_is_null() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -39,7 +39,7 @@ public void should_return_default_configuration_when_site_xml_is_null() { } @Test - public void should_return_default_configuration_when_asciidoc_xml_is_null() { + void should_return_default_configuration_when_asciidoc_xml_is_null() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -58,7 +58,7 @@ public void should_return_default_configuration_when_asciidoc_xml_is_null() { } @Test - public void should_return_simple_single_requires() { + void should_return_simple_single_requires() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -81,7 +81,7 @@ public void should_return_simple_single_requires() { } @Test - public void should_return_multiple_requires() { + void should_return_multiple_requires() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -104,7 +104,7 @@ public void should_return_multiple_requires() { } @Test - public void should_return_multiple_requires_when_defined_in_single_element() { + void should_return_multiple_requires_when_defined_in_single_element() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -127,7 +127,7 @@ public void should_return_multiple_requires_when_defined_in_single_element() { } @Test - public void should_remove_empty_and_blank_requires() { + void should_remove_empty_and_blank_requires() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -150,7 +150,7 @@ public void should_remove_empty_and_blank_requires() { } @Test - public void should_return_attributes() { + void should_return_attributes() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -181,14 +181,14 @@ public void should_return_attributes() { } @Test - public void should_map_null_attributes_as_empty_string() { + void should_map_null_attributes_as_empty_string() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); AttributesBuilder emptyAttributes = Attributes.builder(); Xpp3Dom siteConfig = Xpp3DoomBuilder.asciidocNode() .addChild("attributes") - .addChild("toc", null) + .addChild("toc") .build(); // when @@ -207,7 +207,7 @@ public void should_map_null_attributes_as_empty_string() { } @Test - public void should_map_true_boolean_attribute_as_empty_string_value() { + void should_map_true_boolean_attribute_as_empty_string_value() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -233,7 +233,7 @@ public void should_map_true_boolean_attribute_as_empty_string_value() { } @Test - public void should_map_false_boolean_attribute_as_null_value() { + void should_map_false_boolean_attribute_as_null_value() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -259,7 +259,7 @@ public void should_map_false_boolean_attribute_as_null_value() { } @Test - public void should_return_template_dirs_when_defined_as_templateDirs_dir() { + void should_return_template_dirs_when_defined_as_templateDirs_dir() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -287,7 +287,7 @@ public void should_return_template_dirs_when_defined_as_templateDirs_dir() { } @Test - public void should_return_template_dirs_when_defined_as_template_dirs_dir() { + void should_return_template_dirs_when_defined_as_template_dirs_dir() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -315,7 +315,7 @@ public void should_return_template_dirs_when_defined_as_template_dirs_dir() { } @Test - public void should_not_return_empty_template_dirs() { + void should_not_return_empty_template_dirs() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -324,7 +324,7 @@ public void should_not_return_empty_template_dirs() { .addChild("template_dirs") .addChild("dir", "") .parent() - .addChild("dir", null) + .addChild("dir") .build(); // when @@ -338,7 +338,7 @@ public void should_not_return_empty_template_dirs() { } @Test - public void should_return_baseDir_dirs_when_defined_as_template_dirs_dir() { + void should_return_baseDir_dirs_when_defined_as_template_dirs_dir() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -361,7 +361,7 @@ public void should_return_baseDir_dirs_when_defined_as_template_dirs_dir() { } @Test - public void should_return_any_configuration_inside_asciidoc_node_as_option() { + void should_return_any_configuration_inside_asciidoc_node_as_option() { // given final MavenProject project = fakeProject(); OptionsBuilder emptyOptions = Options.builder(); @@ -391,7 +391,7 @@ public void should_return_any_configuration_inside_asciidoc_node_as_option() { } @Test - public void should_return_and_format_any_maven_project_property_as_attribute_when_site_config_is_not_present() { + void should_return_and_format_any_maven_project_property_as_attribute_when_site_config_is_not_present() { // given final Map projectProperties = new HashMap<>(); projectProperties.put("mvn.property-test1", "value-1"); @@ -416,7 +416,7 @@ public void should_return_and_format_any_maven_project_property_as_attribute_whe } @Test - public void should_return_and_format_any_maven_project_property_as_attribute_when_site_config_is_present() { + void should_return_and_format_any_maven_project_property_as_attribute_when_site_config_is_present() { // given final Map projectProperties = new HashMap<>(); projectProperties.put("mvn.property-test1", "value-1"); @@ -469,5 +469,4 @@ private Map map(Map.Entry... entries) { private AbstractMap.SimpleEntry entry(String key, Object value) { return new AbstractMap.SimpleEntry<>(key, value); } - } diff --git a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializerTest.java b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializerTest.java index 46883159..6c135ade 100644 --- a/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializerTest.java +++ b/asciidoctor-maven-commons/src/test/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializerTest.java @@ -9,10 +9,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; -public class SiteLogHandlerDeserializerTest { +class SiteLogHandlerDeserializerTest { @Test - public void should_deserialize_null_logHandler() { + void should_deserialize_null_logHandler() { // given final Xpp3Dom logHandlerConfig = null; // when @@ -25,7 +25,7 @@ public void should_deserialize_null_logHandler() { } @Test - public void should_deserialize_empty_logHandler() { + void should_deserialize_empty_logHandler() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.asciidocNode() .build(); @@ -39,7 +39,7 @@ public void should_deserialize_empty_logHandler() { } @Test - public void should_deserialize_valid_outputToConsole() { + void should_deserialize_valid_outputToConsole() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("outputToConsole", "false") @@ -56,7 +56,7 @@ public void should_deserialize_valid_outputToConsole() { } @Test - public void should_deserialize_invalid_outputToConsole() { + void should_deserialize_invalid_outputToConsole() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("outputToConsole", "text") @@ -73,7 +73,7 @@ public void should_deserialize_invalid_outputToConsole() { } @Test - public void should_deserialize_empty_failIf() { + void should_deserialize_empty_failIf() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("failIf") @@ -88,7 +88,7 @@ public void should_deserialize_empty_failIf() { } @Test - public void should_deserialize_failIf_with_valid_severity() { + void should_deserialize_failIf_with_valid_severity() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("failIf") @@ -108,7 +108,7 @@ public void should_deserialize_failIf_with_valid_severity() { } @Test - public void should_deserialize_failIf_with_invalid_severity() { + void should_deserialize_failIf_with_invalid_severity() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("failIf") @@ -124,7 +124,7 @@ public void should_deserialize_failIf_with_invalid_severity() { } @Test - public void should_deserialize_failIf_with_empty_severity() { + void should_deserialize_failIf_with_empty_severity() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("failIf") @@ -140,7 +140,7 @@ public void should_deserialize_failIf_with_empty_severity() { } @Test - public void should_deserialize_failIf_with_containsText() { + void should_deserialize_failIf_with_containsText() { // given final String textPattern = "some words"; final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() @@ -161,7 +161,7 @@ public void should_deserialize_failIf_with_containsText() { } @Test - public void should_deserialize_failIf_empty_containsText() { + void should_deserialize_failIf_empty_containsText() { // given final Xpp3Dom logHandlerConfig = Xpp3DoomBuilder.logHandler() .addChild("failIf") @@ -177,7 +177,7 @@ public void should_deserialize_failIf_empty_containsText() { } @Test - public void should_deserialize_failIf_with_severity_and_containsText() { + void should_deserialize_failIf_with_severity_and_containsText() { // given final String textPattern = "some words"; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java index 41aa3bc5..1988696d 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java @@ -219,7 +219,7 @@ public void processSources(List sourceFiles, ResourcesProcessor resourcesP // register LogHandler to capture asciidoctor messages final Boolean outputToConsole = logHandler.getOutputToConsole() == null ? Boolean.TRUE : logHandler.getOutputToConsole(); - final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(outputToConsole, sourceDir, + final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(outputToConsole, logRecord -> getLog().info(LogRecordFormatter.format(logRecord, sourceDir))); asciidoctor.registerLogHandler(memoryLogHandler); // disable default console output of AsciidoctorJ diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorHttpMojoTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorHttpMojoTest.java index 40753131..d5c21701 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorHttpMojoTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorHttpMojoTest.java @@ -21,11 +21,10 @@ import static org.asciidoctor.maven.TestUtils.mockAsciidoctorHttpMojo; import static org.assertj.core.api.Assertions.assertThat; -public class AsciidoctorHttpMojoTest { - +class AsciidoctorHttpMojoTest { @Test - public void http_front_should_let_access_converted_files() throws IOException { + void http_front_should_let_access_converted_files() throws IOException { // given File srcDir = new File("target/test-classes/src/asciidoctor-http"); File outputDir = TestFilesHelper.newOutputTestDirectory("http-mojo"); @@ -64,7 +63,7 @@ public void http_front_should_let_access_converted_files() throws IOException { } @Test - public void should_return_default_page() throws IOException { + void should_return_default_page() throws IOException { // given File srcDir = new File("target/test-classes/src/asciidoctor-http-default"); File outputDir = TestFilesHelper.newOutputTestDirectory("http-mojo"); @@ -103,7 +102,7 @@ public void should_return_default_page() throws IOException { } @Test - public void should_return_404_when_file_does_not_exist() { + void should_return_404_when_file_does_not_exist() { // given File emptySrcDir = new File("some_path"); File outputDir = TestFilesHelper.newOutputTestDirectory("http-mojo"); @@ -139,7 +138,7 @@ public void should_return_404_when_file_does_not_exist() { } @Test - public void should_return_405_when_method_is_not_POST() { + void should_return_405_when_method_is_not_POST() { // given File emptySrcDir = new File("some_path"); File outputDir = TestFilesHelper.newOutputTestDirectory("http-mojo"); @@ -175,7 +174,7 @@ public void should_return_405_when_method_is_not_POST() { } @Test - public void should_return_205_when_method_is_HEAD_and_resource_exists() { + void should_return_205_when_method_is_HEAD_and_resource_exists() { // given File emptySrcDir = new File("some_path"); File outputDir = TestFilesHelper.newOutputTestDirectory("http-mojo"); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorIntegrationTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorIntegrationTest.java index 623fb445..d2cafad2 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorIntegrationTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorIntegrationTest.java @@ -7,23 +7,23 @@ import org.junit.jupiter.api.Test; import java.io.File; +import java.util.Map; import static org.asciidoctor.maven.AsciidoctorAsserter.assertThat; import static org.asciidoctor.maven.TestUtils.ResourceBuilder.excludeAll; -import static org.asciidoctor.maven.TestUtils.map; import static org.asciidoctor.maven.TestUtils.mockAsciidoctorMojo; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; /** * Opinionated tests to validate Asciidoctor behaviours in end-to-end scenarios. */ -public class AsciidoctorIntegrationTest { +class AsciidoctorIntegrationTest { private static final String DEFAULT_SOURCE_DIRECTORY = "target/test-classes/src/asciidoctor"; @Test - public void should_leave_references_when_missing_attribute_is_skip() throws MojoFailureException, MojoExecutionException { + void should_leave_references_when_missing_attribute_is_skip() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -31,7 +31,7 @@ public void should_leave_references_when_missing_attribute_is_skip() throws Mojo // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("attribute-missing", "skip"); + mojo.attributes = Map.of("attribute-missing", "skip"); mojo.sourceDocumentName = "attribute-missing.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -43,7 +43,7 @@ public void should_leave_references_when_missing_attribute_is_skip() throws Mojo } @Test - public void should_remove_references_when_missing_attribute_is_drop() throws MojoFailureException, MojoExecutionException { + void should_remove_references_when_missing_attribute_is_drop() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -51,7 +51,7 @@ public void should_remove_references_when_missing_attribute_is_drop() throws Moj // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("attribute-missing", "drop"); + mojo.attributes = Map.of("attribute-missing", "drop"); mojo.sourceDirectory = srcDir; mojo.sourceDocumentName = "attribute-missing.adoc"; mojo.outputDirectory = outputDir; @@ -64,7 +64,7 @@ public void should_remove_references_when_missing_attribute_is_drop() throws Moj } @Test - public void should_remove_line_with_references_when_missing_attribute_is_drop_line() throws MojoFailureException, MojoExecutionException { + void should_remove_line_with_references_when_missing_attribute_is_drop_line() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -72,7 +72,7 @@ public void should_remove_line_with_references_when_missing_attribute_is_drop_li // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("attribute-missing", "drop-line"); + mojo.attributes = Map.of("attribute-missing", "drop-line"); mojo.sourceDocumentName = "attribute-missing.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -85,7 +85,7 @@ public void should_remove_line_with_references_when_missing_attribute_is_drop_li } @Test - public void should_remove_expression_when_attribute_undefined_is_drop() throws MojoFailureException, MojoExecutionException { + void should_remove_expression_when_attribute_undefined_is_drop() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -93,7 +93,7 @@ public void should_remove_expression_when_attribute_undefined_is_drop() throws M // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("attribute-undefined", "drop"); + mojo.attributes = Map.of("attribute-undefined", "drop"); mojo.sourceDocumentName = "attribute-undefined.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -106,7 +106,7 @@ public void should_remove_expression_when_attribute_undefined_is_drop() throws M } @Test - public void should_remove_line_when_attribute_undefined_is_drop_line() throws MojoFailureException, MojoExecutionException { + void should_remove_line_when_attribute_undefined_is_drop_line() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -114,7 +114,7 @@ public void should_remove_line_when_attribute_undefined_is_drop_line() throws Mo // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("attribute-undefined", "drop-line"); + mojo.attributes = Map.of("attribute-undefined", "drop-line"); mojo.sourceDocumentName = "attribute-undefined.adoc"; mojo.outputDirectory = outputDir; mojo.sourceDirectory = srcDir; @@ -127,7 +127,7 @@ public void should_remove_line_when_attribute_undefined_is_drop_line() throws Mo } @Test - public void should_apply_code_highlighting_with_pygments_coderay() throws MojoFailureException, MojoExecutionException { + void should_apply_code_highlighting_with_pygments_coderay() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-coderay"); @@ -135,7 +135,7 @@ public void should_apply_code_highlighting_with_pygments_coderay() throws MojoFa // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("source-highlighter", "coderay"); + mojo.attributes = Map.of("source-highlighter", "coderay"); mojo.sourceDocumentName = "main-document.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -147,7 +147,7 @@ public void should_apply_code_highlighting_with_pygments_coderay() throws MojoFa } @Test - public void should_apply_code_highlighting_with_pygments_highlightjs() throws MojoFailureException, MojoExecutionException { + void should_apply_code_highlighting_with_pygments_highlightjs() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-highlightjs"); @@ -155,7 +155,7 @@ public void should_apply_code_highlighting_with_pygments_highlightjs() throws Mo // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("source-highlighter", "highlight.js"); + mojo.attributes = Map.of("source-highlighter", "highlight.js"); mojo.sourceDocumentName = "main-document.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -168,7 +168,7 @@ public void should_apply_code_highlighting_with_pygments_highlightjs() throws Mo } @Test - public void should_apply_code_highlighting_with_prettify() throws MojoFailureException, MojoExecutionException { + void should_apply_code_highlighting_with_prettify() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-prettify"); @@ -176,7 +176,7 @@ public void should_apply_code_highlighting_with_prettify() throws MojoFailureExc // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map("source-highlighter", "prettify"); + mojo.attributes = Map.of("source-highlighter", "prettify"); mojo.sourceDocumentName = "main-document.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -190,7 +190,7 @@ public void should_apply_code_highlighting_with_prettify() throws MojoFailureExc @Disabled("Not supported in Asciidoctorj (gem not embedded)") @Test - public void should_apply_code_highlighting_with_pygments() throws MojoFailureException, MojoExecutionException { + void should_apply_code_highlighting_with_pygments() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-pygments"); @@ -198,7 +198,7 @@ public void should_apply_code_highlighting_with_pygments() throws MojoFailureExc // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html"; - mojo.attributes = map( + mojo.attributes = Map.of( "source-highlighter", "pygments", "pygments-style", "monokai", "pygments-linenums-mode", "inline"); @@ -213,7 +213,7 @@ public void should_apply_code_highlighting_with_pygments() throws MojoFailureExc } @Test - public void should_apply_code_highlighting_when_set_in_document_header() throws MojoFailureException, MojoExecutionException { + void should_apply_code_highlighting_when_set_in_document_header() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-header"); @@ -234,7 +234,7 @@ public void should_apply_code_highlighting_when_set_in_document_header() throws } @Test - public void should_not_add_CSS_when_code_highlighting_value_is_not_valid() throws MojoFailureException, MojoExecutionException { + void should_not_add_CSS_when_code_highlighting_value_is_not_valid() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("src/test/resources/src/asciidoctor"); File outputDir = newOutputTestDirectory("sourceHighlighting-nonExistent"); @@ -242,7 +242,7 @@ public void should_not_add_CSS_when_code_highlighting_value_is_not_valid() throw // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("source-highlighter", "nonExistent"); + mojo.attributes = Map.of("source-highlighter", "nonExistent"); mojo.sourceDocumentName = "main-document.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -254,7 +254,7 @@ public void should_not_add_CSS_when_code_highlighting_value_is_not_valid() throw } @Test - public void should_include_local_source_file() throws MojoFailureException, MojoExecutionException { + void should_include_local_source_file() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("include"); @@ -274,7 +274,7 @@ public void should_include_local_source_file() throws MojoFailureException, Mojo } @Test - public void should_include_github_files_when_allowUriRead_is_true() throws MojoFailureException, MojoExecutionException { + void should_include_github_files_when_allowUriRead_is_true() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("remote-includes"); @@ -283,7 +283,7 @@ public void should_include_github_files_when_allowUriRead_is_true() throws MojoF // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.sourceDocumentName = documentName; - mojo.attributes = map("allow-uri-read", "true"); + mojo.attributes = Map.of("allow-uri-read", "true"); mojo.backend = "html5"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; @@ -296,7 +296,7 @@ public void should_include_github_files_when_allowUriRead_is_true() throws MojoF } @Test - public void should_not_include_github_files_when_allowUriRead_is_false() throws MojoFailureException, MojoExecutionException { + void should_not_include_github_files_when_allowUriRead_is_false() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("remote-includes"); @@ -305,7 +305,7 @@ public void should_not_include_github_files_when_allowUriRead_is_false() throws // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("allow-uri-read", "false"); + mojo.attributes = Map.of("allow-uri-read", "false"); mojo.sourceDirectory = srcDir; mojo.sourceDocumentName = documentName; mojo.outputDirectory = outputDir; @@ -318,7 +318,7 @@ public void should_not_include_github_files_when_allowUriRead_is_false() throws } @Test - public void should_add_docinfo_contents_and_not_copy_them_as_resources() throws MojoFailureException, MojoExecutionException { + void should_add_docinfo_contents_and_not_copy_them_as_resources() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -346,7 +346,7 @@ public void should_add_docinfo_contents_and_not_copy_them_as_resources() throws } @Test - public void should_honor_doctype_set_in_document() throws MojoFailureException, MojoExecutionException { + void should_honor_doctype_set_in_document() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -358,12 +358,11 @@ public void should_honor_doctype_set_in_document() throws MojoFailureException, mojo.sourceDocumentName = "book.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("linkcss", "", "copycss!", ""); + mojo.attributes = Map.of("linkcss", "", "copycss!", ""); mojo.execute(); // then assertThat(outputDir, "book.html") .contains(""); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoExtensionsTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoExtensionsTest.java index c6216461..8f57f4be 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoExtensionsTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoExtensionsTest.java @@ -12,27 +12,27 @@ import java.io.File; import java.util.Arrays; +import java.util.Map; import static java.util.Collections.singletonList; -import static org.asciidoctor.maven.TestUtils.map; import static org.asciidoctor.maven.TestUtils.mockAsciidoctorMojo; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; /** * Specific tests to validate usage of AsciidoctorJ extension in AsciidoctorMojo. - * + *

* Most of the examples have been directly adapted from the ones found in AsciidoctorJ * documentation. * * @author abelsromero */ -public class AsciidoctorMojoExtensionsTest { +class AsciidoctorMojoExtensionsTest { private static final String SRC_DIR = "target/test-classes/src/asciidoctor/"; @Test - public void should_fail_when_extension_is_not_found_in_classpath() { + void should_fail_when_extension_is_not_found_in_classpath() { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -43,7 +43,6 @@ public void should_fail_when_extension_is_not_found_in_classpath() { mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null, "linkcss!", ""); mojo.extensions = Arrays.asList(extensionConfiguration("non.existent.Processor")); Throwable throwable = Assertions.catchThrowable(mojo::execute); // then @@ -56,7 +55,7 @@ public void should_fail_when_extension_is_not_found_in_classpath() { // This test is added to keep track of possible changes in the extension"s SPI @Test - public void should_fail_when_extension_throws_an_uncaught_exception() { + void should_fail_when_extension_throws_an_uncaught_exception() { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -67,7 +66,6 @@ public void should_fail_when_extension_throws_an_uncaught_exception() { mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null, "linkcss!", ""); mojo.extensions = Arrays.asList(extensionConfiguration(FailingPreprocessor.class)); Throwable throwable = Assertions.catchThrowable(mojo::execute); // then @@ -79,7 +77,7 @@ public void should_fail_when_extension_throws_an_uncaught_exception() { } @Test - public void should_register_and_run_Preprocessor() { + void should_register_and_run_Preprocessor() { String extensionClassName = "ChangeAttributeValuePreprocessor"; String expectedMessage = "ChangeAttributeValuePreprocessor(Preprocessor) initialized"; @@ -89,7 +87,7 @@ public void should_register_and_run_Preprocessor() { } @Test - public void should_register_and_run_Treeprocessor() { + void should_register_and_run_Treeprocessor() { String extensionClassName = "DummyTreeprocessor"; String expectedMessage = "DummyTreeprocessor(Treeprocessor) initialized"; @@ -99,7 +97,7 @@ public void should_register_and_run_Treeprocessor() { } @Test - public void should_register_and_run_PostProcessor() { + void should_register_and_run_PostProcessor() { String extensionClassName = "DummyPostprocessor"; String expectedMessage = "DummyPostprocessor(Postprocessor) initialized"; @@ -109,7 +107,7 @@ public void should_register_and_run_PostProcessor() { } @Test - public void should_register_and_run_DocinfoProcessor() { + void should_register_and_run_DocinfoProcessor() { String extensionClassName = "MetaDocinfoProcessor"; String expectedMessage = "MetaDocinfoProcessor(DocinfoProcessor) initialized"; @@ -119,7 +117,7 @@ public void should_register_and_run_DocinfoProcessor() { } @Test - public void should_register_and_run_IncludeProcessor() { + void should_register_and_run_IncludeProcessor() { String extensionClassName = "UriIncludeProcessor"; String expectedMessage = "UriIncludeProcessor(IncludeProcessor) initialized"; @@ -141,11 +139,12 @@ private void shouldRegisterAndRunExtension(String extensionClassName, String ini mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); + mojo.attributes = Map.of("toc", ""); mojo.extensions = singletonList(extensionConfiguration("org.asciidoctor.maven.test.processors." + extensionClassName)); mojo.execute(); // then - assertThat(consoleHolder.getOutput()) + String output = consoleHolder.getOutput(); + assertThat(output) .contains(initializationMessage) .contains(executionMessage); // cleanup @@ -153,7 +152,7 @@ private void shouldRegisterAndRunExtension(String extensionClassName, String ini } @Test - public void should_convert_to_html_with_a_preprocessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_a_preprocessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -164,7 +163,6 @@ public void should_convert_to_html_with_a_preprocessor() throws MojoFailureExcep mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = Arrays.asList(extensionConfiguration(ChangeAttributeValuePreprocessor.class)); mojo.execute(); // then @@ -174,7 +172,7 @@ public void should_convert_to_html_with_a_preprocessor() throws MojoFailureExcep } @Test - public void should_convert_to_html_with_a_blockprocessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_a_blockprocessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("blockprocessor"); @@ -185,7 +183,6 @@ public void should_convert_to_html_with_a_blockprocessor() throws MojoFailureExc mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = singletonList(extensionConfiguration(YellBlockProcessor.class, "yell")); mojo.execute(); // then @@ -195,7 +192,7 @@ public void should_convert_to_html_with_a_blockprocessor() throws MojoFailureExc } @Test - public void should_convert_to_html_and_add_meta_tag_with_a_DocinfoProcessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_and_add_meta_tag_with_a_DocinfoProcessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("docinfoProcessor"); @@ -206,7 +203,6 @@ public void should_convert_to_html_and_add_meta_tag_with_a_DocinfoProcessor() th mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = singletonList(extensionConfiguration(MetaDocinfoProcessor.class, "yell")); mojo.execute(); // then @@ -216,7 +212,7 @@ public void should_convert_to_html_and_add_meta_tag_with_a_DocinfoProcessor() th } @Test - public void should_convert_to_html_and_modify_output_with_a_BlockMacroProcessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_and_modify_output_with_a_BlockMacroProcessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("blockMacroProcessor"); @@ -227,7 +223,6 @@ public void should_convert_to_html_and_modify_output_with_a_BlockMacroProcessor( mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = singletonList(extensionConfiguration(GistBlockMacroProcessor.class, "gist")); mojo.execute(); // then @@ -237,7 +232,7 @@ public void should_convert_to_html_and_modify_output_with_a_BlockMacroProcessor( } @Test - public void should_convert_to_html_and_modify_output_with_a_InlineMacroProcessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_and_modify_output_with_a_InlineMacroProcessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("inlineMacroProcessor"); @@ -248,7 +243,6 @@ public void should_convert_to_html_and_modify_output_with_a_InlineMacroProcessor mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = singletonList(extensionConfiguration(ManpageInlineMacroProcessor.class, "man")); mojo.execute(); // then @@ -258,7 +252,7 @@ public void should_convert_to_html_and_modify_output_with_a_InlineMacroProcessor } @Test - public void should_convert_to_html_and_modify_output_with_an_IncludeProcessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_and_modify_output_with_an_IncludeProcessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("includeProcessor"); @@ -269,7 +263,6 @@ public void should_convert_to_html_and_modify_output_with_an_IncludeProcessor() mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = singletonList(extensionConfiguration(UriIncludeProcessor.class)); mojo.execute(); // then @@ -279,7 +272,7 @@ public void should_convert_to_html_and_modify_output_with_an_IncludeProcessor() } @Test - public void should_run_the_same_preprocessor_twice_when_registered_twice() throws MojoFailureException, MojoExecutionException { + void should_run_the_same_preprocessor_twice_when_registered_twice() throws MojoFailureException, MojoExecutionException { // given ConsoleHolder consoleHolder = ConsoleHolder.start(); File srcDir = new File(SRC_DIR); @@ -291,7 +284,6 @@ public void should_run_the_same_preprocessor_twice_when_registered_twice() throw mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = Arrays.asList( extensionConfiguration(ChangeAttributeValuePreprocessor.class), extensionConfiguration(ChangeAttributeValuePreprocessor.class) @@ -310,7 +302,7 @@ public void should_run_the_same_preprocessor_twice_when_registered_twice() throw // Adding a BlockMacroProcessor or BlockProcessor makes the conversion fail @Test - public void should_convert_to_html_with_Preprocessor_DocinfoProcessor_InlineMacroProcessor_and_IncludeProcessor() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_Preprocessor_DocinfoProcessor_InlineMacroProcessor_and_IncludeProcessor() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -321,7 +313,6 @@ public void should_convert_to_html_with_Preprocessor_DocinfoProcessor_InlineMacr mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.extensions = Arrays.asList( extensionConfiguration("org.asciidoctor.maven.test.processors.ChangeAttributeValuePreprocessor"), extensionConfiguration("org.asciidoctor.maven.test.processors.MetaDocinfoProcessor"), @@ -338,7 +329,7 @@ public void should_convert_to_html_with_Preprocessor_DocinfoProcessor_InlineMacr } @Test - public void should_convert_to_html_using_all_extension_types() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_using_all_extension_types() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -349,7 +340,7 @@ public void should_convert_to_html_using_all_extension_types() throws MojoFailur mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", "", + mojo.attributes = Map.of("toc", "", "linkcss", "", "copycss!", ""); mojo.extensions = Arrays.asList( @@ -370,13 +361,13 @@ public void should_convert_to_html_using_all_extension_types() throws MojoFailur } /** - * Manual test to validate automatic extension registration. - * To execute, copy _org.asciidoctor.extension.spi.ExtensionRegistry to - * /src/test/resources/META-INF/services/ and execute + * Manual test to validate automatic extension registration. + * To execute, copy _org.asciidoctor.extension.spi.ExtensionRegistry to + * /src/test/resources/META-INF/services/ and execute */ @Disabled @Test - public void property_extension() throws MojoFailureException, MojoExecutionException { + void property_extension() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(SRC_DIR); File outputDir = newOutputTestDirectory("preprocessor"); @@ -387,7 +378,7 @@ public void property_extension() throws MojoFailureException, MojoExecutionExcep mojo.sourceDocumentName = "processors-sample.adoc"; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null, "linkcss!", ""); + mojo.attributes = Map.of("toc", null, "linkcss!", ""); mojo.execute(); // then AsciidoctorAsserter.assertThat(outputDir, "processors-sample.html") diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoLogHandlerTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoLogHandlerTest.java index 4f09736d..f626319e 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoLogHandlerTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoLogHandlerTest.java @@ -8,27 +8,26 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; - import java.io.File; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static org.asciidoctor.log.Severity.ERROR; import static org.asciidoctor.log.Severity.WARN; -import static org.asciidoctor.maven.TestUtils.map; import static org.asciidoctor.maven.TestUtils.mockAsciidoctorMojo; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; -public class AsciidoctorMojoLogHandlerTest { +class AsciidoctorMojoLogHandlerTest { private static final String DEFAULT_SOURCE_DIRECTORY = "target/test-classes/src/asciidoctor"; @Test - public void should_not_fail_when_logHandler_is_not_set() throws MojoFailureException, MojoExecutionException { + void should_not_fail_when_logHandler_is_not_set() throws MojoFailureException, MojoExecutionException { // setup String sourceDocument = "errors/document-with-missing-include.adoc"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -41,7 +40,6 @@ public void should_not_fail_when_logHandler_is_not_set() throws MojoFailureExcep mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.execute(); // then: process completes but the document contains errors @@ -65,7 +63,6 @@ public void should_show_Asciidoctor_messages_as_info_by_default() throws MojoFai mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.execute(); // then @@ -106,7 +103,6 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set() mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.execute(); // then: output file exists & shows include error @@ -132,7 +128,7 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set() @Disabled @Test - public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_and_doc_contains_messages_without_cursor_and_verbose_is_enabled() throws MojoFailureException, MojoExecutionException { + void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_and_doc_contains_messages_without_cursor_and_verbose_is_enabled() throws MojoFailureException, MojoExecutionException { // setup final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -149,7 +145,7 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_a mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); + mojo.attributes = Map.of("toc", null); mojo.enableVerbose = true; mojo.execute(); @@ -172,7 +168,7 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_a @Disabled @Test - public void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws MojoFailureException, MojoExecutionException { + void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws MojoFailureException, MojoExecutionException { // setup final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -189,7 +185,6 @@ public void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.enableVerbose = true; mojo.gemPath = System.getProperty("java.io.tmpdir"); mojo.execute(); @@ -210,7 +205,7 @@ public void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws } @Test - public void should_fail_when_logHandler_failIf_is_WARNING() { + void should_fail_when_logHandler_failIf_is_WARNING() { // setup String sourceDocument = "errors/document-with-missing-include.adoc"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -227,7 +222,6 @@ public void should_fail_when_logHandler_failIf_is_WARNING() { mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); Throwable throwable = catchThrowable(mojo::execute); // then: issues with WARN and ERROR are returned @@ -237,7 +231,7 @@ public void should_fail_when_logHandler_failIf_is_WARNING() { } @Test - public void should_fail_when_logHandler_failIf_is_ERROR() { + void should_fail_when_logHandler_failIf_is_ERROR() { // setup String sourceDocument = "errors/document-with-missing-include.adoc"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -254,7 +248,6 @@ public void should_fail_when_logHandler_failIf_is_ERROR() { mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); Throwable throwable = catchThrowable(mojo::execute); // then @@ -264,7 +257,7 @@ public void should_fail_when_logHandler_failIf_is_ERROR() { } @Test - public void should_not_fail_if_containsText_does_not_match_any_message() throws MojoFailureException, MojoExecutionException { + void should_not_fail_if_containsText_does_not_match_any_message() throws MojoFailureException, MojoExecutionException { // setup String sourceDocument = "errors/document-with-missing-include.adoc"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -281,7 +274,6 @@ public void should_not_fail_if_containsText_does_not_match_any_message() throws mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.execute(); // then @@ -290,7 +282,7 @@ public void should_not_fail_if_containsText_does_not_match_any_message() throws } @Test - public void should_fail_when_containsText_matches() { + void should_fail_when_containsText_matches() { // setup final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -309,7 +301,6 @@ public void should_fail_when_containsText_matches() { mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); Throwable throwable = catchThrowable(mojo::execute); // then @@ -335,7 +326,7 @@ public void should_fail_when_containsText_matches() { } @Test - public void should_fail_and_filter_errors_that_match_both_severity_and_text() { + void should_fail_and_filter_errors_that_match_both_severity_and_text() { // setup final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -355,7 +346,6 @@ public void should_fail_and_filter_errors_that_match_both_severity_and_text() { mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); Throwable throwable = catchThrowable(mojo::execute); // then @@ -374,7 +364,7 @@ public void should_fail_and_filter_errors_that_match_both_severity_and_text() { // `asciidoctor` JUL logger inherits a ConsoleHandler that needs to be disabled // to avoid redundant messages in error channel @Test - public void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureException, MojoExecutionException { + void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureException, MojoExecutionException { // setup final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -391,7 +381,6 @@ public void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureE mojo.sourceDocumentName = sourceDocument; mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null); mojo.execute(); // then: output file exists & shows include error diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java index f62fe861..64f72aac 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorMojoTest.java @@ -13,10 +13,7 @@ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import static java.util.Collections.singletonList; @@ -26,13 +23,13 @@ import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; -public class AsciidoctorMojoTest { +class AsciidoctorMojoTest { private static final String DEFAULT_SOURCE_DIRECTORY = "target/test-classes/src/asciidoctor"; @Test - public void should_skip_execution_when_skip_is_set() throws MojoFailureException, MojoExecutionException { + void should_skip_execution_when_skip_is_set() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -51,7 +48,7 @@ public void should_skip_execution_when_skip_is_set() throws MojoFailureException } @Test - public void should_skip_processing_when_source_directory_does_no_exist() throws MojoFailureException, MojoExecutionException { + void should_skip_processing_when_source_directory_does_no_exist() throws MojoFailureException, MojoExecutionException { // given PrintStream originalOut = System.out; OutputStream newOut = new ByteArrayOutputStream(); @@ -76,7 +73,7 @@ public void should_skip_processing_when_source_directory_does_no_exist() throws } @Test - public void should_skip_processing_when_there_are_no_sources() throws MojoFailureException, MojoExecutionException { + void should_skip_processing_when_there_are_no_sources() throws MojoFailureException, MojoExecutionException { // given PrintStream originalOut = System.out; OutputStream newOut = new ByteArrayOutputStream(); @@ -102,7 +99,7 @@ public void should_skip_processing_when_there_are_no_sources() throws MojoFailur } @Test - public void should_convert_to_docbook() throws MojoFailureException, MojoExecutionException { + void should_convert_to_docbook() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -123,7 +120,7 @@ public void should_convert_to_docbook() throws MojoFailureException, MojoExecuti } @Test - public void should_convert_to_html5_with_defaults() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html5_with_defaults() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -147,7 +144,7 @@ public void should_convert_to_html5_with_defaults() throws MojoFailureException, } @Test - public void should_convert_to_html_with_attributes() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_attributes() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -160,7 +157,7 @@ public void should_convert_to_html_with_attributes() throws MojoFailureException mojo.resources = excludeAll(); mojo.outputDirectory = outputDir; mojo.standalone = true; - mojo.attributes = map("toc", null, + mojo.attributes = Map.of("toc", "", "linkcss!", "", "source-highlighter", "coderay"); @@ -177,7 +174,7 @@ public void should_convert_to_html_with_attributes() throws MojoFailureException } @Test - public void should_convert_to_html_with_a_custom_slim_template() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_a_custom_slim_template() throws MojoFailureException, MojoExecutionException { // given final String templatesPath = "target/test-classes/templates/slim/"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -204,7 +201,7 @@ public void should_convert_to_html_with_a_custom_slim_template() throws MojoFail } @Test - public void should_convert_to_html_with_a_custom_erb_template() throws MojoFailureException, MojoExecutionException { + void should_convert_to_html_with_a_custom_erb_template() throws MojoFailureException, MojoExecutionException { // given final String templatesPath = "target/test-classes/templates/"; File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); @@ -229,7 +226,7 @@ public void should_convert_to_html_with_a_custom_erb_template() throws MojoFailu } @Test - public void should_set_output_file() throws MojoFailureException, MojoExecutionException { + void should_set_output_file() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -237,7 +234,7 @@ public void should_set_output_file() throws MojoFailureException, MojoExecutionE // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.embedAssets = true; mojo.sourceDirectory = srcDir; mojo.sourceDocumentName = "sample-embedded.adoc"; @@ -255,7 +252,7 @@ public void should_set_output_file() throws MojoFailureException, MojoExecutionE } @Test - public void should_override_output_directory_with_output_file_with_absolute_path() throws MojoFailureException, MojoExecutionException { + void should_override_output_directory_with_output_file_with_absolute_path() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -264,7 +261,7 @@ public void should_override_output_directory_with_output_file_with_absolute_path // when AsciidoctorMojo mojo = mockAsciidoctorMojo(); mojo.backend = "html5"; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.embedAssets = true; mojo.sourceDirectory = srcDir; mojo.sourceDocumentName = "sample-embedded.adoc"; @@ -286,7 +283,7 @@ public void should_override_output_directory_with_output_file_with_absolute_path } @Test - public void should_set_file_extension() throws MojoFailureException, MojoExecutionException { + void should_set_file_extension() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory(); Assertions.assertThat(outputDir).doesNotExist(); @@ -315,7 +312,7 @@ public void should_set_file_extension() throws MojoFailureException, MojoExecuti } @Test - public void should_set_flag_attribute_as_true() throws MojoFailureException, MojoExecutionException { + void should_set_flag_attribute_as_true() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -328,7 +325,7 @@ public void should_set_flag_attribute_as_true() throws MojoFailureException, Moj mojo.outputDirectory = outputDir; // IMPORTANT Maven can only assign string values or null, so we have to emulate the value precisely in the test! // Believe it or not, null is the equivalent of writing in the XML configuration - mojo.attributes = map("toc2", "true"); + mojo.attributes = Map.of("toc2", "true"); mojo.execute(); // then @@ -338,7 +335,7 @@ public void should_set_flag_attribute_as_true() throws MojoFailureException, Moj } @Test - public void should_unset_flag_attribute_as_false() throws MojoFailureException, MojoExecutionException { + void should_unset_flag_attribute_as_false() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -351,7 +348,7 @@ public void should_unset_flag_attribute_as_false() throws MojoFailureException, mojo.outputDirectory = outputDir; // IMPORTANT Maven can only assign string values or null, so we have to emulate the value precisely in the test! // Believe it or not, null is the equivalent of writing in the XML configuration - mojo.attributes = map("toc2", "false"); + mojo.attributes = Map.of("toc2", "false"); mojo.execute(); // then @@ -361,7 +358,7 @@ public void should_unset_flag_attribute_as_false() throws MojoFailureException, } @Test - public void should_set_flag_attribute_as_null() throws MojoFailureException, MojoExecutionException { + void should_set_flag_attribute_as_null() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -374,7 +371,7 @@ public void should_set_flag_attribute_as_null() throws MojoFailureException, Moj mojo.outputDirectory = outputDir; // IMPORTANT Maven can only assign string values or null, so we have to emulate the value precisely in the test! // Believe it or not, null is the equivalent of writing in the XML configuration - mojo.attributes = map("toc", null); + mojo.attributes = Map.of("toc", ""); mojo.execute(); // then @@ -394,7 +391,7 @@ public void should_set_flag_attribute_as_null() throws MojoFailureException, Moj * - all documents are correctly converted with the import */ @Test - public void should_replicate_source_structure_when_standard_paths() throws MojoFailureException, MojoExecutionException, IOException { + void should_replicate_source_structure_when_standard_paths() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment"); File outputDir = newOutputTestDirectory("relative"); @@ -406,7 +403,7 @@ public void should_replicate_source_structure_when_standard_paths() throws MojoF mojo.outputDirectory = outputDir; mojo.preserveDirectories = true; mojo.relativeBaseDir = true; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.execute(); // then @@ -435,7 +432,7 @@ public void should_replicate_source_structure_when_standard_paths() throws MojoF * - all documents are correctly converted with the import */ @Test - public void should_replicate_source_structure_when_complex_paths() throws MojoFailureException, MojoExecutionException, IOException { + void should_replicate_source_structure_when_complex_paths() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment/../relative-path-treatment"); File outputDir = newOutputTestDirectory("relative"); @@ -447,7 +444,7 @@ public void should_replicate_source_structure_when_complex_paths() throws MojoFa mojo.outputDirectory = outputDir; mojo.preserveDirectories = true; mojo.relativeBaseDir = true; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.execute(); // then @@ -478,7 +475,7 @@ public void should_replicate_source_structure_when_complex_paths() throws MojoFa * - all documents but 1 (in the root) are incorrectly converted because they cannot find the imported file */ @Test - public void should_not_replicate_source_structure_when_complex_paths() throws MojoFailureException, MojoExecutionException, IOException { + void should_not_replicate_source_structure_when_complex_paths() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment/../relative-path-treatment"); File outputDir = newOutputTestDirectory("relative"); @@ -521,7 +518,7 @@ public void should_not_replicate_source_structure_when_complex_paths() throws Mo * - all documents but 1 (in the root) are incorrectly converted because they cannot find the imported file */ @Test - public void should_replicate_source_structure_when_no_baseDir_rewrite() throws MojoFailureException, MojoExecutionException, IOException { + void should_replicate_source_structure_when_no_baseDir_rewrite() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment"); File outputDir = newOutputTestDirectory("relative"); @@ -534,7 +531,7 @@ public void should_replicate_source_structure_when_no_baseDir_rewrite() throws M mojo.preserveDirectories = true; mojo.baseDir = srcDir; //mojo.relativeBaseDir = true - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.execute(); // then @@ -562,7 +559,7 @@ public void should_replicate_source_structure_when_no_baseDir_rewrite() throws M * Expected: all documents are correctly converted in the same folder */ @Test - public void should_not_replicate_source_structure_when_baseDir_rewrite() throws MojoFailureException, MojoExecutionException, IOException { + void should_not_replicate_source_structure_when_baseDir_rewrite() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment"); File outputDir = newOutputTestDirectory("relative"); @@ -574,7 +571,7 @@ public void should_not_replicate_source_structure_when_baseDir_rewrite() throws mojo.outputDirectory = outputDir; mojo.preserveDirectories = false; mojo.relativeBaseDir = true; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.execute(); // then @@ -592,7 +589,7 @@ public void should_not_replicate_source_structure_when_baseDir_rewrite() throws } @Test - public void should_copy_all_resources_into_output_folder() throws MojoFailureException, MojoExecutionException { + void should_copy_all_resources_into_output_folder() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory("multiple-resources-multiple-sources"); String relativeTestsPath = DEFAULT_SOURCE_DIRECTORY + "/relative-path-treatment"; @@ -636,7 +633,7 @@ public void should_copy_all_resources_into_output_folder() throws MojoFailureExc } @Test - public void should_not_copy_files_in_hidden_directories() throws MojoFailureException, MojoExecutionException { + void should_not_copy_files_in_hidden_directories() throws MojoFailureException, MojoExecutionException { // given String relativeTestsPath = DEFAULT_SOURCE_DIRECTORY + "/relative-path-treatment"; File outputDir = newOutputTestDirectory("hidden-resources"); @@ -659,7 +656,7 @@ public void should_not_copy_files_in_hidden_directories() throws MojoFailureExce } @Test - public void should_not_copy_custom_source_documents_when_custom_extensions_are_set() throws MojoFailureException, MojoExecutionException { + void should_not_copy_custom_source_documents_when_custom_extensions_are_set() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory("resources"); @@ -683,7 +680,7 @@ public void should_not_copy_custom_source_documents_when_custom_extensions_are_s } @Test - public void should_only_convert_documents_and_not_copy_any_resources_when_resources_directory_does_no_exist() throws MojoFailureException, MojoExecutionException { + void should_only_convert_documents_and_not_copy_any_resources_when_resources_directory_does_no_exist() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory("multiple-sources-error-source-not-found"); @@ -706,7 +703,7 @@ public void should_only_convert_documents_and_not_copy_any_resources_when_resour } @Test - public void should_convert_single_document_and_not_copy_any_resources_when_excluding_all_resources() throws MojoFailureException, MojoExecutionException { + void should_convert_single_document_and_not_copy_any_resources_when_excluding_all_resources() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory(); @@ -727,7 +724,7 @@ public void should_convert_single_document_and_not_copy_any_resources_when_exclu } @Test - public void should_only_convert_a_single_file_and_not_copy_any_resource() throws MojoFailureException, MojoExecutionException { + void should_only_convert_a_single_file_and_not_copy_any_resource() throws MojoFailureException, MojoExecutionException { // given File outputDir = newOutputTestDirectory("multiple-resources-file-pattern"); @@ -751,7 +748,7 @@ public void should_only_convert_a_single_file_and_not_copy_any_resource() throws } @Test - public void should_require_ruby_gem() throws MojoFailureException, MojoExecutionException { + void should_require_ruby_gem() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -774,7 +771,7 @@ public void should_require_ruby_gem() throws MojoFailureException, MojoExecution } @Test - public void should_embed_resources() throws MojoFailureException, MojoExecutionException { + void should_embed_resources() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("embedAssets"); @@ -785,7 +782,7 @@ public void should_embed_resources() throws MojoFailureException, MojoExecutionE mojo.sourceDocumentName = "sample-embedded.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; - mojo.attributes = map("icons", "font"); + mojo.attributes = Map.of("icons", "font"); mojo.embedAssets = true; mojo.execute(); @@ -801,7 +798,7 @@ public void should_embed_resources() throws MojoFailureException, MojoExecutionE // issue-78 @Test - public void should_embed_image_in_included_adoc() throws MojoFailureException, MojoExecutionException { + void should_embed_image_in_included_adoc() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File("target/test-classes/src/asciidoctor/issue-78"); File outputDir = newOutputTestDirectory("embedAssets"); @@ -824,7 +821,7 @@ public void should_embed_image_in_included_adoc() throws MojoFailureException, M } @Test - public void should_pass_images_directory_as_attribute() throws MojoFailureException, MojoExecutionException { + void should_pass_images_directory_as_attribute() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory(); @@ -835,7 +832,7 @@ public void should_pass_images_directory_as_attribute() throws MojoFailureExcept mojo.sourceDirectory = srcDir; mojo.sourceDocumentName = "imageDir.adoc"; mojo.outputDirectory = outputDir; - mojo.attributes = map("imagesdir", "custom-images-dir"); + mojo.attributes = Map.of("imagesdir", "custom-images-dir"); mojo.execute(); // then @@ -844,7 +841,7 @@ public void should_pass_images_directory_as_attribute() throws MojoFailureExcept } @Test - public void should_pass_attributes_from_pom_configuration() throws MojoFailureException, MojoExecutionException { + void should_pass_attributes_from_pom_configuration() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("attributes"); @@ -855,7 +852,7 @@ public void should_pass_attributes_from_pom_configuration() throws MojoFailureEx mojo.sourceDocumentName = "attributes-example.adoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; - mojo.attributes = map( + mojo.attributes = Map.of( "plugin-configuration-attribute", "plugin configuration", "execution-attribute", "execution configuration" ); @@ -869,13 +866,13 @@ public void should_pass_attributes_from_pom_configuration() throws MojoFailureEx } @Test - public void should_pass_attributes_from_maven_properties() throws MojoFailureException, MojoExecutionException { + void should_pass_attributes_from_maven_properties() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("attributes"); // when - AsciidoctorMojo mojo = mockAsciidoctorMojo(map("project.property.attribute", "project property configuration")); + AsciidoctorMojo mojo = mockAsciidoctorMojo(Map.of("project.property.attribute", "project property configuration")); mojo.backend = "html5"; mojo.sourceDocumentName = "attributes-example.adoc"; mojo.sourceDirectory = srcDir; @@ -889,7 +886,7 @@ public void should_pass_attributes_from_maven_properties() throws MojoFailureExc } @Test - public void command_line_attributes_should_replace_configurations_and_attributes() throws MojoFailureException, MojoExecutionException { + void command_line_attributes_should_replace_configurations_and_attributes() throws MojoFailureException, MojoExecutionException { // given File srcDir = new File(DEFAULT_SOURCE_DIRECTORY); File outputDir = newOutputTestDirectory("configuration"); @@ -900,7 +897,7 @@ public void command_line_attributes_should_replace_configurations_and_attributes mojo.sourceDocumentName = "sample.asciidoc"; mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; - mojo.attributes = map( + mojo.attributes = Map.of( "toc", "left", "source-highlighter", "coderay"); // replace some options @@ -914,7 +911,7 @@ public void command_line_attributes_should_replace_configurations_and_attributes } @Test - public void should_show_message_when_overwriting_files_without_outputFile() throws MojoFailureException, MojoExecutionException { + void should_show_message_when_overwriting_files_without_outputFile() throws MojoFailureException, MojoExecutionException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); // srcDir contains 6 documents, 2 of them with the same name (HellowWorld3.adoc) @@ -943,7 +940,7 @@ public void should_show_message_when_overwriting_files_without_outputFile() thro } @Test - public void should_show_message_when_overwriting_files_using_outputFile() throws MojoFailureException, MojoExecutionException { + void should_show_message_when_overwriting_files_using_outputFile() throws MojoFailureException, MojoExecutionException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); File srcDir = new File(DEFAULT_SOURCE_DIRECTORY, "relative-path-treatment/"); @@ -971,7 +968,7 @@ public void should_show_message_when_overwriting_files_using_outputFile() throws @SneakyThrows @Test - public void should_not_show_message_when_overwriting_files_using_outputFile_and_preserveDirectories() { + void should_not_show_message_when_overwriting_files_using_outputFile_and_preserveDirectories() { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); File srcDir = new File(DEFAULT_SOURCE_DIRECTORY, "/relative-path-treatment/"); @@ -997,5 +994,4 @@ public void should_not_show_message_when_overwriting_files_using_outputFile_and_ // cleanup consoleHolder.release(); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorRefreshMojoTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorRefreshMojoTest.java index 8f9a5191..a05545cf 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorRefreshMojoTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorRefreshMojoTest.java @@ -24,13 +24,13 @@ import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; -public class AsciidoctorRefreshMojoTest { +class AsciidoctorRefreshMojoTest { private static final String TEST_DIR = "refresh-mojo"; @Test - public void should_stop_with_exit_command() { + void should_stop_with_exit_command() { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -49,7 +49,7 @@ public void should_stop_with_exit_command() { } @Test - public void should_stop_with_quit_command() { + void should_stop_with_quit_command() { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -68,7 +68,7 @@ public void should_stop_with_quit_command() { } @Test - public void should_show_tip_when_command_is_not_valid() { + void should_show_tip_when_command_is_not_valid() { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -88,7 +88,7 @@ public void should_show_tip_when_command_is_not_valid() { } @Test - public void should_only_auto_convert_file_with_custom_sourceDocumentName_when_source_is_updated() throws IOException { + void should_only_auto_convert_file_with_custom_sourceDocumentName_when_source_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -136,7 +136,7 @@ public void should_only_auto_convert_file_with_custom_sourceDocumentName_when_so } @Test - public void should_auto_convert_file_with_custom_file_extension_when_source_is_updated() throws IOException { + void should_auto_convert_file_with_custom_file_extension_when_source_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -178,7 +178,7 @@ public void should_auto_convert_file_with_custom_file_extension_when_source_is_u } @Test - public void should_auto_convert_file_in_root_when_source_is_updated() throws IOException { + void should_auto_convert_file_in_root_when_source_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -214,7 +214,7 @@ public void should_auto_convert_file_in_root_when_source_is_updated() throws IOE } @Test - public void should_auto_convert_file_in_subDir_when_source_is_updated() throws IOException { + void should_auto_convert_file_in_subDir_when_source_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -250,7 +250,7 @@ public void should_auto_convert_file_in_subDir_when_source_is_updated() throws I } @Test - public void should_auto_convert_file_when_new_source_is_created() throws IOException { + void should_auto_convert_file_when_new_source_is_created() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -290,7 +290,7 @@ public void should_auto_convert_file_when_new_source_is_created() throws IOExcep } @Test - public void should_copy_resources_when_updated_but_not_on_start_when_there_are_no_sources() throws IOException { + void should_copy_resources_when_updated_but_not_on_start_when_there_are_no_sources() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -326,7 +326,7 @@ public void should_copy_resources_when_updated_but_not_on_start_when_there_are_n } @Test - public void should_convert_additional_sources_when_set_in_refreshOn() throws IOException { + void should_convert_additional_sources_when_set_in_refreshOn() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -385,7 +385,7 @@ public void should_convert_additional_sources_when_set_in_refreshOn() throws IOE } @Test - public void should_copy_resource_in_root_when_resource_is_updated() throws IOException { + void should_copy_resource_in_root_when_resource_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -424,7 +424,7 @@ public void should_copy_resource_in_root_when_resource_is_updated() throws IOExc } @Test - public void should_copy_resource_in_subDir_when_resource_is_updated() throws IOException { + void should_copy_resource_in_subDir_when_resource_is_updated() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -464,7 +464,7 @@ public void should_copy_resource_in_subDir_when_resource_is_updated() throws IOE } @Test - public void should_copy_resource_to_targetPath_in_resource_when_resources_configuration_is_set() throws IOException { + void should_copy_resource_to_targetPath_in_resource_when_resources_configuration_is_set() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -517,7 +517,7 @@ public void should_copy_resource_to_targetPath_in_resource_when_resources_config } @Test - public void should_copy_resource_to_outputDirectory_in_resource_when_resources_configuration_does_not_set_targePath() throws IOException { + void should_copy_resource_to_outputDirectory_in_resource_when_resources_configuration_does_not_set_targePath() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -569,7 +569,7 @@ public void should_copy_resource_to_outputDirectory_in_resource_when_resources_c } @Test - public void should_ignore_resource_file_when_matches_custom_source_file_extensions() throws IOException { + void should_ignore_resource_file_when_matches_custom_source_file_extensions() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -625,7 +625,7 @@ public void should_ignore_resource_file_when_matches_custom_source_file_extensio } @Test - public void should_ignore_resource_file_when_matches_custom_source_sourceDocumentName() throws IOException { + void should_ignore_resource_file_when_matches_custom_source_sourceDocumentName() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -685,7 +685,7 @@ public void should_ignore_resource_file_when_matches_custom_source_sourceDocumen } @Test - public void should_copy_resource_when_new_resource_is_created() throws IOException { + void should_copy_resource_when_new_resource_is_created() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); @@ -727,7 +727,7 @@ public void should_copy_resource_when_new_resource_is_created() throws IOExcepti } @Test - public void should_run_full_convert_with_refresh_command() throws IOException { + void should_run_full_convert_with_refresh_command() throws IOException { // given final ConsoleHolder consoleHolder = ConsoleHolder.start(); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorZipMojoTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorZipMojoTest.java index d341ca8e..eaeadac7 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorZipMojoTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorZipMojoTest.java @@ -21,11 +21,11 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AsciidoctorZipMojoTest { +class AsciidoctorZipMojoTest { @Test - public void should_create_simple_zip() throws IOException, MojoFailureException, MojoExecutionException { + void should_create_simple_zip() throws IOException, MojoFailureException, MojoExecutionException { // given: an empty output directory File outputDir = TestFilesHelper.newOutputTestDirectory("asciidoctor-zip-output"); @@ -63,7 +63,7 @@ public void should_create_simple_zip() throws IOException, MojoFailureException, } @Test - public void should_replicate_source_structure_in_zip_standard_paths() throws MojoFailureException, MojoExecutionException, IOException { + void should_replicate_source_structure_in_zip_standard_paths() throws MojoFailureException, MojoExecutionException, IOException { // given File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment"); File outputDir = TestFilesHelper.newOutputTestDirectory("asciidoctor-zip-output"); @@ -109,7 +109,7 @@ public void should_replicate_source_structure_in_zip_standard_paths() throws Moj } @Test - public void should_not_replicate_source_structure_in_zip_standard_paths() throws IOException, MojoFailureException, MojoExecutionException { + void should_not_replicate_source_structure_in_zip_standard_paths() throws IOException, MojoFailureException, MojoExecutionException { // setup File srcDir = new File("src/test/resources/src/asciidoctor/relative-path-treatment"); File outputDir = TestFilesHelper.newOutputTestDirectory("asciidoctor-zip-output"); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/SourceDirectoryFinderTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/SourceDirectoryFinderTest.java index 62cfc87f..b8247cfc 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/SourceDirectoryFinderTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/SourceDirectoryFinderTest.java @@ -12,10 +12,10 @@ import static org.asciidoctor.maven.process.SourceDirectoryFinder.ORDERED_CANDIDATE_PATHS; import static org.assertj.core.api.Assertions.assertThat; -public class SourceDirectoryFinderTest { +class SourceDirectoryFinderTest { @TempDir - public File testDirectory; + private File testDirectory; private static final File MOJO_DEFAULT_SOURCE_DIR = new File(SourceDirectoryFinder.DEFAULT_SOURCE_DIR); private static final File[] FALLBACK_CANDIDATES = new File[]{ @@ -23,12 +23,12 @@ public class SourceDirectoryFinderTest { new File(ORDERED_CANDIDATE_PATHS[2]), }; - public static final Consumer EMPTY_CONSUMER = dir -> { + static final Consumer EMPTY_CONSUMER = dir -> { }; @Test - public void should_not_try_candidates_and_not_find_when_initial_does_not_match_default_value() { + void should_not_try_candidates_and_not_find_when_initial_does_not_match_default_value() { // given final File fakePath = new File("fake_path"); @@ -43,7 +43,7 @@ public void should_not_try_candidates_and_not_find_when_initial_does_not_match_d } @Test - public void should_not_try_candidates_and_find_when_initial_does_not_match_default_value() { + void should_not_try_candidates_and_find_when_initial_does_not_match_default_value() { // given final File fakePath = new File("fake_path"); new File(testDirectory, fakePath.toString()).mkdirs(); @@ -57,7 +57,7 @@ public void should_not_try_candidates_and_find_when_initial_does_not_match_defau } @Test - public void should_find_default_candidate_when_set_as_relative_path() { + void should_find_default_candidate_when_set_as_relative_path() { // given final File candidate = MOJO_DEFAULT_SOURCE_DIR; new File(testDirectory, candidate.toString()).mkdirs(); @@ -73,7 +73,7 @@ public void should_find_default_candidate_when_set_as_relative_path() { } @Test - public void should_find_default_candidate_when_set_as_absolute_path() { + void should_find_default_candidate_when_set_as_absolute_path() { // given final File candidate = new File(testDirectory, MOJO_DEFAULT_SOURCE_DIR.toString()); candidate.mkdirs(); @@ -89,7 +89,7 @@ public void should_find_default_candidate_when_set_as_absolute_path() { } @Test - public void should_find_first_fallback_candidate_when_set_as_relative_path() { + void should_find_first_fallback_candidate_when_set_as_relative_path() { // given final File candidate = FALLBACK_CANDIDATES[0]; new File(testDirectory, FALLBACK_CANDIDATES[0].toString()).mkdirs(); @@ -106,7 +106,7 @@ public void should_find_first_fallback_candidate_when_set_as_relative_path() { } @Test - public void should_find_first_fallback_candidate_when_set_as_absolute_path() { + void should_find_first_fallback_candidate_when_set_as_absolute_path() { // given final File candidate = new File(testDirectory, FALLBACK_CANDIDATES[0].toString()); candidate.mkdirs(); @@ -123,7 +123,7 @@ public void should_find_first_fallback_candidate_when_set_as_absolute_path() { } @Test - public void should_find_second_fallback_candidate_when_set_as_relative_path() { + void should_find_second_fallback_candidate_when_set_as_relative_path() { // given final File candidate = FALLBACK_CANDIDATES[1]; new File(testDirectory, FALLBACK_CANDIDATES[1].toString()).mkdirs(); @@ -140,7 +140,7 @@ public void should_find_second_fallback_candidate_when_set_as_relative_path() { } @Test - public void should_find_second_fallback_candidate_when_set_as_absolute_path() { + void should_find_second_fallback_candidate_when_set_as_absolute_path() { // given final File candidate = new File(testDirectory, FALLBACK_CANDIDATES[1].toString()); candidate.mkdirs(); @@ -157,7 +157,7 @@ public void should_find_second_fallback_candidate_when_set_as_absolute_path() { } @Test - public void should_try_all_candidates_and_not_find_any_candidate_when_initial_is_default() { + void should_try_all_candidates_and_not_find_any_candidate_when_initial_is_default() { // given final File defaultSourceDir = MOJO_DEFAULT_SOURCE_DIR; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/TestUtils.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/TestUtils.java index 78b9d38f..49379fd9 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/TestUtils.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/TestUtils.java @@ -6,7 +6,6 @@ import org.apache.maven.project.MavenProject; import org.asciidoctor.maven.log.LogHandler; import org.asciidoctor.maven.model.Resource; -import org.assertj.core.api.Assertions; import org.mockito.Mockito; import java.io.File; @@ -18,6 +17,7 @@ import static java.util.Collections.singletonList; import static org.asciidoctor.maven.process.SourceDocumentFinder.STANDARD_FILE_EXTENSIONS_PATTERN; +import static org.assertj.core.api.Assertions.assertThat; import static org.codehaus.plexus.util.ReflectionUtils.setVariableValueInObject; import static org.mockito.Mockito.when; @@ -73,25 +73,6 @@ private static T mockAsciidoctorMojo(Class clazz, Map mav return (T) mojo; } - public static Map map(String key1, T value1) { - return Collections.singletonMap(key1, value1); - } - - public static Map map(String key1, Object value1, String key2, Object value2) { - Map map = new HashMap<>(); - map.put(key1, value1); - map.put(key2, value2); - return map; - } - - public static Map map(String key1, Object value1, String key2, Object value2, String key3, Object value3) { - Map map = new HashMap<>(); - map.put(key1, value1); - map.put(key2, value2); - map.put(key3, value3); - return map; - } - @SneakyThrows public static String readAsString(File file) { return IOUtils.toString(new FileReader(file)); @@ -155,15 +136,12 @@ public static List excludeAll() { public static void assertEqualsStructure(File[] expected, File[] actual) { List sanitizedExpected = Arrays.stream(expected) - .filter(file -> { - char firstChar = file.getName().charAt(0); - return firstChar != '_' && firstChar != '.'; - }) + .filter(TestUtils::isHidden) .collect(Collectors.toList()); List expectedNames = sanitizedExpected.stream().map(File::getName).collect(Collectors.toList()); List actualNames = Arrays.stream(actual).map(File::getName).collect(Collectors.toList()); - Assertions.assertThat(expectedNames).containsExactlyInAnyOrder(actualNames.toArray(new String[]{})); + assertThat(expectedNames).containsExactlyInAnyOrder(actualNames.toArray(new String[]{})); for (File actualFile : actual) { File expectedFile = sanitizedExpected.stream() @@ -179,11 +157,15 @@ public static void assertEqualsStructure(File[] expected, File[] actual) { File[] htmls = actualFile.listFiles(f -> f.getName().endsWith("html")); if (htmls.length > 0) { File[] asciiDocs = expectedFile.listFiles(f -> f.getName().matches(STANDARD_FILE_EXTENSIONS_PATTERN)); - Assertions.assertThat(htmls).hasSize(asciiDocs.length); + assertThat(htmls).hasSize(asciiDocs.length); } File[] actualChildren = actualFile.listFiles(File::isDirectory); assertEqualsStructure(expectedChildren, actualChildren); } } + private static boolean isHidden(File file) { + char firstChar = file.getName().charAt(0); + return firstChar != '_' && firstChar != '.'; + } } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/extensions/AsciidoctorJExtensionRegistryTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/extensions/AsciidoctorJExtensionRegistryTest.java index 09d751cf..8e56d9b4 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/extensions/AsciidoctorJExtensionRegistryTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/extensions/AsciidoctorJExtensionRegistryTest.java @@ -10,7 +10,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AsciidoctorJExtensionRegistryTest { +class AsciidoctorJExtensionRegistryTest { private JavaExtensionRegistry javaExtensionRegistry; private AsciidoctorJExtensionRegistry pluginExtensionRegistry; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/http/AsciidoctorHttpServerTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/http/AsciidoctorHttpServerTest.java index 5abb1600..ce1fe894 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/http/AsciidoctorHttpServerTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/http/AsciidoctorHttpServerTest.java @@ -21,13 +21,13 @@ import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; -public class AsciidoctorHttpServerTest { +class AsciidoctorHttpServerTest { private static final Random RANDOM = new Random(); @Test - public void should_start_and_stop_server() { + void should_start_and_stop_server() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -51,7 +51,7 @@ public void should_start_and_stop_server() { } @Test - public void should_return_404_when_resource_does_not_exist() { + void should_return_404_when_resource_does_not_exist() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -73,7 +73,7 @@ public void should_return_404_when_resource_does_not_exist() { } @Test - public void should_return_405_when_method_is_not_GET_or_HEAD() { + void should_return_405_when_method_is_not_GET_or_HEAD() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -97,7 +97,7 @@ public void should_return_405_when_method_is_not_GET_or_HEAD() { } @Test - public void should_return_205_when_method_is_HEAD_and_resource_exists() { + void should_return_205_when_method_is_HEAD_and_resource_exists() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -122,7 +122,7 @@ public void should_return_205_when_method_is_HEAD_and_resource_exists() { } @Test - public void should_return_404_when_method_is_HEAD_does_not_exists() { + void should_return_404_when_method_is_HEAD_does_not_exists() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -146,7 +146,7 @@ public void should_return_404_when_method_is_HEAD_does_not_exists() { } @Test - public void should_return_modified_html_content_without_modifying_original() { + void should_return_modified_html_content_without_modifying_original() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -174,7 +174,7 @@ public void should_return_modified_html_content_without_modifying_original() { } @Test - public void should_return_non_html_content_without_modifications() { + void should_return_non_html_content_without_modifications() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); @@ -202,7 +202,7 @@ public void should_return_non_html_content_without_modifications() { } @Test - public void should_return_default_resource_when_url_is_root() { + void should_return_default_resource_when_url_is_root() { // given int port = randomPort(); final File outputDir = newOutputTestDirectory(); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/StringsCollectionsInputStream.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/StringsCollectionsInputStream.java index 5f92d311..e047bdc7 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/StringsCollectionsInputStream.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/StringsCollectionsInputStream.java @@ -18,7 +18,7 @@ class StringsCollectionsInputStream extends InputStream { private static final String LINEBREAK = "\r\n"; - private AtomicInteger index = new AtomicInteger(0); + private final AtomicInteger index = new AtomicInteger(0); private final List lines = new ArrayList<>(); private volatile Semaphore mutex = new Semaphore(1); @@ -30,7 +30,7 @@ public StringsCollectionsInputStream() { @SneakyThrows @Override - public int read() throws IOException { + public int read() { mutex.acquire(); int indexValue = index.get(); return indexValue >= lines.size() ? -1 : lines.get(indexValue).charAt(0); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/TestFilesHelper.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/TestFilesHelper.java index 5da2a06f..29686859 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/TestFilesHelper.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/TestFilesHelper.java @@ -19,8 +19,7 @@ public static File newOutputTestDirectory(String subDir) { } private static File createDirectory(String path) { - final File file = new File(path); - return file; + return new File(path); } public static File createFileWithContent(File srcDir, String filename) { diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/CopyResourcesProcessorTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/CopyResourcesProcessorTest.java index ddc926be..f27b52ad 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/CopyResourcesProcessorTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/CopyResourcesProcessorTest.java @@ -383,5 +383,4 @@ void should_not_copy_any_resource() { assertThat(outputDir.list()).hasSize(0); } } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/SourceDocumentFinderTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/SourceDocumentFinderTest.java index 33d76d8f..16c4137d 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/SourceDocumentFinderTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/process/SourceDocumentFinderTest.java @@ -10,12 +10,12 @@ import static org.assertj.core.api.Assertions.assertThat; -public class SourceDocumentFinderTest { +class SourceDocumentFinderTest { private static final String DEFAULT_SOURCE_DIRECTORY = "src/test/resources/src/asciidoctor"; @Test - public void should_init_SourceDocumentFinder() { + void should_init_SourceDocumentFinder() { // when SourceDocumentFinder walker = new SourceDocumentFinder(); // then @@ -23,7 +23,7 @@ public void should_init_SourceDocumentFinder() { } @Test - public void should_match_standard_file_extensions() { + void should_match_standard_file_extensions() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/file-extensions"; @@ -38,7 +38,7 @@ public void should_match_standard_file_extensions() { } @Test - public void should_match_custom_file_extension() { + void should_match_custom_file_extension() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/file-extensions"; @@ -52,7 +52,7 @@ public void should_match_custom_file_extension() { } @Test - public void should_match_custom_file_extensions() { + void should_match_custom_file_extensions() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/file-extensions"; List customFileExtensions = Arrays.asList("my-adoc", "adoc"); @@ -68,7 +68,7 @@ public void should_match_custom_file_extensions() { } @Test - public void should_not_match_custom_empty_file_extensions() { + void should_not_match_custom_empty_file_extensions() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/file-extensions"; @@ -81,7 +81,7 @@ public void should_not_match_custom_empty_file_extensions() { } @Test - public void should_return_empty_list_if_wrong_source_directory() { + void should_return_empty_list_if_wrong_source_directory() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/file-extensions/non-existing"; @@ -94,7 +94,7 @@ public void should_return_empty_list_if_wrong_source_directory() { } @Test - public void should_exclude_hidden_sources() { + void should_exclude_hidden_sources() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/relative-path-treatment"; final List fileExtensions = Collections.singletonList("adoc"); @@ -109,7 +109,7 @@ public void should_exclude_hidden_sources() { } @Test - public void should_not_treat_enclosing_parent_paths_as_hidden() { + void should_not_treat_enclosing_parent_paths_as_hidden() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/source-finder/_enclosing/src/"; final List fileExtensions = Collections.singletonList("adoc"); @@ -125,7 +125,7 @@ public void should_not_treat_enclosing_parent_paths_as_hidden() { } @Test - public void should_exclude_hidden_directories() { + void should_exclude_hidden_directories() { // given final String rootDirectory = DEFAULT_SOURCE_DIRECTORY + "/relative-path-treatment"; final List fileExtensions = Collections.singletonList("adoc"); diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptorTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptorTest.java index f7d98837..c0d6a42d 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptorTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptorTest.java @@ -19,7 +19,7 @@ import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; -public class ResourceCopyFileAlterationListenerAdaptorTest { +class ResourceCopyFileAlterationListenerAdaptorTest { private static final String TEST_DIR = "resource-copy-listener"; @@ -28,7 +28,7 @@ public class ResourceCopyFileAlterationListenerAdaptorTest { @Test - public void should_copy_files_when_match_resource_includes() { + void should_copy_files_when_match_resource_includes() { // given final File srcDir = newOutputTestDirectory(TEST_DIR); final File outputDir = newOutputTestDirectory(TEST_DIR); @@ -67,7 +67,7 @@ public void should_copy_files_when_match_resource_includes() { } @Test - public void should_not_copy_files_when_match_resource_excludes() { + void should_not_copy_files_when_match_resource_excludes() { // given final File srcDir = newOutputTestDirectory(TEST_DIR); final File outputDir = newOutputTestDirectory(TEST_DIR); @@ -106,7 +106,7 @@ public void should_not_copy_files_when_match_resource_excludes() { } @Test - public void should_copy_and_ignore_files_when_matching_both_resource_includes_and_excludes() { + void should_copy_and_ignore_files_when_matching_both_resource_includes_and_excludes() { // given final File srcDir = newOutputTestDirectory(TEST_DIR); final File outputDir = newOutputTestDirectory(TEST_DIR); @@ -147,7 +147,7 @@ public void should_copy_and_ignore_files_when_matching_both_resource_includes_an // Removal of special files is done by FileAlterationObserver, not ResourceCopyFileAlterationListenerAdaptor @Test - public void should_copy_special_asciidoctor_files() { + void should_copy_special_asciidoctor_files() { // given final File srcDir = newOutputTestDirectory(TEST_DIR); final File outputDir = newOutputTestDirectory(TEST_DIR); @@ -186,5 +186,4 @@ public void should_copy_special_asciidoctor_files() { assertThat(outputCandidate).exists(); }); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilderTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilderTest.java index 3218ed1c..e120dd8c 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilderTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/refresh/ResourcesPatternBuilderTest.java @@ -7,13 +7,13 @@ import static org.assertj.core.api.Assertions.assertThat; -public class ResourcesPatternBuilderTest { +class ResourcesPatternBuilderTest { private static final String DOC_INFO_FILES = "docinfo\\.html|docinfo-header\\.html|docinfo-footer\\.html|\\.*-docinfo\\.html|\\.*-docinfo-header\\.html|\\.*-docinfo-footer\\.html|docinfo\\.xml|docinfo-header\\.xml|docinfo-footer\\.xml|\\.*-docinfo\\.xml|\\.*-docinfo-header\\.xml|\\.*-docinfo-footer\\.xml"; private static final String ASCIIDOC_SOURCES = "(a((sc(iidoc)?)|d(oc)?))"; @Test - public void should_build_default_pattern() { + void should_build_default_pattern() { // given ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("", Collections.emptyList()); // when @@ -24,7 +24,7 @@ public void should_build_default_pattern() { } @Test - public void should_build_pattern_with_sourceDocumentName() { + void should_build_pattern_with_sourceDocumentName() { // given ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("fixed-source.name", Collections.emptyList()); // when @@ -35,7 +35,7 @@ public void should_build_pattern_with_sourceDocumentName() { } @Test - public void should_build_pattern_with_sourceDocumentExtensions() { + void should_build_pattern_with_sourceDocumentExtensions() { // given ResourcesPatternBuilder patternBuilder = new ResourcesPatternBuilder("", Arrays.asList("my-docs", "md")); // when @@ -44,5 +44,4 @@ public void should_build_pattern_with_sourceDocumentExtensions() { assertThat(pattern) .isEqualTo("^(?!(" + DOC_INFO_FILES + "))[^_.].*\\.(?!(a((sc(iidoc)?)|d(oc)?)|my-docs|md)).*$"); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/AutoregisteredProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/AutoregisteredProcessor.java index d80f4eba..267ac005 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/AutoregisteredProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/AutoregisteredProcessor.java @@ -8,10 +8,7 @@ public class AutoregisteredProcessor implements ExtensionRegistry { @Override public void register(Asciidoctor asciidoctor) { - - JavaExtensionRegistry javaExtensionRegistry = asciidoctor.javaExtensionRegistry(); - javaExtensionRegistry.preprocessor(ChangeAttributeValuePreprocessor.class); - + asciidoctor.javaExtensionRegistry() + .preprocessor(ChangeAttributeValuePreprocessor.class); } - -} \ No newline at end of file +} diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ChangeAttributeValuePreprocessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ChangeAttributeValuePreprocessor.java index 012a1f63..636d9ab7 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ChangeAttributeValuePreprocessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ChangeAttributeValuePreprocessor.java @@ -1,26 +1,24 @@ package org.asciidoctor.maven.test.processors; -import java.util.Map; - import org.asciidoctor.ast.Document; import org.asciidoctor.extension.Preprocessor; import org.asciidoctor.extension.PreprocessorReader; +import java.util.Map; + public class ChangeAttributeValuePreprocessor extends Preprocessor { public static final String AUTHOR_NAME = "ThisIsMe"; - + public ChangeAttributeValuePreprocessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public void process(Document document, PreprocessorReader reader) { - System.out.println("Processing "+ this.getClass().getSimpleName()); + System.out.println("Processing " + this.getClass().getSimpleName()); System.out.println("Processing: blocks found: " + document.getBlocks().size()); document.getAttributes().put("author", AUTHOR_NAME); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyPostprocessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyPostprocessor.java index f8e99252..60a45ee9 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyPostprocessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyPostprocessor.java @@ -1,24 +1,22 @@ package org.asciidoctor.maven.test.processors; -import java.util.Map; - import org.asciidoctor.ast.Document; import org.asciidoctor.extension.Postprocessor; +import java.util.Map; + public class DummyPostprocessor extends Postprocessor { public DummyPostprocessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public String process(Document document, String output) { - System.out.println("Processing "+ this.getClass().getSimpleName()); + System.out.println("Processing " + this.getClass().getSimpleName()); System.out.println("Processing: blocks found: " + document.getBlocks().size()); System.out.println("Processing: output size: " + output.length()); return output; } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyTreeprocessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyTreeprocessor.java index 9bdca09a..fde03d24 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyTreeprocessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/DummyTreeprocessor.java @@ -1,28 +1,26 @@ package org.asciidoctor.maven.test.processors; -import java.util.HashMap; -import java.util.Map; - import org.asciidoctor.ast.Document; import org.asciidoctor.extension.Treeprocessor; +import java.util.HashMap; +import java.util.Map; + public class DummyTreeprocessor extends Treeprocessor { public DummyTreeprocessor() { - super(new HashMap()); + super(new HashMap<>()); } public DummyTreeprocessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public Document process(Document document) { - System.out.println("Processing "+ this.getClass().getSimpleName()); + System.out.println("Processing " + this.getClass().getSimpleName()); System.out.println("Processing: blocks found: " + document.getBlocks().size()); return document; } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/FailingPreprocessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/FailingPreprocessor.java index 3545a28d..2a14aa36 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/FailingPreprocessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/FailingPreprocessor.java @@ -10,13 +10,12 @@ public class FailingPreprocessor extends Preprocessor { public FailingPreprocessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public void process(Document document, PreprocessorReader reader) { - System.out.println("Processing "+ this.getClass().getSimpleName()); + System.out.println("Processing " + this.getClass().getSimpleName()); System.out.println("Processing: blocks found: " + document.getBlocks().size()); throw new RuntimeException("That's all folks"); } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/GistBlockMacroProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/GistBlockMacroProcessor.java index 97caeade..a47c3db9 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/GistBlockMacroProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/GistBlockMacroProcessor.java @@ -4,7 +4,7 @@ import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.extension.BlockMacroProcessor; -import java.util.Arrays; +import java.util.List; import java.util.Map; public class GistBlockMacroProcessor extends BlockMacroProcessor { @@ -17,11 +17,10 @@ public GistBlockMacroProcessor(String macroName, Map config) { public Block process(StructuralNode parent, String target, Map attributes) { - String content = "

\n" + - "\n" + - "
"; + final String content = "
\n" + + "\n" + + "
"; - return createBlock(parent, "pass", Arrays.asList(content), attributes); + return createBlock(parent, "pass", List.of(content), attributes); } - - } +} diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ManpageInlineMacroProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ManpageInlineMacroProcessor.java index 8c132b93..0600ffb3 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ManpageInlineMacroProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/ManpageInlineMacroProcessor.java @@ -15,10 +15,9 @@ public ManpageInlineMacroProcessor(String macroName) { @Override public String process(ContentNode parent, String target, Map attributes) { - Map options = new HashMap(); + final Map options = new HashMap<>(); options.put("type", ":link"); options.put("target", target + ".html"); return createPhraseNode(parent, "anchor", target, attributes, options).convert(); } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/MetaDocinfoProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/MetaDocinfoProcessor.java index e1b03dc6..a68d9912 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/MetaDocinfoProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/MetaDocinfoProcessor.java @@ -1,23 +1,21 @@ package org.asciidoctor.maven.test.processors; -import java.util.Map; - import org.asciidoctor.ast.Document; import org.asciidoctor.extension.DocinfoProcessor; +import java.util.Map; + public class MetaDocinfoProcessor extends DocinfoProcessor { public MetaDocinfoProcessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public String process(Document document) { - System.out.println("Processing "+ this.getClass().getSimpleName()); + System.out.println("Processing " + this.getClass().getSimpleName()); System.out.println("Processing: blocks found: " + document.getBlocks().size()); return ""; } - } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/RequireCheckerTreeprocessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/RequireCheckerTreeprocessor.java index 52740959..26838964 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/RequireCheckerTreeprocessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/RequireCheckerTreeprocessor.java @@ -12,7 +12,8 @@ public class RequireCheckerTreeprocessor extends Treeprocessor { public Document process(Document document) { assertEquals("constant", JRubyRuntimeContext.get(document).evalScriptlet("defined? ::DateTime").toString()); // Leave a trace in the converted document so that the test can check that I was called - document.getBlocks().add(createBlock(document, "paragraph", RequireCheckerTreeprocessor.class.getSimpleName() + " was here")); + document.getBlocks() + .add(createBlock(document, "paragraph", RequireCheckerTreeprocessor.class.getSimpleName() + " was here")); return document; } } diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java index b64aa15e..644d2919 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/UriIncludeProcessor.java @@ -6,61 +6,39 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; -import java.net.MalformedURLException; import java.net.URL; import java.util.Map; +import java.util.stream.Collectors; public class UriIncludeProcessor extends IncludeProcessor { public UriIncludeProcessor(Map config) { super(config); - System.out.println(this.getClass().getSimpleName() + "(" - + this.getClass().getSuperclass().getSimpleName() + ") initialized"); + System.out.println(String.format("%s(%s) initialized", this.getClass().getSimpleName(), this.getClass().getSuperclass().getSimpleName())); } @Override public boolean handles(String target) { - return target.startsWith("http://") || target.startsWith("https://"); + return target.matches("^https?://.*"); } @Override public void process(Document document, PreprocessorReader reader, String target, Map attributes) { - - System.out.println("Processing "+ this.getClass().getSimpleName()); - - StringBuilder content = readContent(target); - reader.push_include(content.toString(), target, target, 1, attributes); - + System.out.println("Processing " + this.getClass().getSimpleName()); + final String content = readContent(target); + reader.push_include(content, target, target, 1, attributes); } - private StringBuilder readContent(String target) { - - StringBuilder content = new StringBuilder(); - - try { - - URL url = new URL(target); - InputStream openStream = url.openStream(); - - BufferedReader bufferedReader = new BufferedReader( - new InputStreamReader(openStream)); - - String line = null; - while ((line = bufferedReader.readLine()) != null) { - content.append(line + "\n"); + private String readContent(String target) { + try (var openStream = new URL(target).openStream()) { + try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openStream))) { + return bufferedReader.lines() + .collect(Collectors.joining("\n")); } - - bufferedReader.close(); - - } catch (MalformedURLException e) { - throw new IllegalArgumentException(e); } catch (IOException e) { - throw new IllegalArgumentException(e); + throw new RuntimeException(e); } - return content; } - - } +} diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/YellBlockProcessor.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/YellBlockProcessor.java index 10b43d62..937861ea 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/YellBlockProcessor.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/processors/YellBlockProcessor.java @@ -4,18 +4,18 @@ import org.asciidoctor.extension.BlockProcessor; import org.asciidoctor.extension.Reader; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class YellBlockProcessor extends BlockProcessor { @SuppressWarnings("serial") - private static Map configs = new HashMap() {{ - put("contexts", Arrays.asList(":listing")); - put("content_model", ":compound"); - }}; + private static Map configs = Map.of( + "contexts", List.of(":listing"), + "content_model", ":compound" + ); public YellBlockProcessor(String name, Map config) { super(name, configs); @@ -23,17 +23,11 @@ public YellBlockProcessor(String name, Map config) { @Override public Object process(StructuralNode parent, Reader reader, Map attributes) { - List lines = reader.readLines(); - String upperLines = null; - for (String line : lines) { - if (upperLines == null) { - upperLines = line.toUpperCase(); - } else { - upperLines = upperLines + "\n" + line.toUpperCase(); - } - } + final String upperLines = reader.readLines() + .stream() + .map(String::toUpperCase) + .collect(Collectors.joining("\n")); - return createBlock(parent, "paragraph", Arrays.asList(upperLines), attributes, new HashMap<>()); + return createBlock(parent, "paragraph", List.of(upperLines), attributes, new HashMap<>()); } - } diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParser.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParser.java index 8df4c921..7bb4ae01 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParser.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParser.java @@ -101,7 +101,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept private MemoryLogHandler asciidoctorLoggingSetup(Asciidoctor asciidoctor, LogHandler logHandler, File siteDirectory) { - final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), siteDirectory, + final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory))); asciidoctor.registerLogHandler(memoryLogHandler); // disable default console output of AsciidoctorJ diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParserTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParserTest.java index 82c54761..c21280fe 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParserTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/AsciidoctorAstDoxiaParserTest.java @@ -22,7 +22,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -public class AsciidoctorAstDoxiaParserTest { +class AsciidoctorAstDoxiaParserTest { private static final String TEST_DOCS_PATH = "src/test/resources/"; @@ -36,7 +36,7 @@ void setup() throws NoSuchFieldException, IllegalAccessException { } @Test - public void should_convert_html_without_any_configuration() throws FileNotFoundException, ParseException { + void should_convert_html_without_any_configuration() throws FileNotFoundException, ParseException { final File srcAsciidoc = new File(TEST_DOCS_PATH, "sample.asciidoc"); AsciidoctorAstDoxiaParser parser = mockAsciidoctorDoxiaParser(); @@ -58,7 +58,7 @@ public void should_convert_html_without_any_configuration() throws FileNotFoundE } @Test - public void should_convert_html_with_an_attribute() throws ParseException { + void should_convert_html_with_an_attribute() throws ParseException { final String source = "= Document Title\n\n" + "== Section A\n\n" + "My attribute value is {custom-attribute}.\n"; @@ -79,7 +79,7 @@ public void should_convert_html_with_an_attribute() throws ParseException { } @Test - public void should_process_empty_selfclosing_XML_attributes() throws ParseException { + void should_process_empty_selfclosing_XML_attributes() throws ParseException { final String source = sectionsSample(); AsciidoctorAstDoxiaParser parser = mockAsciidoctorDoxiaParser( @@ -101,7 +101,7 @@ public void should_process_empty_selfclosing_XML_attributes() throws ParseExcept } @Test - public void should_process_config_with_sectnumlevels() throws ParseException { + void should_process_config_with_sectnumlevels() throws ParseException { final String source = sectionsSample(); AsciidoctorAstDoxiaParser parser = mockAsciidoctorDoxiaParser( @@ -124,7 +124,7 @@ public void should_process_config_with_sectnumlevels() throws ParseException { } @Test - public void should_process_empty_value_XML_attributes() throws ParseException { + void should_process_empty_value_XML_attributes() throws ParseException { final String source = sectionsSample(); AsciidoctorAstDoxiaParser parser = mockAsciidoctorDoxiaParser( @@ -158,7 +158,7 @@ private static String sectionsSample() { } @Test - public void should_fail_when_logHandler_failIf_is_WARNING() { + void should_fail_when_logHandler_failIf_is_WARNING() { final String source = "= My Document\n\n" + "include::unexistingdoc.adoc[]\n\n" + "include::unexistingdoc.adoc[]"; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/NodeSinkerTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/NodeSinkerTest.java index 85e52f6d..25f97d52 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/NodeSinkerTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/NodeSinkerTest.java @@ -22,7 +22,7 @@ /** * Validate node processors are registered. */ -public class NodeSinkerTest { +class NodeSinkerTest { private NodesSinker nodesSinker; private StringWriter sinkWriter; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DocumentNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DocumentNodeProcessorTest.java index 26d45f8d..58192da3 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DocumentNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/DocumentNodeProcessorTest.java @@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(DocumentNodeProcessor.class) -public class DocumentNodeProcessorTest { +class DocumentNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessorTest.java index 127e83ee..a8170096 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessorTest.java @@ -16,7 +16,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ImageNodeProcessor.class) -public class ImageNodeProcessorTest { +class ImageNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessorTest.java index 3cc360ea..6ad9481c 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessorTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ListItemNodeProcessor.class) -public class ListItemNodeProcessorTest { +class ListItemNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListingNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListingNodeProcessorTest.java index 3e8b8b23..b733409d 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListingNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ListingNodeProcessorTest.java @@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ListingNodeProcessor.class) -public class ListingNodeProcessorTest { +class ListingNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/LiteralNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/LiteralNodeProcessorTest.java index fdb956d5..bf0b45df 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/LiteralNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/LiteralNodeProcessorTest.java @@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(LiteralNodeProcessor.class) -public class LiteralNodeProcessorTest { +class LiteralNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessorTest.java index 9f918538..6fb7687f 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessorTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(OrderedListNodeProcessor.class) -public class OrderedListNodeProcessorTest { +class OrderedListNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ParagraphNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ParagraphNodeProcessorTest.java index 0d2518b8..d60d137c 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ParagraphNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/ParagraphNodeProcessorTest.java @@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ParagraphNodeProcessor.class) -public class ParagraphNodeProcessorTest { +class ParagraphNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/PreambleNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/PreambleNodeProcessorTest.java index 58ae9cb2..77d76cdb 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/PreambleNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/PreambleNodeProcessorTest.java @@ -17,7 +17,7 @@ * by their respective processors. */ @NodeProcessorTest(PreambleNodeProcessor.class) -public class PreambleNodeProcessorTest { +class PreambleNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/SectionNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/SectionNodeProcessorTest.java index ce425152..e9c3cfce 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/SectionNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/SectionNodeProcessorTest.java @@ -14,7 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(SectionNodeProcessor.class) -public class SectionNodeProcessorTest { +class SectionNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessorTest.java index 0c7e594e..13b1376a 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessorTest.java @@ -27,7 +27,7 @@ * The tests refer to caption as the combination of both. */ @NodeProcessorTest(TableNodeProcessor.class) -public class TableNodeProcessorTest { +class TableNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessorTest.java index 761d6b47..2276835c 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessorTest.java @@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(UnorderedListNodeProcessor.class) -public class UnorderedListNodeProcessorTest { +class UnorderedListNodeProcessorTest { private Asciidoctor asciidoctor; private NodeProcessor nodeProcessor;