Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class RestructuredTextImporter extends AbstractLightWeightMarkupImporter
}

@Override
@SuppressWarnings("java:S138") // Transition table is OK be larger than 75 lines.
protected Transition[] configureTransitions()
{
// @formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ public TreeContentHandler build()
throw new ImporterException("Element " + elem + " does not have an attribute '"
+ DOCTYPE_ATTRIBUTE_NAME + "' at " + elem.getLocation());
}
final String defaultDoctype = doctypeAttribute.getValue();
this.handler.pushDelegate(new SpecObjectsHandlerBuilder(this.file, defaultDoctype, this.listener)
.build());
this.handler.pushDelegate(new SpecObjectsHandlerBuilder(this.file, doctypeAttribute.getValue(),
this.listener).build());
});

return this.handler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void init(final TreeParsingController treeParsingController)
}

@Override
@SuppressWarnings("java:S2221") // Intentionally catching all exceptions to provide better error messages.
public void startElement(final TreeElement treeElement)
{
LOG.finest(() -> "Start element: " + treeElement);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private ImportAssertions()
* @param importerFactory
* factory that generates the importer
*/
@SuppressWarnings("java:S4968") // Match type definition comes from Hamcrest. Cannot change.
public static void assertImportWithFactory(final Path path, final String input,
final Matcher<Iterable<? extends SpecificationItem>> matcher,
final ImporterFactory importerFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.itsallcode.matcher.auto.AutoMatcher.contains;
import static org.itsallcode.openfasttrace.api.core.SpecificationItemId.createId;
import static org.itsallcode.openfasttrace.testutil.core.ItemBuilderFactory.item;
import static org.itsallcode.openfasttrace.testutil.importer.ImportAssertions.assertImportWithFactory;
import static org.itsallcode.openfasttrace.testutil.importer.ImportAssertions.runImporterOnText;

import java.nio.file.Path;
import java.util.List;
Expand All @@ -16,6 +13,7 @@
import org.hamcrest.Matcher;
import org.itsallcode.openfasttrace.api.core.*;
import org.itsallcode.openfasttrace.api.importer.ImporterFactory;
import org.itsallcode.openfasttrace.testutil.importer.ImportAssertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;
Expand Down Expand Up @@ -100,7 +98,7 @@ protected void assertImport(final String path, final String input,
protected void assertImport(final Path path, final String input,
final Matcher<Iterable<? extends SpecificationItem>> matcher)
{
assertImportWithFactory(path, processTextInput(input), matcher, getImporterFactory());
ImportAssertions.assertImportWithFactory(path, processTextInput(input), matcher, getImporterFactory());
}

private String processTextInput(final String input)
Expand Down Expand Up @@ -236,7 +234,7 @@ static Stream<Arguments> tags()
@MethodSource("tags")
void testTags(final String mdContent, final List<String> expected)
{
final List<SpecificationItem> items = runImporterOnText(Path.of("irrelevant-filename"),
final List<SpecificationItem> items = ImportAssertions.runImporterOnText(Path.of("irrelevant-filename"),
"`a~b~1`\n" + mdContent,
getImporterFactory());
assertThat(items.get(0).getTags(), equalTo(expected));
Expand Down Expand Up @@ -538,7 +536,7 @@ static Stream<Arguments> needsCoverage()
@MethodSource("needsCoverage")
void testNeedsCoverage(final String mdContent, final List<String> expected)
{
final List<SpecificationItem> items = runImporterOnText(Path.of("irrelevant-filename"),
final List<SpecificationItem> items = ImportAssertions.runImporterOnText(Path.of("irrelevant-filename"),
"`a~b~1`\n" + mdContent,
getImporterFactory());
assertThat(items.get(0).getNeedsArtifactTypes(), equalTo(expected));
Expand Down Expand Up @@ -570,7 +568,7 @@ void testItemIdSupportsUTF8Characaters()
Needs: arch
""",
contains(item()
.id(createId("req", "zellzustandsänderung", 1))
.id(SpecificationItemId.createId("req", "zellzustandsänderung", 1))
.title("Die Implementierung muss den Zustand einzelner Zellen ändern")
.description("Ermöglicht die Aktualisierung des Zustands von lebenden und toten Zellen"
+ " in jeder Generation.")
Expand All @@ -591,12 +589,12 @@ void testHeaderBelongsToNextItem()
`req~item2~1
Item 2 description
""",
contains(item().id(createId("req", "item1", 1))
contains(item().id(SpecificationItemId.createId("req", "item1", 1))
.title("Item 1")
.description("Item 1 description")
.location("file", 2 + titleLocationOffset)
.build(),
item().id(createId("req", "item2", 1))
item().id(SpecificationItemId.createId("req", "item2", 1))
.title("Item 2")
.description("Item 2 description")
.location("file", 6 + (2 * titleLocationOffset))
Expand All @@ -614,7 +612,7 @@ void testParsingNeedsIgnoresExtraListItems() {
* this must not be in needs section
""",
contains(item()
.id(createId("feat", "the-feature", 1))
.id(SpecificationItemId.createId("feat", "the-feature", 1))
.addNeedsArtifactType("arch")
.description("* this must not be in needs section")
.location("needs_with_extra_list_items.md", 1)
Expand All @@ -638,12 +636,12 @@ void testNeedsAfterCovers() {
Needs: itest
""",
contains(item()
.id(createId("dsn", "needs", 3))
.id(SpecificationItemId.createId("dsn", "needs", 3))
.description("Description with a bulleted list"
+ System.lineSeparator()
+ System.lineSeparator() + "* this"
+ System.lineSeparator() + "* that")
.addCoveredId(createId("req", "needs", 2))
.addCoveredId(SpecificationItemId.createId("req", "needs", 2))
.addNeedsArtifactType("itest")
.location("needs_after_covers.md", 1)
.build()));
Expand Down
Loading