aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/zwobble')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java5
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java14
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()));