From abbcc3915fa783c648436ef52e15da923a246dd1 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 26 Mar 2016 09:27:45 +0000 Subject: Lazily combine warnings in results --- .../org/zwobble/mammoth/tests/MammothTests.java | 47 +++++++++++----------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/test/java/org/zwobble/mammoth/tests/MammothTests.java') diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index 7dc373c..8ac7af3 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -12,65 +12,64 @@ import java.util.function.Function; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; -import static org.zwobble.mammoth.internal.results.InternalResult.success; import static org.zwobble.mammoth.internal.util.MammothLists.list; -import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.tests.ResultMatchers.isResult; +import static org.zwobble.mammoth.tests.ResultMatchers.isSuccess; public class MammothTests { @Test public void docxContainingOneParagraphIsConvertedToSingleParagraphElement() throws IOException { assertThat( convertToHtml("single-paragraph.docx"), - deepEquals(success("

Walking on imported air

"))); + isSuccess("

Walking on imported air

")); } @Test public void canReadFilesWithUtf8Bom() throws IOException { assertThat( convertToHtml("utf8-bom.docx"), - deepEquals(success("

This XML has a byte order mark.

"))); + isSuccess("

This XML has a byte order mark.

")); } @Test public void emptyParagraphsAreIgnoredByDefault() throws IOException { assertThat( convertToHtml("empty.docx"), - deepEquals(success(""))); + isSuccess("")); } @Test public void emptyParagraphsArePreservedIfIgnoreEmptyParagraphsIsFalse() throws IOException { assertThat( convertToHtml("empty.docx", mammoth -> mammoth.preserveEmptyParagraphs()), - deepEquals(success("

"))); + isSuccess("

")); } @Test public void simpleListIsConvertedToListElements() throws IOException { assertThat( convertToHtml("simple-list.docx"), - deepEquals(success(""))); + isSuccess("")); } @Test public void wordTablesAreConvertedToHtmlTables() throws IOException { assertThat( convertToHtml("tables.docx"), - deepEquals(success( + isSuccess( "

Above

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

Top left

Top right

Bottom left

Bottom right

" + - "

Below

"))); + "

Below

")); } @Test public void inlineImagesAreIncludedInOutput() throws IOException { assertThat( convertToHtml("tiny-picture.docx"), - deepEquals(success("

"))); + isSuccess("

")); } @Test @@ -82,7 +81,7 @@ public class MammothTests { Files.copy(TestData.file("tiny-picture.png").toPath(), tempDirectory.resolve("tiny-picture.png")); assertThat( new DocumentConverter().convertToHtml(documentPath.toFile()), - deepEquals(success("

"))); + isSuccess("

")); } finally { tempDirectory.toFile().delete(); } @@ -126,68 +125,68 @@ public class MammothTests { public void contentTypesAreRead() throws IOException { assertThat( convertToHtml("tiny-picture-custom-content-type.docx"), - deepEquals(success("

"))); + isSuccess("

")); } @Test public void footnotesAreAppendedToText() throws IOException { assertThat( convertToHtml("footnotes.docx", mammoth -> mammoth.idPrefix("doc-42-")), - deepEquals(success( + isSuccess( "

Ouch" + "[1]." + "[2]

" + "
  1. A tachyon walks into a bar. ↑

  2. " + - "
  3. Fin. ↑

"))); + "
  • Fin. ↑

  • ")); } @Test public void endNotesAreAppendedToText() throws IOException { assertThat( convertToHtml("endnotes.docx", mammoth -> mammoth.idPrefix("doc-42-")), - deepEquals(success( + isSuccess( "

    Ouch" + "[1]." + "[2]

    " + "
    1. A tachyon walks into a bar. ↑

    2. " + - "
    3. Fin. ↑

    "))); + "
  • Fin. ↑

  • ")); } @Test public void relationshipsAreReadForEachFileContainingBodyXml() throws IOException { assertThat( convertToHtml("footnote-hyperlink.docx", mammoth -> mammoth.idPrefix("doc-42-")), - deepEquals(success( + isSuccess( "

    [1]

    " + - "
    1. Example ↑

    "))); + "
    1. Example ↑

    ")); } @Test public void textBoxesAreRead() throws IOException { assertThat( convertToHtml("text-box.docx"), - deepEquals(success("

    Datum plane

    "))); + isSuccess("

    Datum plane

    ")); } @Test public void canUseCustomStyleMap() throws IOException { assertThat( convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em")), - deepEquals(success("

    The Sunset Tree

    "))); + isSuccess("

    The Sunset Tree

    ")); } @Test public void mostRecentlyAddedStyleMapTakesPrecedence() throws IOException { assertThat( convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em").addStyleMap("u => strong")), - deepEquals(success("

    The Sunset Tree

    "))); + isSuccess("

    The Sunset Tree

    ")); } @Test public void rulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverriden() throws IOException { assertThat( convertToHtml("underline.docx", mammoth -> mammoth.addStyleMap("u => em").addStyleMap("strike => del")), - deepEquals(success("

    The Sunset Tree

    "))); + isSuccess("

    The Sunset Tree

    ")); } @Test @@ -203,14 +202,14 @@ public class MammothTests { public void canExtractRawTextFromFile() throws IOException { assertThat( new DocumentConverter().extractRawText(TestData.file("simple-list.docx")), - deepEquals(success("Apple\n\nBanana\n\n"))); + isSuccess("Apple\n\nBanana\n\n")); } @Test public void canExtractRawTextFromStream() throws IOException { assertThat( new DocumentConverter().extractRawText(TestData.file("simple-list.docx").toURI().toURL().openStream()), - deepEquals(success("Apple\n\nBanana\n\n"))); + isSuccess("Apple\n\nBanana\n\n")); } private Result convertToHtml(String name) throws IOException { -- cgit v1.2.3