From 002102cb7451913e14687e1b9fbeaf89faa62940 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Fri, 18 Oct 2024 22:33:49 +0200 Subject: [PATCH] Fix tests --- CHANGELOG.adoc | 3 + .../parser/AsciidoctorAstDoxiaParser.java | 16 +- .../maven/site/parser/NodeSinker.java | 3 +- .../processors/DocumentNodeProcessor.java | 13 +- .../processors/LiteralNodeProcessor.java | 14 +- .../parser/AsciidoctorAstDoxiaParserTest.java | 16 +- .../maven/site/parser/NodeSinkerTest.java | 6 +- .../processors/DocumentNodeProcessorTest.java | 18 ++- .../processors/ListItemNodeProcessorTest.java | 34 ++--- .../processors/LiteralNodeProcessorTest.java | 8 +- .../processors/SectionNodeProcessorTest.java | 144 +++++++++--------- .../UnorderedListNodeProcessorTest.java | 60 ++++---- 12 files changed, 188 insertions(+), 147 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index e5d18bf6..28ea77b3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -23,6 +23,9 @@ Improvements:: * Added support for AsciidoctorJ v3.0.0 (#651) * Add compatibility with maven-site-plugin v3.20.0 and Doxia v2.0.0 (#933) * Add support for code blocks titles in asciidoctor-parser-doxia-module (#935) + * Refactor AST traversal method in asciidoctor-parser-doxia-module (#944) + * Empty titles in document or empty literals no longer generate

or
 in asciidoctor-parser-doxia-module (#944)
+  * Sections are now wrapped in 
in asciidoctor-parser-doxia-module (#944) Build / Infrastructure:: diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParser.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParser.java index f06d6246..9ab0424a 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParser.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParser.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; import java.io.Reader; +import java.util.List; import java.util.logging.Logger; import org.apache.maven.doxia.parser.AbstractTextParser; @@ -28,6 +29,7 @@ import org.asciidoctor.maven.site.SiteConversionConfiguration; import org.asciidoctor.maven.site.SiteConversionConfigurationParser; import org.asciidoctor.maven.site.SiteLogHandlerDeserializer; +import org.asciidoctor.maven.site.parser.processors.DescriptionListNodeProcessor; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -82,7 +84,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept final Asciidoctor asciidoctor = Asciidoctor.Factory.create(); SiteConversionConfiguration conversionConfig = new SiteConversionConfigurationParser(project) - .processAsciiDocConfig(siteConfig, defaultOptions(siteDirectory), defaultAttributes()); + .processAsciiDocConfig(siteConfig, defaultOptions(siteDirectory), defaultAttributes()); for (String require : conversionConfig.getRequires()) { requireLibrary(asciidoctor, require); } @@ -98,7 +100,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept try { // process log messages according to mojo configuration new LogRecordsProcessors(logHandler, siteDirectory, errorMessage -> logger.error(errorMessage)) - .processLogRecords(memoryLogHandler); + .processLogRecords(memoryLogHandler); } catch (Exception exception) { throw new ParseException(exception.getMessage(), exception); @@ -146,15 +148,15 @@ protected File resolveSiteDirectory(MavenProject project, Xpp3Dom siteConfig) { protected OptionsBuilder defaultOptions(File siteDirectory) { return Options.builder() - .backend("xhtml") - .safe(SafeMode.UNSAFE) - .baseDir(new File(siteDirectory, ROLE_HINT)); + .backend("xhtml") + .safe(SafeMode.UNSAFE) + .baseDir(new File(siteDirectory, ROLE_HINT)); } protected AttributesBuilder defaultAttributes() { return Attributes.builder() - .attribute("idprefix", "@") - .attribute("showtitle", "@"); + .attribute("idprefix", "@") + .attribute("showtitle", "@"); } private void requireLibrary(Asciidoctor asciidoctor, String require) { diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodeSinker.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodeSinker.java index 53b47c1b..604bfced 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodeSinker.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/NodeSinker.java @@ -20,6 +20,8 @@ import org.asciidoctor.maven.site.parser.processors.UnorderedListNodeProcessor; /** + * Factory and repository for NodeProcessors. + * * @author abelsromero * @since 3.1.0 */ @@ -29,7 +31,6 @@ public class NodeSinker { private final NodeProcessor noOpProcessor; - // TODO this should not be public public NodeSinker(Sink sink) { nodeProcessors = Arrays.asList( new DescriptionListNodeProcessor(sink, this), diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessor.java index 75b096c1..9437cb1c 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessor.java @@ -5,6 +5,8 @@ import org.asciidoctor.maven.site.parser.NodeProcessor; import org.asciidoctor.maven.site.parser.NodeSinker; +import static org.asciidoctor.maven.commons.StringUtils.isNotBlank; + /** * Root document processor. * @@ -32,11 +34,12 @@ public void process(StructuralNode node) { final Sink sink = getSink(); sink.body(); - // TODO review how this fits with Section titles also being 1 - sink.sectionTitle1(); - sink.rawText(node.getTitle()); - sink.sectionTitle1_(); - + String title = node.getTitle(); + if (isNotBlank(title)) { + sink.sectionTitle1(); + sink.rawText(title); + sink.sectionTitle1_(); + } node.getBlocks() .forEach(this::sink); diff --git a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessor.java b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessor.java index 17f5f665..e12ac6f8 100644 --- a/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessor.java +++ b/asciidoctor-parser-doxia-module/src/main/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessor.java @@ -3,6 +3,7 @@ import org.apache.maven.doxia.sink.Sink; import org.asciidoctor.ast.StructuralNode; import org.asciidoctor.jruby.ast.impl.BlockImpl; +import org.asciidoctor.maven.commons.StringUtils; import org.asciidoctor.maven.site.parser.NodeProcessor; import org.asciidoctor.maven.site.parser.NodeSinker; @@ -33,10 +34,13 @@ public boolean applies(StructuralNode node) { public void process(StructuralNode node) { final Sink sink = getSink(); - sink.division(); - sink.rawText("
");
-        sink.rawText(((BlockImpl) node).getSource());
-        sink.rawText("
"); - sink.division_(); + String source = ((BlockImpl) node).getSource(); + if (StringUtils.isNotBlank(source)) { + sink.division(); + sink.rawText("
");
+            sink.rawText(source);
+            sink.rawText("
"); + sink.division_(); + } } } diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParserTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParserTest.java index 2a836449..fc30ef6e 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParserTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/AsciidoctorAstDoxiaParserTest.java @@ -1,5 +1,11 @@ package org.asciidoctor.maven.site.parser; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.StringReader; +import java.io.StringWriter; + import lombok.SneakyThrows; import org.apache.maven.doxia.parser.AbstractTextParser; import org.apache.maven.doxia.parser.ParseException; @@ -10,8 +16,6 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import java.io.*; - import static org.asciidoctor.maven.site.parser.AsciidoctorAstDoxiaParserTest.TestMocks.mockAsciidoctorDoxiaParser; import static org.asciidoctor.maven.site.parser.processors.test.ReflectionUtils.extractField; import static org.asciidoctor.maven.site.parser.processors.test.StringTestUtils.clean; @@ -45,17 +49,23 @@ void should_convert_html_without_any_configuration() throws FileNotFoundExceptio assertThat(result) .isEqualTo("

Document Title

Preamble paragraph.

" + + "
"+ "

Section A

" + "

Section A paragraph.

" + + "
"+ "

Section A Subsection

" + "

Section A 'subsection' paragraph.

" + + "
"+ + "
"+ + "
"+ "

Section B

" + "

Section B paragraph.

" + "
    " + "
  • Item 1
  • " + "
  • Item 2
  • " + "
  • Item 3
" + - "
require 'asciidoctor'
"); + "
require 'asciidoctor'
" + + "
"); } @Test diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/NodeSinkerTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/NodeSinkerTest.java index 942f5ab8..fc04e6ab 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/NodeSinkerTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/NodeSinkerTest.java @@ -4,6 +4,7 @@ import java.util.List; import org.apache.maven.doxia.sink.Sink; +import org.asciidoctor.ast.Block; import org.asciidoctor.ast.Document; import org.asciidoctor.ast.ListItem; import org.asciidoctor.ast.StructuralNode; @@ -27,7 +28,6 @@ class NodeSinkerTest { private NodeSinker nodeSinker; private StringWriter sinkWriter; - @BeforeEach void setup() throws NoSuchFieldException, IllegalAccessException { Sink sink = createSink(); @@ -53,6 +53,7 @@ void should_not_fail_when_processing_invalid_node() { @Test void should_process_document_node() { StructuralNode mockNode = mockNode("document"); + Mockito.when(mockNode.getTitle()).thenReturn("Something"); nodeSinker.sink(mockNode); @@ -171,6 +172,9 @@ private static StructuralNode mockNode(String nodeName) { private static T mockNode(String nodeName, Class clazz) { StructuralNode mockNode = Mockito.mock(clazz); Mockito.when(mockNode.getNodeName()).thenReturn(nodeName); + if (Block.class.isAssignableFrom(clazz)) { + Mockito.when(((Block) mockNode).getSource()).thenReturn("Something"); + } return (T) mockNode; } } diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessorTest.java index 6d19d252..3fd02335 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/DocumentNodeProcessorTest.java @@ -1,5 +1,7 @@ package org.asciidoctor.maven.site.parser.processors; +import java.io.StringWriter; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -7,8 +9,6 @@ import org.asciidoctor.maven.site.parser.processors.test.NodeProcessorTest; import org.junit.jupiter.api.Test; -import java.io.StringWriter; - import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(DocumentNodeProcessor.class) @@ -18,6 +18,16 @@ class DocumentNodeProcessorTest { private NodeProcessor nodeProcessor; private StringWriter sinkWriter; + @Test + void should_not_fail_if_document_is_empty() { + String content = ""; + + String html = process(content, 0); + + assertThat(html) + .isEmpty(); + } + @Test void should_convert_document_title() { String content = "= Document tile"; @@ -25,7 +35,7 @@ void should_convert_document_title() { String html = process(content, 0); assertThat(html) - .isEqualTo("

Document tile

"); + .isEqualTo("

Document tile

"); } @Test @@ -35,7 +45,7 @@ void should_convert_document_title_with_markup() { String html = process(content, 0); assertThat(html) - .isEqualTo("

Document tile

"); + .isEqualTo("

Document tile

"); } private String process(String content, int level) { diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/ListItemNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/ListItemNodeProcessorTest.java index dbeceab8..c8deb13e 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/ListItemNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/ListItemNodeProcessorTest.java @@ -1,5 +1,8 @@ package org.asciidoctor.maven.site.parser.processors; +import java.io.StringWriter; +import java.util.Collections; + import org.asciidoctor.Asciidoctor; import org.asciidoctor.Options; import org.asciidoctor.ast.StructuralNode; @@ -9,9 +12,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import java.io.StringWriter; -import java.util.Collections; - import static org.assertj.core.api.Assertions.assertThat; @NodeProcessorTest(ListItemNodeProcessor.class) @@ -25,51 +25,51 @@ class ListItemNodeProcessorTest { @ValueSource(strings = {"*", "-"}) void should_convert_list_item(String marker) { String content = new DocumentBuilder() - .listItem(marker) - .toString(); + .listItem(marker) + .toString(); String html = process(content); assertThat(html) - .isEqualTo(htmlListItem()); + .isEqualTo(htmlListItem()); } @Test void should_convert_ordered_list_item() { String content = new DocumentBuilder() - .listItem(".") - .toString(); + .listItem(".") + .toString(); String html = process(content); assertThat(html) - .isEqualTo(htmlListItem()); + .isEqualTo(htmlListItem()); } @ParameterizedTest @ValueSource(strings = {"*", "-"}) void should_convert_ordered_list_item_with_formatting() { String content = new DocumentBuilder() - .formattedListItem("*") - .toString(); + .formattedListItem("*") + .toString(); String html = process(content); assertThat(html) - .isEqualTo(htmlListItemWithFormatting()); + .isEqualTo(htmlListItemWithFormatting()); } @ParameterizedTest @ValueSource(strings = {"*", "-"}) void should_convert_ordered_list_item_with_link(String marker) { String content = new DocumentBuilder() - .linkListItem(marker) - .toString(); + .linkListItem(marker) + .toString(); String html = process(content); assertThat(html) - .isEqualTo(htmlListItemWithLink()); + .isEqualTo(htmlListItemWithLink()); } private static String htmlListItem() { @@ -116,8 +116,8 @@ public String toString() { private String process(String content) { StructuralNode node = asciidoctor.load(content, Options.builder().build()) - .findBy(Collections.singletonMap("context", ":list_item")) - .get(0); + .findBy(Collections.singletonMap("context", ":list_item")) + .get(0); nodeProcessor.process(node); diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessorTest.java index c6a46440..231e1a5f 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/LiteralNodeProcessorTest.java @@ -26,18 +26,18 @@ void should_convert_simple_literal() { String html = process(content); assertThat(html) - .isEqualTo("
This is a literal line.
"); + .isEqualTo("
This is a literal line.
"); } private String documentWithLiteralBlock() { return "= Document tile\n\n" - + "== Section\n\n This is a literal line.\n"; + + "== Section\n\n This is a literal line.\n"; } private String process(String content) { StructuralNode node = asciidoctor.load(content, Options.builder().build()) - .findBy(Collections.singletonMap("context", ":literal")) - .get(0); + .findBy(Collections.singletonMap("context", ":literal")) + .get(0); nodeProcessor.process(node); diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/SectionNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/SectionNodeProcessorTest.java index 7b2996ce..2c32f881 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/SectionNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/SectionNodeProcessorTest.java @@ -27,7 +27,7 @@ void should_convert_document_title() { String html = process(content, 0); assertThat(html) - .isEqualTo("
\n

Document tile

"); + .isEqualTo("

Document tile

"); } @Test @@ -37,20 +37,20 @@ void should_convert_section_level_2() { String html = process(content, 1); assertThat(html) - .isEqualTo("
\n" + - "

First section title

\n" + - "

First section body

\n" + - "
\n" + - "

Second section title

\n" + - "

Second section body

\n" + - "
\n" + - "

Third section title

\n" + - "

Third section body

\n" + - "
\n" + - "
Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "

First section title

" + + "

First section body

" + + "
" + + "

Second section title

" + + "

Second section body

" + + "
" + + "

Third section title

" + + "

Third section body

" + + "
" + + "
Fourth section title
" + + "

Fourth section body

" + + "
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -61,17 +61,17 @@ void should_convert_section_level_3() { String html = process(content, 2); assertThat(html) - .isEqualTo("
\n" + - "

Second section title

\n" + - "

Second section body

\n" + - "
\n" + - "

Third section title

\n" + - "

Third section body

\n" + - "
\n" + - "
Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "

Second section title

" + + "

Second section body

" + + "
" + + "

Third section title

" + + "

Third section body

" + + "
" + + "
Fourth section title
" + + "

Fourth section body

" + + "
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -82,14 +82,14 @@ void should_convert_section_level_4() { String html = process(content, 3); assertThat(html) - .isEqualTo("
\n" + - "

Third section title

\n" + - "

Third section body

\n" + - "
\n" + - "
Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "

Third section title

" + + "

Third section body

" + + "
" + + "
Fourth section title
" + + "

Fourth section body

" + + "
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -100,11 +100,11 @@ void should_convert_section_level_5() { String html = process(content, 4); assertThat(html) - .isEqualTo("
\n" + - "
Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "
Fourth section title
" + + "

Fourth section body

" + + "
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -115,8 +115,8 @@ void should_convert_section_level_6() { String html = process(content, 5); assertThat(html) - .isEqualTo("
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -129,20 +129,20 @@ void should_convert_section_with_sectionNumbers() { // With numbering assertThat(process(content, 1, attributes)) - .isEqualTo("
\n" + - "

1. First section title

\n" + - "

First section body

\n" + - "
\n" + - "

1.1. Second section title

\n" + - "

Second section body

\n" + - "
\n" + - "

1.1.1. Third section title

\n" + - "

Third section body

\n" + - "
\n" + - "
Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
Fifth section title
\n" + + .isEqualTo("
" + + "

1. First section title

" + + "

First section body

" + + "
" + + "

1.1. Second section title

" + + "

Second section body

" + + "
" + + "

1.1.1. Third section title

" + + "

Third section body

" + + "
" + + "
Fourth section title
" + + "

Fourth section body

" + + "
" + + "
Fifth section title
" + "

Fifth section body

"); } @@ -156,20 +156,20 @@ void should_convert_section_with_sectionNumbers_and_sectNumLevels() { // With numbering assertThat(process(content, 1, attributes)) - .isEqualTo("
\n" + - "

1. First section title

\n" + - "

First section body

\n" + - "
\n" + - "

1.1. Second section title

\n" + - "

Second section body

\n" + - "
\n" + - "

1.1.1. Third section title

\n" + - "

Third section body

\n" + - "
\n" + - "
1.1.1.1. Fourth section title
\n" + - "

Fourth section body

\n" + - "
\n" + - "
1.1.1.1.1. Fifth section title
\n" + + .isEqualTo("
" + + "

1. First section title

" + + "

First section body

" + + "
" + + "

1.1. Second section title

" + + "

Second section body

" + + "
" + + "

1.1.1. Third section title

" + + "

Third section body

" + + "
" + + "
1.1.1.1. Fourth section title
" + + "

Fourth section body

" + + "
" + + "
1.1.1.1.1. Fifth section title
" + "

Fifth section body

"); } @@ -199,7 +199,11 @@ private String process(String content, int level, Attributes attributes) { reset(sinkWriter); nodeProcessor.process(node); - return sinkWriter.toString().trim(); + return removeLineBreaks(sinkWriter.toString().trim()); + } + + private static String removeLineBreaks(String html) { + return html.replaceAll("(\n)?\n", ""); } private void reset(StringWriter sinkWriter) { diff --git a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/UnorderedListNodeProcessorTest.java b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/UnorderedListNodeProcessorTest.java index c2ab213a..26d790e3 100644 --- a/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/UnorderedListNodeProcessorTest.java +++ b/asciidoctor-parser-doxia-module/src/test/java/org/asciidoctor/maven/site/parser/processors/UnorderedListNodeProcessorTest.java @@ -29,10 +29,10 @@ void should_convert_simple_list() { String html = process(content); assertThat(html) - .isEqualTo("
    " + - "
  • unordered item 1
  • " + - "
  • unordered item 2
  • " + - "
"); + .isEqualTo("
    " + + "
  • unordered item 1
  • " + + "
  • unordered item 2
  • " + + "
"); } @Test @@ -42,44 +42,44 @@ void should_convert_nested_list() { String html = process(content); assertThat(html) - .isEqualTo("
    " + - "
  • unordered item 1" + - "
      " + - "
    • unordered item 1 1
    • " + - "
    • unordered item 1 2
    • " + - "
    " + - "
  • " + - "
  • unordered item 2" + - "
      " + - "
    • unordered item 2 1" + - "
        " + - "
      • unordered item 2 1 1
    " + - "
  • " + - "
"); + .isEqualTo("
    " + + "
  • unordered item 1" + + "
      " + + "
    • unordered item 1 1
    • " + + "
    • unordered item 1 2
    • " + + "
    " + + "
  • " + + "
  • unordered item 2" + + "
      " + + "
    • unordered item 2 1" + + "
        " + + "
      • unordered item 2 1 1
    " + + "
  • " + + "
"); } private static String buildDocumentWithSimpleList() { return "= Document tile\n\n" - + "== Section\n\n" - + "* unordered item 1\n" - + "* unordered item 2\n"; + + "== Section\n\n" + + "* unordered item 1\n" + + "* unordered item 2\n"; } private static String buildDocumentWithNestedLists() { return "= Document tile\n\n" - + "== Section\n\n" - + "* unordered item 1\n" - + "** unordered item 1 1\n" - + "** unordered item 1 2\n" - + "* unordered item 2\n" - + "** unordered item 2 1\n" - + "*** unordered item 2 1 1\n"; + + "== Section\n\n" + + "* unordered item 1\n" + + "** unordered item 1 1\n" + + "** unordered item 1 2\n" + + "* unordered item 2\n" + + "** unordered item 2 1\n" + + "*** unordered item 2 1 1\n"; } private String process(String content) { StructuralNode node = asciidoctor.load(content, Options.builder().build()) - .findBy(Collections.singletonMap("context", ":ulist")) - .get(0); + .findBy(Collections.singletonMap("context", ":ulist")) + .get(0); nodeProcessor.process(node);