From d7e577a5813d12d06b2ab6df81ec34c56671991c Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sat, 27 Jan 2024 17:18:44 +0100 Subject: [PATCH] Add .editorconfig to help with formatting (#760) * Reformated imports for all Java files * Formatted some files (IntellJ issue) * Updated contributing.adoc --- .editorconfig | 14 ++ CHANGELOG.adoc | 2 +- README.adoc | 4 +- .../AsciidoctorConverterDoxiaParserTest.java | 8 +- .../maven/log/LogRecordFormatter.java | 6 +- .../maven/log/LogRecordsProcessors.java | 6 +- .../maven/log/MemoryLogHandler.java | 8 +- .../site/SiteConversionConfiguration.java | 4 +- .../SiteConversionConfigurationParser.java | 14 +- .../site/SiteLogHandlerDeserializer.java | 4 +- .../maven/commons/AsciidoctorHelperTest.java | 8 +- .../maven/log/LogRecordFormatterTest.java | 6 +- ...SiteConversionConfigurationParserTest.java | 16 +- .../asciidoctor/maven/AsciidoctorMojo.java | 28 +-- .../maven/AsciidoctorRefreshMojo.java | 16 +- .../asciidoctor/maven/AsciidoctorZipMojo.java | 6 +- .../maven/http/AsciidoctorHandler.java | 10 +- .../maven/http/AsciidoctorHttpServer.java | 8 +- .../java/org/asciidoctor/maven/io/Zips.java | 4 +- .../maven/process/CopyResourcesProcessor.java | 94 +++++----- .../maven/process/ResourcesProcessor.java | 4 +- ...AbstractFileAlterationListenerAdaptor.java | 4 +- ...alSourceFileAlterationListenerAdaptor.java | 4 +- ...onverterFileAlterationListenerAdaptor.java | 6 +- ...urceCopyFileAlterationListenerAdaptor.java | 12 +- .../maven/AsciidoctorAsserter.java | 6 +- .../maven/AsciidoctorHttpMojoTest.java | 16 +- .../maven/AsciidoctorIntegrationTest.java | 8 +- .../maven/AsciidoctorMojoExtensionsTest.java | 18 +- .../maven/AsciidoctorMojoLogHandlerTest.java | 104 ++++++------ .../maven/AsciidoctorMojoTest.java | 20 +-- .../maven/AsciidoctorRefreshMojoTest.java | 160 +++++++++--------- .../maven/AsciidoctorZipMojoTest.java | 90 +++++----- .../maven/SourceDirectoryFinderTest.java | 8 +- .../AsciidoctorJExtensionRegistryTest.java | 27 ++- .../maven/http/AsciidoctorHttpServerTest.java | 19 ++- .../asciidoctor/maven/io/ConsoleHolder.java | 4 +- .../maven/io/DoubleOutputStream.java | 4 +- .../maven/io/PrefilledInputStream.java | 4 +- .../io/StringsCollectionsInputStream.java | 5 +- .../asciidoctor/maven/io/TestFilesHelper.java | 4 +- .../maven/io/UserInputSimulator.java | 4 +- .../process/CopyResourcesProcessorTest.java | 14 +- .../process/SourceDocumentFinderTest.java | 4 +- ...CopyFileAlterationListenerAdaptorTest.java | 12 +- .../refresh/ResourcesPatternBuilderTest.java | 4 +- .../asciidoctor/maven/test/MojoMocker.java | 8 +- .../maven/test/MojoMockerTest.java | 4 +- .../org/asciidoctor/maven/test/TestUtils.java | 14 +- .../processors/AutoregisteredProcessor.java | 1 - .../ChangeAttributeValuePreprocessor.java | 4 +- .../test/processors/DummyPostprocessor.java | 4 +- .../test/processors/DummyTreeprocessor.java | 6 +- .../test/processors/FailingPreprocessor.java | 4 +- .../processors/GistBlockMacroProcessor.java | 6 +- .../ManpageInlineMacroProcessor.java | 6 +- .../test/processors/MetaDocinfoProcessor.java | 4 +- .../test/processors/UriIncludeProcessor.java | 8 +- .../test/processors/YellBlockProcessor.java | 8 +- .../site/ast/AsciidoctorAstDoxiaParser.java | 14 +- .../maven/site/ast/NodesSinker.java | 8 +- .../ast/processors/ImageNodeProcessor.java | 4 +- .../ast/processors/ListItemNodeProcessor.java | 4 +- .../processors/OrderedListNodeProcessor.java | 4 +- .../ast/processors/TableNodeProcessor.java | 4 +- .../UnorderedListNodeProcessor.java | 4 +- .../processors/ImageNodeProcessorTest.java | 12 +- .../processors/ListingNodeProcessorTest.java | 54 +++--- .../processors/LiteralNodeProcessorTest.java | 6 +- .../processors/TableNodeProcessorTest.java | 17 +- .../test/JUnitNodeProcessorExtension.java | 10 +- .../processors/test/NodeProcessorTest.java | 6 +- .../test/TestNodeProcessorFactory.java | 4 +- docs/modules/project/pages/contributing.adoc | 12 +- 74 files changed, 566 insertions(+), 505 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..98a99fd9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +tab_width = 4 + +[*.java] +ij_java_class_count_to_use_import_on_demand = 99 +ij_java_imports_layout = javax.**, java.**, |, *, |, $* + +[{*.yml,*.yaml}] +indent_size = 2 diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index f0fc5ba0..c43facf4 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -35,6 +35,7 @@ Improvements:: * Upgrade Asciidoctorj to v2.5.10 and jRuby to v9.4.2.0 (#647) * Upgrade Asciidoctorj to v2.5.11 (#688) * Improve warning message when destination file is going to be replaced (#728) + * Added `.editorconfig` file to facilitate code formatting (#760) Build / Infrastructure:: @@ -66,7 +67,6 @@ Build / Infrastructure:: * Automate release using GH Actions (#141) * Ensure Mojos use correct default values in unit tests (#609) - Maintenance:: * Replace use of reflection by direct JavaExtensionRegistry calls to register extensions (#596) diff --git a/README.adoc b/README.adoc index 7919c438..21044dbb 100644 --- a/README.adoc +++ b/README.adoc @@ -1,8 +1,8 @@ = Asciidoctor Maven Tools (Plugin & Site Integration) // Metadata -:release-version: 2.2.2 +:release-version: 2.2.5 :docs-version: 2.2 -:maven-site-plugin-version: 3.9.0 +:maven-site-plugin-version: 3.12.1 // Settings :idprefix: :idseparator: - 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 c219536a..0acc9e78 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 @@ -1,5 +1,11 @@ package org.asciidoctor.maven.site; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.Reader; +import java.io.StringReader; + import lombok.SneakyThrows; import org.apache.maven.doxia.parser.ParseException; import org.apache.maven.doxia.sink.Sink; @@ -9,8 +15,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.io.*; - import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; import static org.codehaus.plexus.util.ReflectionUtils.setVariableValueInObject; diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordFormatter.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordFormatter.java index 895fc192..1102bb29 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordFormatter.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordFormatter.java @@ -1,13 +1,13 @@ package org.asciidoctor.maven.log; -import org.asciidoctor.ast.Cursor; -import org.asciidoctor.log.LogRecord; - import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import org.asciidoctor.ast.Cursor; +import org.asciidoctor.log.LogRecord; + public class LogRecordFormatter { private static final String MESSAGE_HEADER = "asciidoctor"; diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordsProcessors.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordsProcessors.java index f8a3df58..0f5b673f 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordsProcessors.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/log/LogRecordsProcessors.java @@ -1,12 +1,12 @@ package org.asciidoctor.maven.log; -import org.asciidoctor.log.LogRecord; -import org.asciidoctor.log.Severity; - import java.io.File; import java.util.List; import java.util.function.Consumer; +import org.asciidoctor.log.LogRecord; +import org.asciidoctor.log.Severity; + public class LogRecordsProcessors { private final LogHandler logHandler; 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 97ed6d1b..e9fd5063 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 @@ -1,14 +1,14 @@ package org.asciidoctor.maven.log; -import org.asciidoctor.log.LogHandler; -import org.asciidoctor.log.LogRecord; -import org.asciidoctor.log.Severity; - import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; +import org.asciidoctor.log.LogHandler; +import org.asciidoctor.log.LogRecord; +import org.asciidoctor.log.Severity; + /** * AsciidoctorJ LogHandler that stores records in memory. diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfiguration.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfiguration.java index ae2f43a0..98e32920 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfiguration.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfiguration.java @@ -1,9 +1,9 @@ package org.asciidoctor.maven.site; -import org.asciidoctor.Options; - import java.util.List; +import org.asciidoctor.Options; + public class SiteConversionConfiguration { private final Options options; diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfigurationParser.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfigurationParser.java index f6ae9e63..05f10b7d 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfigurationParser.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteConversionConfigurationParser.java @@ -1,5 +1,14 @@ package org.asciidoctor.maven.site; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.apache.maven.project.MavenProject; import org.asciidoctor.AttributesBuilder; import org.asciidoctor.Options; @@ -8,11 +17,6 @@ import org.asciidoctor.maven.commons.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.io.File; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; public class SiteConversionConfigurationParser { diff --git a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializer.java b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializer.java index b87705ac..a12a8bd1 100644 --- a/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializer.java +++ b/asciidoctor-maven-commons/src/main/java/org/asciidoctor/maven/site/SiteLogHandlerDeserializer.java @@ -1,12 +1,12 @@ package org.asciidoctor.maven.site; +import java.util.Optional; + import org.asciidoctor.log.Severity; import org.asciidoctor.maven.log.FailIf; import org.asciidoctor.maven.log.LogHandler; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.util.Optional; - public class SiteLogHandlerDeserializer { public static final String NODE_NAME = "logHandler"; 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 index 3b34126c..a2205db0 100644 --- 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 @@ -1,5 +1,9 @@ package org.asciidoctor.maven.commons; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + import org.asciidoctor.Attributes; import org.asciidoctor.AttributesBuilder; import org.assertj.core.data.MapEntry; @@ -7,10 +11,6 @@ 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; 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 db5ab5be..a0ef7363 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 @@ -1,14 +1,14 @@ package org.asciidoctor.maven.log; +import java.io.File; +import java.io.IOException; + import org.asciidoctor.ast.Cursor; import org.asciidoctor.log.LogRecord; import org.asciidoctor.log.Severity; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.io.File; -import java.io.IOException; - import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; 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 ea986852..fd96e02e 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 @@ -1,5 +1,11 @@ package org.asciidoctor.maven.site; +import java.io.File; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.asciidoctor.Attributes; @@ -9,13 +15,9 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; import org.junit.jupiter.api.Test; -import java.io.File; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.asciidoctor.Options.*; +import static org.asciidoctor.Options.ATTRIBUTES; +import static org.asciidoctor.Options.BASEDIR; +import static org.asciidoctor.Options.TEMPLATE_DIRS; import static org.assertj.core.api.Assertions.assertThat; class SiteConversionConfigurationParserTest { 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 c80bc91f..a51bc12b 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 @@ -1,5 +1,19 @@ package org.asciidoctor.maven; +import javax.inject.Inject; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.logging.Logger; + import org.apache.commons.io.FilenameUtils; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -30,20 +44,6 @@ import org.asciidoctor.maven.process.SourceDocumentFinder; import org.jruby.Ruby; -import javax.inject.Inject; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.logging.Logger; - import static org.asciidoctor.maven.commons.StringUtils.isBlank; import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; import static org.asciidoctor.maven.process.SourceDirectoryFinder.DEFAULT_SOURCE_DIR; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorRefreshMojo.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorRefreshMojo.java index 88ba4626..da4c385e 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorRefreshMojo.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorRefreshMojo.java @@ -1,5 +1,13 @@ package org.asciidoctor.maven; +import java.io.File; +import java.io.FileFilter; +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.Scanner; +import java.util.StringJoiner; + import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.NameFileFilter; @@ -17,14 +25,6 @@ import org.asciidoctor.maven.refresh.ResourcesPatternBuilder; import org.asciidoctor.maven.refresh.TimeCounter; -import java.io.File; -import java.io.FileFilter; -import java.util.Collection; -import java.util.Collections; -import java.util.Optional; -import java.util.Scanner; -import java.util.StringJoiner; - import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; import static org.asciidoctor.maven.process.SourceDocumentFinder.CUSTOM_FILE_EXTENSIONS_PATTERN_PREFIX; import static org.asciidoctor.maven.process.SourceDocumentFinder.CUSTOM_FILE_EXTENSIONS_PATTERN_SUFFIX; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorZipMojo.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorZipMojo.java index 1485c84c..a573b478 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorZipMojo.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/AsciidoctorZipMojo.java @@ -1,5 +1,8 @@ package org.asciidoctor.maven; +import java.io.File; +import java.io.IOException; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -8,9 +11,6 @@ import org.apache.maven.project.MavenProjectHelper; import org.asciidoctor.maven.io.Zips; -import java.io.File; -import java.io.IOException; - @Mojo(name = "zip") public class AsciidoctorZipMojo extends AsciidoctorMojo { public static final String PREFIX = AsciidoctorMaven.PREFIX + "zip."; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHandler.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHandler.java index 2fdc2e5d..8744b353 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHandler.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHandler.java @@ -1,5 +1,10 @@ package org.asciidoctor.maven.http; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.nio.charset.StandardCharsets; + import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelFutureListener; @@ -16,11 +21,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.nio.charset.StandardCharsets; - public class AsciidoctorHandler extends SimpleChannelInboundHandler { private static final String HTML_MEDIA_TYPE = "text/html"; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHttpServer.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHttpServer.java index 8acc09d7..877fa129 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHttpServer.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/http/AsciidoctorHttpServer.java @@ -1,5 +1,9 @@ package org.asciidoctor.maven.http; +import java.io.File; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.atomic.AtomicInteger; + import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInitializer; @@ -14,10 +18,6 @@ import io.netty.util.concurrent.Future; import org.apache.maven.plugin.logging.Log; -import java.io.File; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicInteger; - /** * HTTP server to expose AsciiDoc converted sources. */ diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/io/Zips.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/io/Zips.java index 37495a6a..bf1893ba 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/io/Zips.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/io/Zips.java @@ -1,7 +1,5 @@ package org.asciidoctor.maven.io; -import org.apache.commons.io.IOUtils; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -9,6 +7,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import org.apache.commons.io.IOUtils; + public final class Zips { public static void zip(final File dir, final File zipName) throws IOException, IllegalArgumentException { diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/CopyResourcesProcessor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/CopyResourcesProcessor.java index ee07883a..a0beac01 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/CopyResourcesProcessor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/CopyResourcesProcessor.java @@ -1,16 +1,16 @@ package org.asciidoctor.maven.process; -import org.apache.commons.io.FileUtils; -import org.asciidoctor.maven.AsciidoctorMojo; -import org.asciidoctor.maven.model.Resource; -import org.codehaus.plexus.util.DirectoryScanner; - import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import org.apache.commons.io.FileUtils; +import org.asciidoctor.maven.AsciidoctorMojo; +import org.asciidoctor.maven.model.Resource; +import org.codehaus.plexus.util.DirectoryScanner; + import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; @@ -27,28 +27,28 @@ public class CopyResourcesProcessor implements ResourcesProcessor { // docinfo snippets should not be copied public static String[] IGNORED_FILE_NAMES = { - "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" + "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 String[] DEFAULT_ASCIIDOC_EXTENSIONS = {"**/*.adoc", "**/*.ad", "**/*.asc", "**/*.asciidoc"}; // Files and directories beginning with underscore are ignored private static String[] INTERNAL_FOLDERS_AND_FILES_PATTERNS = { - "**/_*.*", - "**/_*", - "**/.*", - "**/_*/**/*.*", + "**/_*.*", + "**/_*", + "**/.*", + "**/_*/**/*.*", }; /* @@ -72,8 +72,8 @@ public void process(File sourceRootDirectory, File outputRootDirectory, Asciidoc */ private List prepareResources(File sourceDirectory, AsciidoctorMojo configuration) { final List resources = configuration.getResources() != null - ? configuration.getResources() - : new ArrayList<>(); + ? configuration.getResources() + : new ArrayList<>(); if (resources.isEmpty()) { // we don't want to copy files considered sources Resource resource = new Resource(); @@ -81,7 +81,7 @@ private List prepareResources(File sourceDirectory, AsciidoctorMojo co // exclude sourceDocumentName if defined if (isNotBlank(configuration.getSourceDocumentName())) { resource.getExcludes() - .add(configuration.getSourceDocumentName()); + .add(configuration.getSourceDocumentName()); } resources.add(resource); } @@ -120,33 +120,33 @@ private List prepareResources(File sourceDirectory, AsciidoctorMojo co private void copyResources(List resources, File outputDirectory) { resources.stream() - .filter(resource -> new File(resource.getDirectory()).exists()) - .forEach(resource -> { - DirectoryScanner directoryScanner = new DirectoryScanner(); - directoryScanner.setBasedir(resource.getDirectory()); - - if (resource.getIncludes().isEmpty()) - directoryScanner.setIncludes(new String[]{"**/*.*", "**/*"}); - else - directoryScanner.setIncludes(resource.getIncludes().toArray(new String[0])); - - directoryScanner.setExcludes(resource.getExcludes().toArray(new String[0])); - directoryScanner.setFollowSymlinks(false); - directoryScanner.scan(); - - for (String includedFile : directoryScanner.getIncludedFiles()) { - File source = new File(directoryScanner.getBasedir(), includedFile); - copyFileToDirectory(source, resource, outputDirectory); - } - }); + .filter(resource -> new File(resource.getDirectory()).exists()) + .forEach(resource -> { + DirectoryScanner directoryScanner = new DirectoryScanner(); + directoryScanner.setBasedir(resource.getDirectory()); + + if (resource.getIncludes().isEmpty()) + directoryScanner.setIncludes(new String[]{"**/*.*", "**/*"}); + else + directoryScanner.setIncludes(resource.getIncludes().toArray(new String[0])); + + directoryScanner.setExcludes(resource.getExcludes().toArray(new String[0])); + directoryScanner.setFollowSymlinks(false); + directoryScanner.scan(); + + for (String includedFile : directoryScanner.getIncludedFiles()) { + File source = new File(directoryScanner.getBasedir(), includedFile); + copyFileToDirectory(source, resource, outputDirectory); + } + }); } private void copyFileToDirectory(File source, Resource resource, File outputDirectory) { try { final File target = resource.getTargetPath() == null - ? outputDirectory - : composeTargetPath(resource, outputDirectory); + ? outputDirectory + : composeTargetPath(resource, outputDirectory); Path sourceDirectoryPath = new File(resource.getDirectory()).toPath(); Path sourcePath = source.toPath(); @@ -168,7 +168,7 @@ private void copyFileToDirectory(File source, Resource resource, File outputDire private static File composeTargetPath(Resource resource, File outputDirectory) { final File targetFile = new File(resource.getTargetPath()); return targetFile.isAbsolute() - ? targetFile - : new File(outputDirectory, resource.getTargetPath()); + ? targetFile + : new File(outputDirectory, resource.getTargetPath()); } } diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/ResourcesProcessor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/ResourcesProcessor.java index f2f03622..a5424619 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/ResourcesProcessor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/process/ResourcesProcessor.java @@ -1,9 +1,9 @@ package org.asciidoctor.maven.process; -import org.asciidoctor.maven.AsciidoctorMojo; - import java.io.File; +import org.asciidoctor.maven.AsciidoctorMojo; + public interface ResourcesProcessor { /** diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AbstractFileAlterationListenerAdaptor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AbstractFileAlterationListenerAdaptor.java index c2193efd..38d577be 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AbstractFileAlterationListenerAdaptor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AbstractFileAlterationListenerAdaptor.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.refresh; +import java.io.File; + import org.apache.commons.io.monitor.FileAlterationListenerAdaptor; import org.apache.maven.plugin.logging.Log; import org.asciidoctor.maven.AsciidoctorRefreshMojo; -import java.io.File; - public abstract class AbstractFileAlterationListenerAdaptor extends FileAlterationListenerAdaptor { private final AsciidoctorRefreshMojo mojo; diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.java index 8ede2323..82a5a969 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AdditionalSourceFileAlterationListenerAdaptor.java @@ -1,12 +1,12 @@ package org.asciidoctor.maven.refresh; +import java.io.File; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.asciidoctor.maven.AsciidoctorRefreshMojo; import org.asciidoctor.maven.process.ResourcesProcessor; -import java.io.File; - public class AdditionalSourceFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor { private static final ResourcesProcessor EMPTY_RESOURCES_PROCESSOR = (sourcesDir, outputDir, configuration) -> { diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AsciidoctorConverterFileAlterationListenerAdaptor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AsciidoctorConverterFileAlterationListenerAdaptor.java index 864d0c1b..8c132d1d 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AsciidoctorConverterFileAlterationListenerAdaptor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/AsciidoctorConverterFileAlterationListenerAdaptor.java @@ -1,13 +1,13 @@ package org.asciidoctor.maven.refresh; +import java.io.File; +import java.util.Collections; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.asciidoctor.maven.AsciidoctorRefreshMojo; import org.asciidoctor.maven.process.ResourcesProcessor; -import java.io.File; -import java.util.Collections; - public class AsciidoctorConverterFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor { private static final ResourcesProcessor EMPTY_RESOURCES_PROCESSOR = (sourcesDir, outputDir, configuration) -> { diff --git a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptor.java b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptor.java index e7b5087d..5d31c536 100644 --- a/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptor.java +++ b/asciidoctor-maven-plugin/src/main/java/org/asciidoctor/maven/refresh/ResourceCopyFileAlterationListenerAdaptor.java @@ -1,17 +1,17 @@ package org.asciidoctor.maven.refresh; -import org.apache.maven.plugin.logging.Log; -import org.asciidoctor.maven.AsciidoctorRefreshMojo; -import org.asciidoctor.maven.model.Resource; -import org.codehaus.plexus.util.DirectoryScanner; -import org.codehaus.plexus.util.FileUtils; - import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.apache.maven.plugin.logging.Log; +import org.asciidoctor.maven.AsciidoctorRefreshMojo; +import org.asciidoctor.maven.model.Resource; +import org.codehaus.plexus.util.DirectoryScanner; +import org.codehaus.plexus.util.FileUtils; + import static org.asciidoctor.maven.commons.StringUtils.isBlank; public class ResourceCopyFileAlterationListenerAdaptor extends AbstractFileAlterationListenerAdaptor { diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java index cb6ce454..7be79381 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java @@ -1,13 +1,13 @@ package org.asciidoctor.maven; +import java.io.File; +import java.nio.file.Files; + import lombok.SneakyThrows; import org.assertj.core.api.AbstractFileAssert; import org.assertj.core.api.AbstractStringAssert; import org.assertj.core.api.Assertions; -import java.io.File; -import java.nio.file.Files; - public class AsciidoctorAsserter { private final AbstractFileAssert fileAssert; 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 9fde57d5..087f9eb5 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 @@ -1,5 +1,13 @@ package org.asciidoctor.maven; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.ServerSocket; +import java.net.URL; + import lombok.SneakyThrows; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -9,14 +17,6 @@ import org.asciidoctor.maven.io.UserInputSimulator; import org.junit.jupiter.api.Test; -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.ServerSocket; -import java.net.URL; - import static java.nio.charset.StandardCharsets.UTF_8; import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorHttpMojo; import static org.assertj.core.api.Assertions.assertThat; 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 642b5ef8..b8d04f17 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 @@ -1,18 +1,18 @@ package org.asciidoctor.maven; +import java.io.File; +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Disabled; 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.io.TestFilesHelper.newOutputTestDirectory; import static org.asciidoctor.maven.test.TestUtils.ResourceBuilder.excludeAll; import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorMojo; -import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; /** * Opinionated tests to validate Asciidoctor behaviours in end-to-end scenarios. 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 b93763bf..d7b1d3d6 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 @@ -1,22 +1,28 @@ package org.asciidoctor.maven; +import java.io.File; +import java.util.Arrays; +import java.util.Map; + import lombok.SneakyThrows; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.asciidoctor.maven.extensions.ExtensionConfiguration; import org.asciidoctor.maven.io.ConsoleHolder; -import org.asciidoctor.maven.test.processors.*; +import org.asciidoctor.maven.test.processors.ChangeAttributeValuePreprocessor; +import org.asciidoctor.maven.test.processors.FailingPreprocessor; +import org.asciidoctor.maven.test.processors.GistBlockMacroProcessor; +import org.asciidoctor.maven.test.processors.ManpageInlineMacroProcessor; +import org.asciidoctor.maven.test.processors.MetaDocinfoProcessor; +import org.asciidoctor.maven.test.processors.UriIncludeProcessor; +import org.asciidoctor.maven.test.processors.YellBlockProcessor; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import java.io.File; -import java.util.Arrays; -import java.util.Map; - import static java.util.Collections.singletonList; -import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorMojo; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; +import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorMojo; import static org.assertj.core.api.Assertions.assertThat; /** 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 f684b62d..6a9c3ae9 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 @@ -1,5 +1,11 @@ package org.asciidoctor.maven; +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.asciidoctor.maven.io.ConsoleHolder; @@ -8,16 +14,10 @@ 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.test.TestUtils.mockAsciidoctorMojo; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; +import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorMojo; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; @@ -44,7 +44,7 @@ void should_not_fail_when_logHandler_is_not_set() throws MojoFailureException, M // then: process completes but the document contains errors AsciidoctorAsserter.assertThat(outputDir, "document-with-missing-include.html") - .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); + .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); } @Test @@ -67,19 +67,19 @@ public void should_show_Asciidoctor_messages_as_info_by_default() throws MojoFai // then List asciidoctorMessages = Arrays.stream(consoleHolder.getOutput().split("\n")) - .filter(line -> line.contains("asciidoctor:")) - .collect(Collectors.toList()); + .filter(line -> line.contains("asciidoctor:")) + .collect(Collectors.toList()); assertThat(asciidoctorMessages) - .hasSize(4); + .hasSize(4); assertThat(asciidoctorMessages.get(0)) - .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); + .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); assertThat(asciidoctorMessages.get(1)) - .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); + .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); assertThat(asciidoctorMessages.get(2)) - .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); + .contains(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); assertThat(asciidoctorMessages.get(3)) - .contains(fixOsSeparator("[info] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); + .contains(fixOsSeparator("[info] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); // cleanup consoleHolder.release(); @@ -107,20 +107,20 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set() // then: output file exists & shows include error AsciidoctorAsserter.assertThat(outputDir, "document-with-missing-include.html") - .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); + .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); // and: all messages (ERR & WARN) are logged as info List outputLines = getOutputInfoLines(consoleHolder); assertThat(outputLines) - .hasSize(4); + .hasSize(4); assertThat(outputLines.get(0)) - .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); + .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); assertThat(outputLines.get(1)) - .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); + .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); assertThat(outputLines.get(2)) - .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); + .startsWith(fixOsSeparator("[info] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); assertThat(outputLines.get(3)) - .startsWith(fixOsSeparator("[info] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); + .startsWith(fixOsSeparator("[info] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); // cleanup consoleHolder.release(); @@ -151,15 +151,15 @@ void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_and_doc_ // then: output file exists & shows include error assertThat(new File(outputDir, "document-with-invalid-reference.html")) - .isNotEmpty(); + .isNotEmpty(); // and: all messages (WARN) are logged as info List outputLines = getOutputInfoLines(consoleHolder); assertThat(outputLines) - .containsExactly( - "[info] asciidoctor: WARN: invalid reference: ../path/some-file.adoc", - "[info] asciidoctor: WARN: invalid reference: section-id" - ); + .containsExactly( + "[info] asciidoctor: WARN: invalid reference: ../path/some-file.adoc", + "[info] asciidoctor: WARN: invalid reference: section-id" + ); // cleanup consoleHolder.release(); @@ -191,14 +191,14 @@ void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws MojoFai // then: output file exists & shows include error assertThat(new File(outputDir, "document-with-invalid-reference.html")) - .isNotEmpty(); + .isNotEmpty(); // and: all messages (WARN) are logged as info assertThat(getOutputInfoLines(consoleHolder)) - .containsExactly( - "[info] asciidoctor: WARN: invalid reference: ../path/some-file.adoc", - "[info] asciidoctor: WARN: invalid reference: section-id" - ); + .containsExactly( + "[info] asciidoctor: WARN: invalid reference: ../path/some-file.adoc", + "[info] asciidoctor: WARN: invalid reference: section-id" + ); // cleanup consoleHolder.release(); @@ -226,8 +226,8 @@ void should_fail_when_logHandler_failIf_is_WARNING() { // then: issues with WARN and ERROR are returned assertThat(throwable) - .isInstanceOf(MojoExecutionException.class) - .hasMessageContaining("Found 4 issue(s) of severity WARN or higher during conversion"); + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Found 4 issue(s) of severity WARN or higher during conversion"); } @Test @@ -252,8 +252,8 @@ void should_fail_when_logHandler_failIf_is_ERROR() { // then assertThat(throwable) - .isInstanceOf(MojoExecutionException.class) - .hasMessageContaining("Found 3 issue(s) of severity ERROR or higher during conversion"); + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Found 3 issue(s) of severity ERROR or higher during conversion"); } @Test @@ -278,7 +278,7 @@ void should_not_fail_if_containsText_does_not_match_any_message() throws MojoFai // then AsciidoctorAsserter.assertThat(outputDir, "document-with-missing-include.html") - .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); + .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); } @Test @@ -305,21 +305,21 @@ void should_fail_when_containsText_matches() { // then assertThat(throwable) - .isInstanceOf(MojoExecutionException.class) - .hasMessageContaining("Found 3 issue(s) containing 'include file not found'"); + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Found 3 issue(s) containing 'include file not found'"); assertThat(new File(outputDir, "document-with-missing-include.html")) - .exists(); + .exists(); // and: all messages (ERR & WARN) are logged as error List errorLines = getErrorLines(consoleHolder); assertThat(errorLines) - .hasSize(3); + .hasSize(3); assertThat(errorLines.get(0)) - .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); + .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 3: include file not found:")); assertThat(errorLines.get(1)) - .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); + .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 5: include file not found:")); assertThat(errorLines.get(2)) - .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); + .contains(fixOsSeparator("[error] asciidoctor: ERROR: errors/document-with-missing-include.adoc: line 9: include file not found:")); // cleanup consoleHolder.release(); @@ -350,12 +350,12 @@ void should_fail_and_filter_errors_that_match_both_severity_and_text() { // then assertThat(new File(outputDir, "document-with-missing-include.html")) - .isNotEmpty(); + .isNotEmpty(); assertThat(throwable) - .isInstanceOf(MojoExecutionException.class) - .hasMessageContaining("Found 4 issue(s) matching severity WARN or higher and text 'no'"); + .isInstanceOf(MojoExecutionException.class) + .hasMessageContaining("Found 4 issue(s) matching severity WARN or higher and text 'no'"); assertThat(consoleHolder.getError()) - .contains(fixOsSeparator("[error] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); + .contains(fixOsSeparator("[error] asciidoctor: WARN: errors/document-with-missing-include.adoc: line 25: no callout found for <1>")); // cleanup consoleHolder.release(); @@ -385,9 +385,9 @@ void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureExceptio // then: output file exists & shows include error AsciidoctorAsserter.assertThat(new File(outputDir, "document-with-missing-include.html")) - .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); + .contains("

Unresolved directive in document-with-missing-include.adoc - include::unexistingdoc.adoc[]

"); assertThat(consoleHolder.getError()) - .isEmpty(); + .isEmpty(); // cleanup consoleHolder.release(); @@ -396,13 +396,13 @@ void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureExceptio private List getOutputInfoLines(ConsoleHolder consoleHolder) { final String lineSeparator = lineSeparator(); return Arrays.stream(consoleHolder.getOutput().split(lineSeparator)) - .filter(line -> line.startsWith("[info] asciidoctor")) - .collect(Collectors.toList()); + .filter(line -> line.startsWith("[info] asciidoctor")) + .collect(Collectors.toList()); } private List getErrorLines(ConsoleHolder consoleHolder) { return Arrays.stream(consoleHolder.getError().split(lineSeparator())) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } private String fixOsSeparator(String text) { 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 784d4e90..635cf736 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 @@ -1,15 +1,5 @@ package org.asciidoctor.maven; -import lombok.SneakyThrows; -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.asciidoctor.maven.extensions.ExtensionConfiguration; -import org.asciidoctor.maven.io.ConsoleHolder; -import org.asciidoctor.maven.test.processors.RequireCheckerTreeprocessor; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Test; - import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -24,6 +14,16 @@ import java.util.UUID; import java.util.stream.Collectors; +import lombok.SneakyThrows; +import org.apache.commons.io.FileUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.asciidoctor.maven.extensions.ExtensionConfiguration; +import org.asciidoctor.maven.io.ConsoleHolder; +import org.asciidoctor.maven.test.processors.RequireCheckerTreeprocessor; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + import static java.nio.file.Files.writeString; import static java.util.Collections.singletonList; import static org.asciidoctor.maven.AsciidoctorAsserter.assertThat; 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 c96646a5..29225913 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 @@ -1,14 +1,5 @@ package org.asciidoctor.maven; -import lombok.SneakyThrows; -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.asciidoctor.maven.test.TestUtils.ResourceBuilder; -import org.asciidoctor.maven.io.ConsoleHolder; -import org.asciidoctor.maven.model.Resource; -import org.junit.jupiter.api.Test; - import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -18,10 +9,19 @@ import java.util.function.Supplier; import java.util.stream.Collectors; +import lombok.SneakyThrows; +import org.apache.commons.io.FileUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.asciidoctor.maven.io.ConsoleHolder; +import org.asciidoctor.maven.model.Resource; +import org.asciidoctor.maven.test.TestUtils.ResourceBuilder; +import org.junit.jupiter.api.Test; + import static java.nio.charset.StandardCharsets.UTF_8; -import static org.asciidoctor.maven.test.TestUtils.newFakeRefreshMojo; import static org.asciidoctor.maven.io.TestFilesHelper.createFileWithContent; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; +import static org.asciidoctor.maven.test.TestUtils.newFakeRefreshMojo; import static org.assertj.core.api.Assertions.assertThat; class AsciidoctorRefreshMojoTest { @@ -113,10 +113,10 @@ void should_only_auto_convert_file_with_custom_sourceDocumentName_when_source_is final File target = new File(outputDir, sourceFile.getName().replace(fileExtension, "html")); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); final File ignoredTarget = new File(outputDir, ignoredFile.getName().replace(fileExtension, "html")); assertThat(ignoredTarget) - .doesNotExist(); + .doesNotExist(); // and when FileUtils.write(sourceFile, "= Document Title\n\nWow, this will be auto refreshed !", UTF_8); @@ -124,9 +124,9 @@ void should_only_auto_convert_file_with_custom_sourceDocumentName_when_source_is // then consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertThat(ignoredTarget) - .doesNotExist(); + .doesNotExist(); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -160,7 +160,7 @@ void should_auto_convert_file_with_custom_file_extension_when_source_is_updated( final File target = new File(outputDir, sourceFile.getName().replace(customFileExtension, "html")); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); // and when FileUtils.write(sourceFile, "= Document Title\n\nWow, this will be auto refreshed !", UTF_8); @@ -168,7 +168,7 @@ void should_auto_convert_file_with_custom_file_extension_when_source_is_updated( // then consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -196,7 +196,7 @@ void should_auto_convert_file_in_root_when_source_is_updated() throws IOExceptio final File target = new File(outputDir, sourceFile.getName().replace(".asciidoc", ".html")); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); // and when FileUtils.write(sourceFile, "= Document Title\n\nWow, this will be auto refreshed !", UTF_8); @@ -204,7 +204,7 @@ void should_auto_convert_file_in_root_when_source_is_updated() throws IOExceptio // then consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -232,7 +232,7 @@ void should_auto_convert_file_in_subDir_when_source_is_updated() throws IOExcept File target = new File(outputDir, sourceFile.getName().replace(".asciidoc", ".html")); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); // and when FileUtils.write(sourceFile, "= Document Title\n\nWow, this will be auto refreshed !", UTF_8); @@ -240,7 +240,7 @@ void should_auto_convert_file_in_subDir_when_source_is_updated() throws IOExcept // then consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -268,7 +268,7 @@ void should_auto_convert_file_when_new_source_is_created() throws IOException { File target = new File(outputDir, sourceFile.getName().replace(".asciidoc", ".html")); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); // and when final File newSourceFile = new File(new File(srcDir, "sub-dir1/sub_dir2"), "sourceFile-2.asciidoc"); @@ -278,9 +278,9 @@ void should_auto_convert_file_when_new_source_is_created() throws IOException { File newTarget = new File(outputDir, newSourceFile.getName().replace(".asciidoc", ".html")); consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(newTarget, UTF_8)) - .contains("Wow, this is NEW!!"); + .contains("Wow, this is NEW!!"); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("This is test, only a test"); + .contains("This is test, only a test"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -308,7 +308,7 @@ void should_copy_resources_when_updated_but_not_on_start_when_there_are_no_sourc final File target = new File(outputDir, resourceFile.getName()); consoleHolder.awaitProcessingAllSources(); assertThat(target) - .doesNotExist(); + .doesNotExist(); // and when FileUtils.write(resourceFile, "Supposedly image content UPDATED!", UTF_8); @@ -316,7 +316,7 @@ void should_copy_resources_when_updated_but_not_on_start_when_there_are_no_sourc // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content UPDATED!"); + .isEqualTo("Supposedly image content UPDATED!"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -336,17 +336,17 @@ void should_convert_additional_sources_when_set_in_refreshOn() throws IOExceptio // when final File sourceFile = new File(srcDir, "sourceFile.adoc"); String sourceContent = new StringBuilder() - .append("= Document Title\n\n") - .append("This is test, only a test.\n\n") - .append("== Included\n\n") - .append("include::included.txt[]") - .toString(); + .append("= Document Title\n\n") + .append("This is test, only a test.\n\n") + .append("== Included\n\n") + .append("include::included.txt[]") + .toString(); FileUtils.write(sourceFile, sourceContent, UTF_8); final File includedFile = new File(srcDir, "included.txt"); String includedContent = new StringBuilder() - .append("Original included content") - .toString(); + .append("Original included content") + .toString(); FileUtils.write(includedFile, includedContent, UTF_8); // when @@ -364,9 +364,9 @@ void should_convert_additional_sources_when_set_in_refreshOn() throws IOExceptio final File target = new File(outputDir, "sourceFile.html"); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Original included content"); + .contains("Original included content"); assertThat(includedContent) - .isNotEmpty(); + .isNotEmpty(); // and when FileUtils.write(includedFile, "Included content UPDATED!", UTF_8); @@ -374,9 +374,9 @@ void should_convert_additional_sources_when_set_in_refreshOn() throws IOExceptio // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .contains("Included content UPDATED!"); + .contains("Included content UPDATED!"); assertThat(includedContent) - .isNotEmpty(); + .isNotEmpty(); // cleanup consoleHolder.input("exit"); @@ -394,7 +394,7 @@ void should_copy_resource_in_root_when_resource_is_updated() throws IOException final List docInfoFiles = createDocInfoFiles(srcDir); FileUtils.write(new File(srcDir, "sourceFile.asciidoc"), - "= Document Title\n\nThis is test, only a test.", UTF_8); + "= Document Title\n\nThis is test, only a test.", UTF_8); final String resourceFileExtension = "jpg"; final File resourceFile = new File(srcDir, "fakeImage." + resourceFileExtension); @@ -406,7 +406,7 @@ void should_copy_resource_in_root_when_resource_is_updated() throws IOException final File target = new File(outputDir, resourceFile.getName()); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content"); + .isEqualTo("Supposedly image content"); // and when FileUtils.write(resourceFile, "Supposedly image content UPDATED!", UTF_8); @@ -414,7 +414,7 @@ void should_copy_resource_in_root_when_resource_is_updated() throws IOException // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content UPDATED!"); + .isEqualTo("Supposedly image content UPDATED!"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -433,7 +433,7 @@ void should_copy_resource_in_subDir_when_resource_is_updated() throws IOExceptio final List docInfoFiles = createDocInfoFiles(srcDir); FileUtils.write(new File(srcDir, "sourceFile.asciidoc"), - "= Document Title\n\nThis is test, only a test.", UTF_8); + "= Document Title\n\nThis is test, only a test.", UTF_8); final File subDirectory = new File(srcDir, "sub-dir1/sub_dir2"); final String resourceFileExtension = "jpg"; final File resourceFile = new File(subDirectory, "fakeImage." + resourceFileExtension); @@ -446,7 +446,7 @@ void should_copy_resource_in_subDir_when_resource_is_updated() throws IOExceptio final File target = new File(subDirectory, resourceFile.getName()); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content"); + .isEqualTo("Supposedly image content"); // and when FileUtils.write(resourceFile, "Supposedly image content UPDATED!", UTF_8); @@ -454,7 +454,7 @@ void should_copy_resource_in_subDir_when_resource_is_updated() throws IOExceptio // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content UPDATED!"); + .isEqualTo("Supposedly image content UPDATED!"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -473,7 +473,7 @@ void should_copy_resource_to_targetPath_in_resource_when_resources_configuration final List docInfoFiles = createDocInfoFiles(srcDir); FileUtils.write(new File(srcDir, "sourceFile.asciidoc"), - "= Document Title\n\nThis is test, only a test.", UTF_8); + "= Document Title\n\nThis is test, only a test.", UTF_8); final String subDirPath = "sub-dir1/sub_dir2"; final File subDirectory = new File(srcDir, subDirPath); final String resourceFileExtension = "jpg"; @@ -487,17 +487,17 @@ void should_copy_resource_to_targetPath_in_resource_when_resources_configuration mojo.sourceDirectory = srcDir; mojo.outputDirectory = outputDir; mojo.resources = Arrays.asList(new ResourceBuilder() - .directory(subDirectory.getAbsolutePath()) - .includes("**/*.jpg", "**/*.gif") - .targetPath(String.join(File.separator, subDirPath, customOutput)) - .build()); + .directory(subDirectory.getAbsolutePath()) + .includes("**/*.jpg", "**/*.gif") + .targetPath(String.join(File.separator, subDirPath, customOutput)) + .build()); }); // then final File target = new File(outputDir, String.join(File.separator, subDirPath, customOutput, resourceFile.getName())); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content"); + .isEqualTo("Supposedly image content"); // and when FileUtils.write(resourceFile, "Supposedly image content UPDATED!", UTF_8); @@ -505,9 +505,9 @@ void should_copy_resource_to_targetPath_in_resource_when_resources_configuration // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content UPDATED!"); + .isEqualTo("Supposedly image content UPDATED!"); assertThat(new File(outputDir, resourceFile.getName())) - .doesNotExist(); + .doesNotExist(); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -526,7 +526,7 @@ void should_copy_resource_to_outputDirectory_in_resource_when_resources_configur final List docInfoFiles = createDocInfoFiles(srcDir); FileUtils.write(new File(srcDir, "sourceFile.asciidoc"), - "= Document Title\n\nThis is test, only a test.", UTF_8); + "= Document Title\n\nThis is test, only a test.", UTF_8); final String subDirPath = "sub-dir1/sub_dir2"; final File subDirectory = new File(srcDir, subDirPath); final String resourceFileExtension = "jpg"; @@ -551,7 +551,7 @@ void should_copy_resource_to_outputDirectory_in_resource_when_resources_configur final File target = new File(outputDir, resourceFile.getName()); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content"); + .isEqualTo("Supposedly image content"); // and when FileUtils.write(resourceFile, "Supposedly image content UPDATED!", UTF_8); @@ -559,7 +559,7 @@ void should_copy_resource_to_outputDirectory_in_resource_when_resources_configur // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content UPDATED!"); + .isEqualTo("Supposedly image content UPDATED!"); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -593,15 +593,15 @@ void should_ignore_resource_file_when_matches_custom_source_file_extensions() th consoleHolder.awaitProcessingAllSources(); final File targetSource = new File(outputDir, sourceFile.getName().replace("adoc", "html")); assertThat(targetSource) - .doesNotExist(); + .doesNotExist(); final File targetResource1 = new File(outputDir, resourceFile1.getName().replace("jpg", "html")); assertThat(FileUtils.readFileToString(targetResource1, UTF_8)) - .contains("This is reality a Adoc source with jpg extension"); + .contains("This is reality a Adoc source with jpg extension"); assertThat(new File(outputDir, resourceFile1.getName())) - .doesNotExist(); + .doesNotExist(); final File targetResource2 = new File(outputDir, resourceFile2.getName()); assertThat(targetResource2) - .exists(); + .exists(); // and when FileUtils.write(resourceFile1, "= Not an image\n\nWow, this will be auto refreshed !", UTF_8); @@ -609,13 +609,13 @@ void should_ignore_resource_file_when_matches_custom_source_file_extensions() th // then: custom file extensions is processed as source consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(targetResource1, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertThat(new File(outputDir, resourceFile1.getName())) - .doesNotExist(); + .doesNotExist(); assertThat(targetResource2) - .exists(); + .exists(); assertThat(targetSource) - .doesNotExist(); + .doesNotExist(); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -653,15 +653,15 @@ void should_ignore_resource_file_when_matches_custom_source_sourceDocumentName() consoleHolder.awaitProcessingAllSources(); final File targetSource = new File(outputDir, sourceFile.getName().replace("adoc", "html")); assertThat(targetSource) - .doesNotExist(); + .doesNotExist(); final File targetResource1 = new File(outputDir, resourceFile1.getName().replace("jpg", "html")); assertThat(FileUtils.readFileToString(targetResource1, UTF_8)) - .contains("This is reality a Adoc source with jpg extension"); + .contains("This is reality a Adoc source with jpg extension"); assertThat(new File(outputDir, resourceFile1.getName())) - .doesNotExist(); + .doesNotExist(); final File targetResource2 = new File(outputDir, resourceFile2.getName()); assertThat(targetResource2) - .exists(); + .exists(); // and when FileUtils.write(resourceFile1, "= Not an image\n\nWow, this will be auto refreshed !", UTF_8); @@ -669,13 +669,13 @@ void should_ignore_resource_file_when_matches_custom_source_sourceDocumentName() // then: custom file extensions is processed as source consoleHolder.awaitProcessingSource(); assertThat(FileUtils.readFileToString(targetResource1, UTF_8)) - .contains("Wow, this will be auto refreshed"); + .contains("Wow, this will be auto refreshed"); assertThat(new File(outputDir, resourceFile1.getName())) - .doesNotExist(); + .doesNotExist(); assertThat(targetResource2) - .exists(); + .exists(); assertThat(targetSource) - .doesNotExist(); + .doesNotExist(); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -694,7 +694,7 @@ void should_copy_resource_when_new_resource_is_created() throws IOException { final List docInfoFiles = createDocInfoFiles(srcDir); FileUtils.write(new File(srcDir, "sourceFile.asciidoc"), - "= Document Title\n\nThis is test, only a test.", UTF_8); + "= Document Title\n\nThis is test, only a test.", UTF_8); final File subDirectory = new File(srcDir, "sub-dir1/sub_dir2"); final File resourceFile = new File(subDirectory, "fakeImage.jpg"); @@ -706,7 +706,7 @@ void should_copy_resource_when_new_resource_is_created() throws IOException { final File target = new File(subDirectory, resourceFile.getName()); consoleHolder.awaitProcessingAllSources(); assertThat(FileUtils.readFileToString(target, UTF_8)) - .isEqualTo("Supposedly image content"); + .isEqualTo("Supposedly image content"); // and when final File newResourceFile = new File(subDirectory, "fakeImage-2.jpg"); @@ -715,9 +715,9 @@ void should_copy_resource_when_new_resource_is_created() throws IOException { // then consoleHolder.awaitProcessingResource(); assertThat(FileUtils.readFileToString(newResourceFile, UTF_8)) - .isEqualTo("Supposedly NEW image content!!"); + .isEqualTo("Supposedly NEW image content!!"); assertThat(resourceFile) - .exists(); + .exists(); assertFilesNotPresentInOutput(docInfoFiles, outputDir); // cleanup @@ -791,17 +791,17 @@ private void awaitTermination(Thread thread) { private List createDocInfoFiles(final File srcDir) { return Arrays.asList("docinfo.html", "docinfo-header.html", "my-docinfo-header.xml") - .stream() - .map(filename -> createFileWithContent(srcDir, filename)) - .collect(Collectors.toList()); + .stream() + .map(filename -> createFileWithContent(srcDir, filename)) + .collect(Collectors.toList()); } private void assertFilesNotPresentInOutput(final List files, final File outputDir) { assertThat(files - .stream() - .map(file -> new File(outputDir, file.getName())) - .collect(Collectors.toList())) - .allMatch(file -> !file.exists()); + .stream() + .map(file -> new File(outputDir, file.getName())) + .collect(Collectors.toList())) + .allMatch(file -> !file.exists()); } } 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 d9e547b2..9248a503 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 @@ -1,11 +1,5 @@ package org.asciidoctor.maven; -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.asciidoctor.maven.io.TestFilesHelper; -import org.junit.jupiter.api.Test; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -16,6 +10,12 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.apache.commons.io.FileUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.asciidoctor.maven.io.TestFilesHelper; +import org.junit.jupiter.api.Test; + import static java.nio.charset.StandardCharsets.UTF_8; import static org.asciidoctor.maven.test.TestUtils.mockAsciidoctorZipMojo; import static org.assertj.core.api.Assertions.assertThat; @@ -38,7 +38,7 @@ void should_create_simple_zip() throws IOException, MojoFailureException, MojoEx FileUtils.write(new File(srcDir, "sample.adoc"), - "= Title\n\ntest", UTF_8); + "= Title\n\ntest", UTF_8); AsciidoctorZipMojo mojo = mockAsciidoctorZipMojo(); mojo.sourceDirectory = srcDir; @@ -52,13 +52,13 @@ void should_create_simple_zip() throws IOException, MojoFailureException, MojoEx ZipFile zipfile = new ZipFile(zip); List names = getNames(zipfile.entries()) - .stream() - .map(value -> normalizeOsPath(value)) - .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) - .collect(Collectors.toList()); + .stream() + .map(value -> normalizeOsPath(value)) + .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) + .collect(Collectors.toList()); assertThat(names).hasSize(1); assertThat(names.get(0).replaceAll("\\\\", "/")) - .isEqualTo("asciidoctor-zip/sample.html"); + .isEqualTo("asciidoctor-zip/sample.html"); } @Test @@ -82,28 +82,28 @@ void should_replicate_source_structure_in_zip_standard_paths() throws MojoFailur // then ZipFile zipfile = new ZipFile(zip); List names = getNames(zipfile.entries()) - .stream() - .map(value -> normalizeOsPath(value)) - .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) - .collect(Collectors.toList()); + .stream() + .map(value -> normalizeOsPath(value)) + .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) + .collect(Collectors.toList()); zipfile.close(); // Paths are adapted for the test are do not match the real paths inside the zip List expected = Arrays.asList( - "asciidoctor-zip/HelloWorld.groovy", - "asciidoctor-zip/HelloWorld.html", - "asciidoctor-zip/level-1-1/asciidoctor-icon.jpg", - "asciidoctor-zip/level-1-1/HelloWorld2.groovy", - "asciidoctor-zip/level-1-1/HelloWorld2.html", - "asciidoctor-zip/level-1-1/HelloWorld22.html", - "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.groovy", - "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.html", - "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.groovy", - "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.html", - "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.groovy", - "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.html" + "asciidoctor-zip/HelloWorld.groovy", + "asciidoctor-zip/HelloWorld.html", + "asciidoctor-zip/level-1-1/asciidoctor-icon.jpg", + "asciidoctor-zip/level-1-1/HelloWorld2.groovy", + "asciidoctor-zip/level-1-1/HelloWorld2.html", + "asciidoctor-zip/level-1-1/HelloWorld22.html", + "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.groovy", + "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.html", + "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.groovy", + "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.html", + "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.groovy", + "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.html" ); assertThat(names) - .containsAll(expected); + .containsAll(expected); } @Test @@ -125,27 +125,27 @@ void should_not_replicate_source_structure_in_zip_standard_paths() throws IOExce // then ZipFile zipfile = new ZipFile(zip); List names = getNames(zipfile.entries()) - .stream() - .map(value -> normalizeOsPath(value)) - .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) - .collect(Collectors.toList()); + .stream() + .map(value -> normalizeOsPath(value)) + .map(value -> value.replaceAll("/" + normalizeOsPath(outputDir.toString()), "")) + .collect(Collectors.toList()); zipfile.close(); // Paths are adapted for the test are do not match the real paths inside the zip List expected = Arrays.asList( - "asciidoctor-zip/HelloWorld.groovy", - "asciidoctor-zip/HelloWorld.html", - "asciidoctor-zip/HelloWorld2.html", - "asciidoctor-zip/HelloWorld22.html", - "asciidoctor-zip/HelloWorld3.html", - "asciidoctor-zip/HelloWorld4.html", - "asciidoctor-zip/level-1-1/asciidoctor-icon.jpg", - "asciidoctor-zip/level-1-1/HelloWorld2.groovy", - "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.groovy", - "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.groovy", - "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.groovy" + "asciidoctor-zip/HelloWorld.groovy", + "asciidoctor-zip/HelloWorld.html", + "asciidoctor-zip/HelloWorld2.html", + "asciidoctor-zip/HelloWorld22.html", + "asciidoctor-zip/HelloWorld3.html", + "asciidoctor-zip/HelloWorld4.html", + "asciidoctor-zip/level-1-1/asciidoctor-icon.jpg", + "asciidoctor-zip/level-1-1/HelloWorld2.groovy", + "asciidoctor-zip/level-1-1/level-2-1/HelloWorld3.groovy", + "asciidoctor-zip/level-1-1/level-2-2/HelloWorld3.groovy", + "asciidoctor-zip/level-1-1/level-2-2/level-3-1/HelloWorld4.groovy" ); assertThat(names) - .containsAll(expected); + .containsAll(expected); } private List getNames(Enumeration entries) { 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 b8247cfc..372b3266 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 @@ -1,14 +1,14 @@ package org.asciidoctor.maven; -import org.asciidoctor.maven.process.SourceDirectoryFinder; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - import java.io.File; import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; +import org.asciidoctor.maven.process.SourceDirectoryFinder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + import static org.asciidoctor.maven.process.SourceDirectoryFinder.ORDERED_CANDIDATE_PATHS; import static org.assertj.core.api.Assertions.assertThat; 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 8e56d9b4..b9c34bdd 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 @@ -1,8 +1,23 @@ package org.asciidoctor.maven.extensions; import org.asciidoctor.Asciidoctor; -import org.asciidoctor.extension.*; -import org.asciidoctor.maven.test.processors.*; +import org.asciidoctor.extension.BlockMacroProcessor; +import org.asciidoctor.extension.BlockProcessor; +import org.asciidoctor.extension.DocinfoProcessor; +import org.asciidoctor.extension.IncludeProcessor; +import org.asciidoctor.extension.InlineMacroProcessor; +import org.asciidoctor.extension.JavaExtensionRegistry; +import org.asciidoctor.extension.Postprocessor; +import org.asciidoctor.extension.Preprocessor; +import org.asciidoctor.extension.Treeprocessor; +import org.asciidoctor.maven.test.processors.ChangeAttributeValuePreprocessor; +import org.asciidoctor.maven.test.processors.DummyPostprocessor; +import org.asciidoctor.maven.test.processors.DummyTreeprocessor; +import org.asciidoctor.maven.test.processors.GistBlockMacroProcessor; +import org.asciidoctor.maven.test.processors.ManpageInlineMacroProcessor; +import org.asciidoctor.maven.test.processors.MetaDocinfoProcessor; +import org.asciidoctor.maven.test.processors.UriIncludeProcessor; +import org.asciidoctor.maven.test.processors.YellBlockProcessor; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -32,8 +47,8 @@ void should_fail_when_not_an_extension() { Exception e = Assertions.catchException(() -> pluginExtensionRegistry.register(className, null)); assertThat(e) - .isInstanceOf(RuntimeException.class) - .hasMessage(String.format("'%s' is not a valid AsciidoctorJ processor class", className)); + .isInstanceOf(RuntimeException.class) + .hasMessage(String.format("'%s' is not a valid AsciidoctorJ processor class", className)); } @Test @@ -43,8 +58,8 @@ void should_fail_when_extension_class_is_not_available() { Exception e = Assertions.catchException(() -> pluginExtensionRegistry.register(className, null)); assertThat(e) - .isInstanceOf(RuntimeException.class) - .hasMessage(String.format("'%s' not found in classpath", className)); + .isInstanceOf(RuntimeException.class) + .hasMessage(String.format("'%s' not found in classpath", className)); } @Test 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 ce1fe894..7b05314c 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 @@ -1,12 +1,5 @@ package org.asciidoctor.maven.http; -import lombok.SneakyThrows; -import lombok.Value; -import org.apache.commons.io.IOUtils; -import org.apache.maven.plugin.logging.Log; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - import java.io.File; import java.io.InputStream; import java.net.ConnectException; @@ -16,7 +9,17 @@ import java.util.Random; import java.util.UUID; -import static io.netty.handler.codec.http.HttpResponseStatus.*; +import lombok.SneakyThrows; +import lombok.Value; +import org.apache.commons.io.IOUtils; +import org.apache.maven.plugin.logging.Log; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; +import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; +import static io.netty.handler.codec.http.HttpResponseStatus.RESET_CONTENT; import static org.asciidoctor.maven.io.TestFilesHelper.createFileWithContent; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/ConsoleHolder.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/ConsoleHolder.java index 31017665..49393899 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/ConsoleHolder.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/ConsoleHolder.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.PrintStream; +import lombok.SneakyThrows; + /** * Helping class to capture console input and output for tests. diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/DoubleOutputStream.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/DoubleOutputStream.java index 4722e042..79725d1a 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/DoubleOutputStream.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/DoubleOutputStream.java @@ -1,10 +1,10 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - import java.io.ByteArrayOutputStream; import java.io.OutputStream; +import lombok.SneakyThrows; + public class DoubleOutputStream extends ByteArrayOutputStream { final OutputStream other; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/PrefilledInputStream.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/PrefilledInputStream.java index 21dc858d..f8a4effa 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/PrefilledInputStream.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/PrefilledInputStream.java @@ -1,10 +1,10 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - import java.io.ByteArrayInputStream; import java.util.concurrent.CountDownLatch; +import lombok.SneakyThrows; + public class PrefilledInputStream extends ByteArrayInputStream { final CountDownLatch latch; 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 e047bdc7..5211a42f 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 @@ -1,14 +1,13 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - -import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicInteger; +import lombok.SneakyThrows; + /** * Reads from a collection of strings to simulate command line inputs. * {@link InputStream#read(byte[], int, int)} will wait indefinitely 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 29686859..a48297ea 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 @@ -1,11 +1,11 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - import java.io.File; import java.nio.file.Files; import java.util.UUID; +import lombok.SneakyThrows; + public class TestFilesHelper { public static final String TEST_OUTPUT_BASE_PATH = "target/test-outputs/"; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/UserInputSimulator.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/UserInputSimulator.java index c3a0c350..b176dd1a 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/UserInputSimulator.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/io/UserInputSimulator.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.io; -import lombok.SneakyThrows; - import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.concurrent.CountDownLatch; +import lombok.SneakyThrows; + public class UserInputSimulator { private final CountDownLatch inputLatch; 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 14d8842f..fc6376a3 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 @@ -1,19 +1,19 @@ package org.asciidoctor.maven.process; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + import org.apache.commons.io.FileUtils; import org.asciidoctor.maven.AsciidoctorMojo; -import org.asciidoctor.maven.test.TestUtils.ResourceBuilder; import org.asciidoctor.maven.model.Resource; +import org.asciidoctor.maven.test.TestUtils.ResourceBuilder; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - import static org.asciidoctor.maven.io.TestFilesHelper.createFileWithContent; import static org.asciidoctor.maven.process.CopyResourcesProcessor.IGNORED_FILE_NAMES; import static org.assertj.core.api.Assertions.assertThat; 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 16c4137d..1b8dcf56 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 @@ -1,13 +1,13 @@ package org.asciidoctor.maven.process; -import org.junit.jupiter.api.Test; - import java.io.File; import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.Assertions.assertThat; class SourceDocumentFinderTest { 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 c0d6a42d..03c07fb9 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 @@ -1,12 +1,6 @@ package org.asciidoctor.maven.refresh; -import org.apache.maven.plugin.logging.Log; -import org.asciidoctor.maven.AsciidoctorRefreshMojo; -import org.asciidoctor.maven.model.Resource; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; - import java.io.File; import java.util.Arrays; import java.util.List; @@ -15,6 +9,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.maven.plugin.logging.Log; +import org.asciidoctor.maven.AsciidoctorRefreshMojo; +import org.asciidoctor.maven.model.Resource; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + import static org.asciidoctor.maven.io.TestFilesHelper.createFileWithContent; import static org.asciidoctor.maven.io.TestFilesHelper.newOutputTestDirectory; import static org.assertj.core.api.Assertions.assertThat; 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 e120dd8c..97013f4a 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 @@ -1,10 +1,10 @@ package org.asciidoctor.maven.refresh; -import org.junit.jupiter.api.Test; - import java.util.Arrays; import java.util.Collections; +import org.junit.jupiter.api.Test; + import static org.assertj.core.api.Assertions.assertThat; class ResourcesPatternBuilderTest { diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMocker.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMocker.java index 4edca0cd..4755c0e5 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMocker.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMocker.java @@ -1,5 +1,9 @@ package org.asciidoctor.maven.test; +import java.io.File; +import java.util.Map; +import java.util.Properties; + import lombok.SneakyThrows; import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.project.MavenProject; @@ -7,10 +11,6 @@ import org.asciidoctor.maven.log.LogHandler; import org.mockito.Mockito; -import java.io.File; -import java.util.Map; -import java.util.Properties; - import static org.codehaus.plexus.util.ReflectionUtils.setVariableValueInObject; import static org.mockito.Mockito.when; diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMockerTest.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMockerTest.java index f18a6928..2a83b6d8 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMockerTest.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/MojoMockerTest.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.test; +import java.util.Map; + import org.asciidoctor.maven.AsciidoctorMojo; import org.asciidoctor.maven.log.LogHandler; import org.junit.jupiter.api.Test; -import java.util.Map; - import static org.assertj.core.api.Assertions.assertThat; class MojoMockerTest { diff --git a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/TestUtils.java b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/TestUtils.java index 08d148d1..3b879d37 100644 --- a/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/TestUtils.java +++ b/asciidoctor-maven-plugin/src/test/java/org/asciidoctor/maven/test/TestUtils.java @@ -1,12 +1,5 @@ package org.asciidoctor.maven.test; -import org.asciidoctor.maven.AsciidoctorHttpMojo; -import org.asciidoctor.maven.AsciidoctorMojo; -import org.asciidoctor.maven.AsciidoctorRefreshMojo; -import org.asciidoctor.maven.AsciidoctorZipMojo; -import org.asciidoctor.maven.log.LogHandler; -import org.asciidoctor.maven.model.Resource; - import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -14,6 +7,13 @@ import java.util.Map; import java.util.stream.Collectors; +import org.asciidoctor.maven.AsciidoctorHttpMojo; +import org.asciidoctor.maven.AsciidoctorMojo; +import org.asciidoctor.maven.AsciidoctorRefreshMojo; +import org.asciidoctor.maven.AsciidoctorZipMojo; +import org.asciidoctor.maven.log.LogHandler; +import org.asciidoctor.maven.model.Resource; + 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; 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 267ac005..f4b2afb6 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 @@ -1,7 +1,6 @@ package org.asciidoctor.maven.test.processors; import org.asciidoctor.Asciidoctor; -import org.asciidoctor.extension.JavaExtensionRegistry; import org.asciidoctor.jruby.extension.spi.ExtensionRegistry; public class AutoregisteredProcessor implements ExtensionRegistry { 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 636d9ab7..f0e7b078 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,11 +1,11 @@ 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"; 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 60a45ee9..597756d3 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,10 +1,10 @@ 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) { 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 fde03d24..52102395 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,11 +1,11 @@ package org.asciidoctor.maven.test.processors; -import org.asciidoctor.ast.Document; -import org.asciidoctor.extension.Treeprocessor; - import java.util.HashMap; import java.util.Map; +import org.asciidoctor.ast.Document; +import org.asciidoctor.extension.Treeprocessor; + public class DummyTreeprocessor extends Treeprocessor { public DummyTreeprocessor() { 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 2a14aa36..35a2183d 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 @@ -1,11 +1,11 @@ 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 FailingPreprocessor extends Preprocessor { public FailingPreprocessor(Map config) { 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 a47c3db9..28a9bced 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 @@ -1,12 +1,12 @@ package org.asciidoctor.maven.test.processors; +import java.util.List; +import java.util.Map; + import org.asciidoctor.ast.Block; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.extension.BlockMacroProcessor; -import java.util.List; -import java.util.Map; - public class GistBlockMacroProcessor extends BlockMacroProcessor { public GistBlockMacroProcessor(String macroName, Map config) { 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 0600ffb3..9d5097e3 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 @@ -1,11 +1,11 @@ package org.asciidoctor.maven.test.processors; -import org.asciidoctor.ast.ContentNode; -import org.asciidoctor.extension.InlineMacroProcessor; - import java.util.HashMap; import java.util.Map; +import org.asciidoctor.ast.ContentNode; +import org.asciidoctor.extension.InlineMacroProcessor; + public class ManpageInlineMacroProcessor extends InlineMacroProcessor { public ManpageInlineMacroProcessor(String macroName) { 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 a68d9912..484c913b 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,10 +1,10 @@ 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) { 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 644d2919..a43ce01c 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 @@ -1,9 +1,5 @@ package org.asciidoctor.maven.test.processors; -import org.asciidoctor.ast.Document; -import org.asciidoctor.extension.IncludeProcessor; -import org.asciidoctor.extension.PreprocessorReader; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -11,6 +7,10 @@ import java.util.Map; import java.util.stream.Collectors; +import org.asciidoctor.ast.Document; +import org.asciidoctor.extension.IncludeProcessor; +import org.asciidoctor.extension.PreprocessorReader; + public class UriIncludeProcessor extends IncludeProcessor { public UriIncludeProcessor(Map config) { 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 937861ea..71f6921f 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 @@ -1,14 +1,14 @@ package org.asciidoctor.maven.test.processors; -import org.asciidoctor.ast.StructuralNode; -import org.asciidoctor.extension.BlockProcessor; -import org.asciidoctor.extension.Reader; - import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.asciidoctor.ast.StructuralNode; +import org.asciidoctor.extension.BlockProcessor; +import org.asciidoctor.extension.Reader; + public class YellBlockProcessor extends BlockProcessor { @SuppressWarnings("serial") 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 6be27d69..542a58bf 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 @@ -1,5 +1,12 @@ package org.asciidoctor.maven.site.ast; +import javax.inject.Inject; +import javax.inject.Provider; +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.util.logging.Logger; + import org.apache.maven.doxia.parser.AbstractTextParser; import org.apache.maven.doxia.parser.ParseException; import org.apache.maven.doxia.parser.Parser; @@ -23,13 +30,6 @@ import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.Xpp3Dom; -import javax.inject.Inject; -import javax.inject.Provider; -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.util.logging.Logger; - import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; /** diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/NodesSinker.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/NodesSinker.java index 7aace284..6571cb54 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/NodesSinker.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/NodesSinker.java @@ -1,5 +1,9 @@ package org.asciidoctor.maven.site.ast; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.maven.site.ast.processors.DocumentNodeProcessor; @@ -14,10 +18,6 @@ import org.asciidoctor.maven.site.ast.processors.TableNodeProcessor; import org.asciidoctor.maven.site.ast.processors.UnorderedListNodeProcessor; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - /** * Document processor. * Responsible for initializing the different Node Processors diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessor.java index 05b56a45..431a455c 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ImageNodeProcessor.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.site.ast.processors; +import java.nio.file.FileSystems; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.maven.site.ast.NodeProcessor; -import java.nio.file.FileSystems; - import static org.asciidoctor.maven.commons.StringUtils.isBlank; /** diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessor.java index bbd7c7e4..2a42d6f2 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/ListItemNodeProcessor.java @@ -1,12 +1,12 @@ package org.asciidoctor.maven.site.ast.processors; +import java.util.List; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.ListItem; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.maven.site.ast.NodeProcessor; -import java.util.List; - /** * List items processor, including numbered and unnumbered. * diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessor.java index 1bed4dc7..0b85dc25 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/OrderedListNodeProcessor.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.site.ast.processors; +import java.util.List; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.maven.site.ast.NodeProcessor; -import java.util.List; - /** * Ordered list processor. * diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessor.java index 88528041..e07ff5d3 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/TableNodeProcessor.java @@ -1,5 +1,7 @@ package org.asciidoctor.maven.site.ast.processors; +import java.util.List; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.Cell; import org.asciidoctor.ast.Row; @@ -7,8 +9,6 @@ import org.asciidoctor.jruby.ast.impl.TableImpl; import org.asciidoctor.maven.site.ast.NodeProcessor; -import java.util.List; - import static org.apache.maven.doxia.sink.Sink.JUSTIFY_LEFT; import static org.asciidoctor.maven.commons.StringUtils.isBlank; import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessor.java index 12228d81..d91ed183 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/ast/processors/UnorderedListNodeProcessor.java @@ -1,11 +1,11 @@ package org.asciidoctor.maven.site.ast.processors; +import java.util.List; + import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.maven.site.ast.NodeProcessor; -import java.util.List; - /** * Unordered list processor. * 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 a8170096..dc6bfafe 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 @@ -1,5 +1,11 @@ package org.asciidoctor.maven.site.ast.processors; +import java.io.StringWriter; +import java.nio.file.FileSystems; +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -7,12 +13,6 @@ import org.asciidoctor.maven.site.ast.processors.test.NodeProcessorTest; import org.junit.jupiter.api.Test; -import java.io.StringWriter; -import java.nio.file.FileSystems; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; - import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ImageNodeProcessor.class) 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 b733409d..c1b601f3 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 @@ -1,5 +1,8 @@ package org.asciidoctor.maven.site.ast.processors; +import java.io.StringWriter; +import java.util.Collections; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -7,9 +10,6 @@ import org.asciidoctor.maven.site.ast.processors.test.NodeProcessorTest; import org.junit.jupiter.api.Test; -import java.io.StringWriter; -import java.util.Collections; - import static org.asciidoctor.maven.site.ast.processors.test.StringTestUtils.clean; import static org.assertj.core.api.Assertions.assertThat; @@ -28,7 +28,7 @@ void should_convert_full_source_block() { String html = process(content); assertThat(html) - .isEqualTo(expectedHtmlCodeBlock()); + .isEqualTo(expectedHtmlCodeBlock()); } @Test @@ -38,16 +38,16 @@ void should_convert_shorthand_source_block() { String html = process(content); assertThat(html) - .isEqualTo(expectedHtmlCodeBlock()); + .isEqualTo(expectedHtmlCodeBlock()); } private static String expectedHtmlCodeBlock() { // Actual styling is added in JS by prettify return "
class HelloWorldLanguage {" +
-                "    public static void main(String[] args) {" +
-                "        System.out.println(\"Hello, World!\");" +
-                "    }" +
-                "}
"; + " public static void main(String[] args) {" + + " System.out.println(\"Hello, World!\");" + + " }" + + "}"; } @Test @@ -57,7 +57,7 @@ void should_convert_full_source_block_with_line_numbers_attribute() { String html = process(content); assertThat(html) - .startsWith("
");
+            .startsWith("
");
     }
 
     @Test
@@ -67,7 +67,7 @@ void should_convert_full_source_block_with_line_numbers_option() {
         String html = process(content);
 
         assertThat(html)
-                .startsWith("
");
+            .startsWith("
");
     }
 
     @Test
@@ -77,11 +77,11 @@ void should_convert_listing_style_block() {
         String html = process(content);
 
         assertThat(html)
-                .isEqualTo("
class HelloWorldLanguage {" +
-                        "    public static void main(String[] args) {" +
-                        "        System.out.println(\"Hello, World!\");" +
-                        "    }" +
-                        "}
"); + .isEqualTo("
class HelloWorldLanguage {" +
+                "    public static void main(String[] args) {" +
+                "        System.out.println(\"Hello, World!\");" +
+                "    }" +
+                "}
"); } private String documentWithFullSourceBlock() { @@ -98,21 +98,21 @@ private String documentWithListingStyleSourceBlock() { private static String buildDocument(String blockDefinition) { return "= Document tile\n\n" - + "== Section\n\n" - + blockDefinition + "\n" + - "----\n" + - "class HelloWorldLanguage {\n" + - " public static void main(String[] args) {\n" + - " System.out.println(\"Hello, World!\");\n" + - " }\n" + - "}\n" + - "----\n"; + + "== Section\n\n" + + blockDefinition + "\n" + + "----\n" + + "class HelloWorldLanguage {\n" + + " public static void main(String[] args) {\n" + + " System.out.println(\"Hello, World!\");\n" + + " }\n" + + "}\n" + + "----\n"; } private String process(String content) { StructuralNode node = asciidoctor.load(content, Options.builder().build()) - .findBy(Collections.singletonMap("context", ":listing")) - .get(0); + .findBy(Collections.singletonMap("context", ":listing")) + .get(0); nodeProcessor.process(node); 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 bf0b45df..f8739e53 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 @@ -1,5 +1,8 @@ package org.asciidoctor.maven.site.ast.processors; +import java.io.StringWriter; +import java.util.Collections; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -7,9 +10,6 @@ import org.asciidoctor.maven.site.ast.processors.test.NodeProcessorTest; import org.junit.jupiter.api.Test; -import java.io.StringWriter; -import java.util.Collections; - import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(LiteralNodeProcessor.class) 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 13b1376a..dd4e45fd 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 @@ -1,5 +1,11 @@ package org.asciidoctor.maven.site.ast.processors; +import java.io.StringWriter; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -7,14 +13,11 @@ import org.asciidoctor.maven.site.ast.processors.test.NodeProcessorTest; import org.junit.jupiter.api.Test; -import java.io.StringWriter; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - import static java.util.Collections.emptyList; -import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.CaptionOptions.*; +import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.CaptionOptions.disableLabelForTable; +import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.CaptionOptions.disableLabelsGlobally; +import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.CaptionOptions.noCaption; +import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.CaptionOptions.simpleCaption; import static org.asciidoctor.maven.site.ast.processors.TableNodeProcessorTest.DocumentBuilder.documentWithTable; import static org.asciidoctor.maven.site.ast.processors.test.StringTestUtils.clean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/JUnitNodeProcessorExtension.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/JUnitNodeProcessorExtension.java index 9b806ba1..48c2b5f0 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/JUnitNodeProcessorExtension.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/JUnitNodeProcessorExtension.java @@ -1,5 +1,8 @@ package org.asciidoctor.maven.site.ast.processors.test; +import java.io.StringWriter; +import java.lang.reflect.Field; + import org.apache.commons.lang3.tuple.Pair; import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.Asciidoctor; @@ -7,10 +10,9 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.TestInstancePostProcessor; -import java.io.StringWriter; -import java.lang.reflect.Field; - -import static org.asciidoctor.maven.site.ast.processors.test.ReflectionUtils.*; +import static org.asciidoctor.maven.site.ast.processors.test.ReflectionUtils.extractField; +import static org.asciidoctor.maven.site.ast.processors.test.ReflectionUtils.findField; +import static org.asciidoctor.maven.site.ast.processors.test.ReflectionUtils.injectField; public class JUnitNodeProcessorExtension implements TestInstancePostProcessor { diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/NodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/NodeProcessorTest.java index 3cf28520..5bc8a554 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/NodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/NodeProcessorTest.java @@ -1,13 +1,13 @@ package org.asciidoctor.maven.site.ast.processors.test; -import org.asciidoctor.maven.site.ast.NodeProcessor; -import org.junit.jupiter.api.extension.ExtendWith; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.asciidoctor.maven.site.ast.NodeProcessor; +import org.junit.jupiter.api.extension.ExtendWith; + @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @ExtendWith(JUnitNodeProcessorExtension.class) diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/TestNodeProcessorFactory.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/TestNodeProcessorFactory.java index 142757d4..2eb96986 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/TestNodeProcessorFactory.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/ast/processors/test/TestNodeProcessorFactory.java @@ -1,5 +1,7 @@ package org.asciidoctor.maven.site.ast.processors.test; +import java.lang.reflect.Constructor; + import lombok.SneakyThrows; import org.apache.commons.lang3.tuple.Pair; import org.apache.maven.doxia.sink.Sink; @@ -8,8 +10,6 @@ import org.asciidoctor.maven.site.ast.NodeProcessor; import org.mockito.Mockito; -import java.lang.reflect.Constructor; - public class TestNodeProcessorFactory { @SneakyThrows diff --git a/docs/modules/project/pages/contributing.adoc b/docs/modules/project/pages/contributing.adoc index 959a969a..a33c3624 100644 --- a/docs/modules/project/pages/contributing.adoc +++ b/docs/modules/project/pages/contributing.adoc @@ -16,13 +16,23 @@ There are multiple ways where you can help: Developer setup for hacking on this project isn't very difficult. The requirements are very small: -* Java 8 or higher +* Java 11 or higher * Maven 3 Everything else will be brought in by Maven. This is a typical Maven Java project, nothing special. You should be able to use IntelliJ, Eclipse, or NetBeans without any issue for hacking on the project. +== Code formatting + +The project doesn't have a strict policy, but there are some rules provided in using https://editorconfig.org/[.editorconfig] file. +Check your IDE for `editorconfig` support. + +The rules are: + +* Use of spaces for indentation. +* Maven import https://maven.apache.org/developers/conventions/code.html#java-code-convention-import-layouts[policy]. + == Testing Unit tests are written with http://spockframework.org/[Spock].