diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-13 19:48:59 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-13 19:48:59 +0000 |
| commit | f63e7014a68c90160da89a25db613381edbc6e5e (patch) | |
| tree | d4e18df804a6dc5e42a9c65d7d2d0940abef4d0e /src/test/java/org/zwobble/mammoth | |
| parent | 7864626f385e23272bf307474ceaebe281b4ed28 (diff) | |
Read hyperlinks with href
Diffstat (limited to 'src/test/java/org/zwobble/mammoth')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java | 5 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 14 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java index 9df21e9..5758dce 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java @@ -4,6 +4,7 @@ import com.natpryce.makeiteasy.Instantiator; import com.natpryce.makeiteasy.Property; import org.zwobble.mammoth.docx.BodyXmlReader; import org.zwobble.mammoth.docx.Numbering; +import org.zwobble.mammoth.docx.Relationships; import org.zwobble.mammoth.docx.Styles; import static com.natpryce.makeiteasy.Property.newProperty; @@ -11,9 +12,11 @@ import static com.natpryce.makeiteasy.Property.newProperty; public class BodyXmlReaderMakers { public static final Property<BodyXmlReader, Styles> STYLES = newProperty(); public static final Property<BodyXmlReader, Numbering> NUMBERING = newProperty(); + public static final Property<BodyXmlReader, Relationships> RELATIONSHIPS = newProperty(); public static final Instantiator<BodyXmlReader> bodyReader = propertyLookup -> new BodyXmlReader( propertyLookup.valueOf(STYLES, Styles.EMPTY), - propertyLookup.valueOf(NUMBERING, Numbering.EMPTY)); + propertyLookup.valueOf(NUMBERING, Numbering.EMPTY), + propertyLookup.valueOf(RELATIONSHIPS, Relationships.EMPTY)); } 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<BodyXmlReader> reader, XmlElement element) { Result<DocumentElement> result = read(reader, element); assertThat(result.getWarnings(), deepEquals(list())); |
