From f63e7014a68c90160da89a25db613381edbc6e5e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 13 Feb 2016 19:48:59 +0000 Subject: Read hyperlinks with href --- .../java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java') 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 b1ce149..40b58a3 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -5,9 +5,7 @@ import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Test; import org.zwobble.mammoth.documents.*; -import org.zwobble.mammoth.docx.BodyXmlReader; -import org.zwobble.mammoth.docx.Numbering; -import org.zwobble.mammoth.docx.Styles; +import org.zwobble.mammoth.docx.*; import org.zwobble.mammoth.results.Result; import org.zwobble.mammoth.results.Warning; import org.zwobble.mammoth.tests.DeepReflectionMatcher; @@ -296,6 +294,16 @@ public class BodyXmlTests { deepEquals(make(a(PARAGRAPH)))); } + @Test + public void hyperlinkIsReadIfItHasARelationshipId() { + Relationships relationships = new Relationships( + map("r42", new Relationship("http://example.com"))); + XmlElement element = element("w:hyperlink", map("r:id", "r42"), list(runXml(list()))); + assertThat( + readSuccess(a(bodyReader, with(RELATIONSHIPS, relationships)), element), + deepEquals(Hyperlink.href("http://example.com", list(make(a(RUN)))))); + } + private static DocumentElement readSuccess(Maker reader, XmlElement element) { Result result = read(reader, element); assertThat(result.getWarnings(), deepEquals(list())); -- cgit v1.2.3