From a07cddd98e2fdad40d2226818b04be1787abc6cf Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 14 Feb 2016 14:27:47 +0000 Subject: Add notes to document --- .../mammoth/tests/docx/DocumentXmlTests.java | 36 ++++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java') 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 5370db3..3eaa4ee 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java @@ -2,23 +2,25 @@ package org.zwobble.mammoth.tests.docx; import org.junit.Test; import org.zwobble.mammoth.documents.Document; -import org.zwobble.mammoth.documents.Text; -import org.zwobble.mammoth.docx.BodyXmlReader; +import org.zwobble.mammoth.documents.Note; +import org.zwobble.mammoth.documents.NoteType; +import org.zwobble.mammoth.documents.Notes; import org.zwobble.mammoth.docx.DocumentXmlReader; import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.xml.XmlElement; import org.zwobble.mammoth.xml.XmlNodes; -import static com.natpryce.makeiteasy.MakeItEasy.*; +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.tests.DeepReflectionMatcher.deepEquals; -import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.*; +import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.paragraphWithText; +import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.bodyReader; import static org.zwobble.mammoth.util.MammothLists.list; import static org.zwobble.mammoth.xml.XmlNodes.element; public class DocumentXmlTests { - private static final BodyXmlReader bodyReader = make(a(BodyXmlReaderMakers.bodyReader)); @Test public void canReadTextWithinDocument() { @@ -29,13 +31,27 @@ public class DocumentXmlTests { element("w:t", list( XmlNodes.text("Hello!"))))))))))); - Result document = new DocumentXmlReader(bodyReader).readElement(documentElement); + DocumentXmlReader reader = new DocumentXmlReader(make(a(bodyReader)), Notes.EMPTY); + Result document = reader.readElement(documentElement); assertThat( document, - deepEquals(success(new Document(list( - make(a(PARAGRAPH, with(CHILDREN, list( - make(a(RUN, with(CHILDREN, list( - new Text("Hello!")))))))))))))); + deepEquals(success(new Document( + list(paragraphWithText("Hello!")), + Notes.EMPTY)))); + } + + @Test + public void notesOfDocumentAreIncludedInDocument() { + Note note = new Note(NoteType.FOOTNOTE, "4", list(paragraphWithText("Hello"))); + Notes notes = new Notes(list(note)); + DocumentXmlReader reader = new DocumentXmlReader(make(a(bodyReader)), notes); + + XmlElement documentElement = element("w:document", list(element("w:body"))); + Result document = reader.readElement(documentElement); + + assertThat( + document.getValue().getNotes().findNote(NoteType.FOOTNOTE, "4").get(), + deepEquals(note)); } } -- cgit v1.2.3