diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-24 21:03:42 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-24 21:03:42 +0000 |
| commit | 86207d30715fe000b95b2f8e8b55b59a21aba34b (patch) | |
| tree | cb61c8c131c6201a23995706d1124d79812e1d5f /src/test | |
| parent | d4ac19bac1d0e1315d129c39de56121def95007b (diff) | |
Turn Result into a minimal interface
Diffstat (limited to 'src/test')
5 files changed, 28 insertions, 28 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java index 6a4c036..526c078 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java @@ -6,7 +6,7 @@ import org.zwobble.mammoth.internal.DocumentToHtmlOptions; import org.zwobble.mammoth.internal.documents.*; import org.zwobble.mammoth.internal.html.Html; import org.zwobble.mammoth.internal.html.HtmlNode; -import org.zwobble.mammoth.results.Result; +import org.zwobble.mammoth.internal.results.InternalResult; import org.zwobble.mammoth.internal.styles.HtmlPath; import org.zwobble.mammoth.internal.styles.ParagraphMatcher; import org.zwobble.mammoth.internal.styles.RunMatcher; @@ -21,8 +21,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.zwobble.mammoth.internal.documents.VerticalAlignment.SUBSCRIPT; import static org.zwobble.mammoth.internal.documents.VerticalAlignment.SUPERSCRIPT; -import static org.zwobble.mammoth.results.Result.success; -import static org.zwobble.mammoth.results.Warning.warning; +import static org.zwobble.mammoth.internal.results.InternalResult.success; +import static org.zwobble.mammoth.internal.results.Warning.warning; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.*; import static org.zwobble.mammoth.internal.util.MammothLists.list; @@ -78,7 +78,7 @@ public class DocumentConverterTests { convertToHtmlResult( make(a(PARAGRAPH, with(STYLE, Optional.of(new Style("TipsParagraph", Optional.of("Tips Paragraph"))))))), - deepEquals(new Result<>( + deepEquals(new InternalResult<>( list(Html.element("p")), list(warning("Unrecognised paragraph style: Tips Paragraph (Style ID: TipsParagraph)"))))); } @@ -105,7 +105,7 @@ public class DocumentConverterTests { with(STYLE, Optional.of(new Style("TipsRun", Optional.of("Tips Run")))), with(CHILDREN, list(new Text("Hello")))))), - deepEquals(new Result<>( + deepEquals(new InternalResult<>( list(Html.text("Hello")), list(warning("Unrecognised run style: Tips Run (Style ID: TipsRun)"))))); } @@ -290,7 +290,7 @@ public class DocumentConverterTests { private List<HtmlNode> convertToHtml(Document document) { DocumentToHtmlOptions options = DocumentToHtmlOptions.DEFAULT .idPrefix("doc-42-"); - Result<List<HtmlNode>> result = DocumentToHtml.convertToHtml(document, options); + InternalResult<List<HtmlNode>> result = DocumentToHtml.convertToHtml(document, options); assertThat(result.getWarnings(), hasSize(0)); return result.getValue(); } @@ -300,16 +300,16 @@ public class DocumentConverterTests { } private List<HtmlNode> convertToHtml(DocumentElement element, StyleMap styleMap) { - Result<List<HtmlNode>> result = convertToHtmlResult(element, styleMap); + InternalResult<List<HtmlNode>> result = convertToHtmlResult(element, styleMap); assertThat(result.getWarnings(), hasSize(0)); return result.getValue(); } - private Result<List<HtmlNode>> convertToHtmlResult(DocumentElement element) { + private InternalResult<List<HtmlNode>> convertToHtmlResult(DocumentElement element) { return convertToHtmlResult(element, StyleMap.EMPTY); } - private Result<List<HtmlNode>> convertToHtmlResult(DocumentElement element, StyleMap styleMap) { + private InternalResult<List<HtmlNode>> convertToHtmlResult(DocumentElement element, StyleMap styleMap) { DocumentToHtmlOptions options = DocumentToHtmlOptions.DEFAULT .idPrefix("doc-42-") .addStyleMap(styleMap); diff --git a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java index efb95f0..8f44fc9 100644 --- a/src/test/java/org/zwobble/mammoth/tests/MammothTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/MammothTests.java @@ -2,7 +2,7 @@ package org.zwobble.mammoth.tests; import org.junit.Test; import org.zwobble.mammoth.DocumentConverter; -import org.zwobble.mammoth.results.Result; +import org.zwobble.mammoth.Result; import java.io.File; import java.io.IOException; @@ -12,7 +12,7 @@ import java.util.function.Function; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; -import static org.zwobble.mammoth.results.Result.success; +import static org.zwobble.mammoth.internal.results.InternalResult.success; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; public class MammothTests { diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java index a35f248..4c9d621 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -7,8 +7,8 @@ import org.hamcrest.Matchers; import org.junit.Test; import org.zwobble.mammoth.internal.documents.*; import org.zwobble.mammoth.internal.docx.*; -import org.zwobble.mammoth.results.Result; -import org.zwobble.mammoth.results.Warning; +import org.zwobble.mammoth.internal.results.InternalResult; +import org.zwobble.mammoth.internal.results.Warning; import org.zwobble.mammoth.tests.DeepReflectionMatcher; import org.zwobble.mammoth.internal.xml.XmlElement; import org.zwobble.mammoth.internal.xml.XmlNode; @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.zwobble.mammoth.internal.documents.NoteReference.endnoteReference; import static org.zwobble.mammoth.internal.documents.NoteReference.footnoteReference; -import static org.zwobble.mammoth.results.Warning.warning; +import static org.zwobble.mammoth.internal.results.Warning.warning; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.*; import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.*; @@ -468,7 +468,7 @@ public class BodyXmlTests { DocxFile file = InMemoryDocxFile.fromStrings(map("word/media/hat.emf", "Not an image at all!")); ContentTypes contentTypes = new ContentTypes(map("emf", "image/x-emf"), map()); - Result<?> result = read( + InternalResult<?> result = read( a(bodyReader, with(RELATIONSHIPS, relationships), with(DOCX_FILE, file), @@ -595,18 +595,18 @@ public class BodyXmlTests { } private static DocumentElement readSuccess(Maker<BodyXmlReader> reader, XmlElement element) { - Result<DocumentElement> result = read(reader, element); + InternalResult<DocumentElement> result = read(reader, element); assertThat(result.getWarnings(), deepEquals(list())); return result.getValue(); } - private static Result<DocumentElement> read(Maker<BodyXmlReader> reader, XmlElement element) { - Result<List<DocumentElement>> result = readAll(reader, element); + private static InternalResult<DocumentElement> read(Maker<BodyXmlReader> reader, XmlElement element) { + InternalResult<List<DocumentElement>> result = readAll(reader, element); assertThat(result.getValue(), Matchers.hasSize(1)); return result.map(elements -> elements.get(0)); } - private static Result<List<DocumentElement>> readAll(Maker<BodyXmlReader> reader, XmlElement element) { + private static InternalResult<List<DocumentElement>> readAll(Maker<BodyXmlReader> reader, XmlElement element) { return reader.make().readElement(element).toResult(); } @@ -654,7 +654,7 @@ public class BodyXmlTests { return hasProperty("numbering", deepEquals(expected)); } - private <T> Matcher<Result<? extends T>> isResult(Matcher<T> valueMatcher, List<Warning> warnings) { + private <T> Matcher<InternalResult<? extends T>> isResult(Matcher<T> valueMatcher, List<Warning> warnings) { return Matchers.allOf( hasProperty("value", valueMatcher), hasProperty("warnings", deepEquals(warnings))); diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java index f2c7dda..dc3e2b7 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java @@ -6,14 +6,14 @@ import org.zwobble.mammoth.internal.documents.Note; import org.zwobble.mammoth.internal.documents.NoteType; import org.zwobble.mammoth.internal.documents.Notes; import org.zwobble.mammoth.internal.docx.DocumentXmlReader; -import org.zwobble.mammoth.results.Result; +import org.zwobble.mammoth.internal.results.InternalResult; import org.zwobble.mammoth.internal.xml.XmlElement; import org.zwobble.mammoth.internal.xml.XmlNodes; import static com.natpryce.makeiteasy.MakeItEasy.a; import static com.natpryce.makeiteasy.MakeItEasy.make; import static org.hamcrest.MatcherAssert.assertThat; -import static org.zwobble.mammoth.results.Result.success; +import static org.zwobble.mammoth.internal.results.InternalResult.success; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.paragraphWithText; import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.bodyReader; @@ -32,7 +32,7 @@ public class DocumentXmlTests { XmlNodes.text("Hello!"))))))))))); DocumentXmlReader reader = new DocumentXmlReader(make(a(bodyReader)), Notes.EMPTY); - Result<Document> document = reader.readElement(documentElement); + InternalResult<Document> document = reader.readElement(documentElement); assertThat( document, @@ -48,7 +48,7 @@ public class DocumentXmlTests { DocumentXmlReader reader = new DocumentXmlReader(make(a(bodyReader)), notes); XmlElement documentElement = element("w:document", list(element("w:body"))); - Result<Document> document = reader.readElement(documentElement); + InternalResult<Document> document = reader.readElement(documentElement); assertThat( document.getValue().getNotes().findNote(NoteType.FOOTNOTE, "4").get(), diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java index 05bb4a7..67ec515 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java @@ -2,7 +2,7 @@ package org.zwobble.mammoth.tests.docx; import org.junit.Test; import org.zwobble.mammoth.internal.documents.NoteType; -import org.zwobble.mammoth.results.Result; +import org.zwobble.mammoth.internal.results.InternalResult; import org.zwobble.mammoth.internal.documents.Note; import org.zwobble.mammoth.internal.docx.BodyXmlReader; import org.zwobble.mammoth.internal.docx.NotesXmlReader; @@ -13,7 +13,7 @@ import java.util.List; import static com.natpryce.makeiteasy.MakeItEasy.a; import static com.natpryce.makeiteasy.MakeItEasy.make; import static org.hamcrest.MatcherAssert.assertThat; -import static org.zwobble.mammoth.results.Result.success; +import static org.zwobble.mammoth.internal.results.InternalResult.success; import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH; import static org.zwobble.mammoth.internal.util.MammothLists.list; @@ -30,7 +30,7 @@ public class NotesXmlReaderTests { element("w:p"))))); NotesXmlReader reader = NotesXmlReader.footnote(bodyReader); - Result<List<Note>> notes = reader.readElement(element); + InternalResult<List<Note>> notes = reader.readElement(element); assertThat( notes, @@ -53,7 +53,7 @@ public class NotesXmlReaderTests { element("w:p"))))); NotesXmlReader reader = NotesXmlReader.footnote(bodyReader); - Result<List<Note>> notes = reader.readElement(element); + InternalResult<List<Note>> notes = reader.readElement(element); assertThat(notes, deepEquals(success(list()))); } |
