From 98a94a032f08e9f1d0ad6a07ea45ef539dd8eac9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 2 Jan 2016 22:32:32 +0000 Subject: Use Style class in Paragraph --- .../org/zwobble/mammoth/tests/DeepReflectionMatcher.java | 4 ++++ .../java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 15 ++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/test/java/org/zwobble') diff --git a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java index 54b74ee..2668811 100644 --- a/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java +++ b/src/test/java/org/zwobble/mammoth/tests/DeepReflectionMatcher.java @@ -18,6 +18,10 @@ import static com.google.common.collect.Iterables.transform; import static java.util.Arrays.asList; public class DeepReflectionMatcher extends TypeSafeDiagnosingMatcher { + public static Matcher deepEquals(T value) { + return new DeepReflectionMatcher<>(value); + } + private final T expected; public DeepReflectionMatcher(T expected) { 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 b0152a5..8c37ea9 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -4,10 +4,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.hamcrest.Matcher; import org.junit.Test; -import org.zwobble.mammoth.documents.DocumentElement; -import org.zwobble.mammoth.documents.ParagraphElement; -import org.zwobble.mammoth.documents.RunElement; -import org.zwobble.mammoth.documents.TextElement; +import org.zwobble.mammoth.documents.*; import org.zwobble.mammoth.tests.DeepReflectionMatcher; import org.zwobble.mammoth.xml.XmlElement; import org.zwobble.mammoth.xml.XmlNode; @@ -18,9 +15,9 @@ import java.util.Optional; import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasProperty; import static org.zwobble.mammoth.docx.BodyXml.readBodyXmlElement; +import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals; import static org.zwobble.mammoth.xml.XmlNodes.element; public class BodyXmlTests { @@ -51,7 +48,7 @@ public class BodyXmlTests { XmlElement element = paragraphXml(); assertThat( readBodyXmlElement(element), - hasStyleId(Optional.empty())); + hasStyle(Optional.empty())); } @Test @@ -61,7 +58,7 @@ public class BodyXmlTests { element("w:pStyle", ImmutableMap.of("w:val", "Heading1")))))); assertThat( readBodyXmlElement(element), - hasStyleId(Optional.of("Heading1"))); + hasStyle(Optional.of(new Style("Heading1", Optional.empty())))); } private XmlElement paragraphXml() { @@ -92,8 +89,8 @@ public class BodyXmlTests { return new DeepReflectionMatcher<>(new TextElement(value)); } - private Matcher hasStyleId(Optional expected) { - return hasProperty("styleId", equalTo(expected)); + private Matcher hasStyle(Optional