diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-01-02 15:17:50 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-01-02 15:18:22 +0000 |
| commit | d5005305b90afe47e639fc0fa1430242556f0385 (patch) | |
| tree | 387c8e888b925917da79e1ad829e14665c7b8cc6 /src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | |
| parent | 70edd90a3077fc63a5890c4d7d55561ba0274902 (diff) | |
Add possibly ill-advised DeepReflectionMatcher
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java | 39 |
1 files changed, 23 insertions, 16 deletions
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 8ab2dd8..e2ee5a9 100644 --- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java +++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java @@ -7,16 +7,17 @@ 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.tests.DeepReflectionMatcher; import org.zwobble.mammoth.xml.XmlElement; import org.zwobble.mammoth.xml.XmlNode; +import org.zwobble.mammoth.xml.XmlNodes; import java.util.List; +import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; import static org.zwobble.mammoth.docx.BodyXml.readBodyXmlElement; import static org.zwobble.mammoth.xml.XmlNodes.element; -import static org.zwobble.mammoth.xml.XmlNodes.text; public class BodyXmlTests { @Test @@ -30,7 +31,7 @@ public class BodyXmlTests { XmlElement element = runXml(ImmutableList.of(textXml("Hello!"))); assertThat( readBodyXmlElement(element), - isRunElement(isTextElement("Hello!"))); + isRun(run(text("Hello!")))); } @Test @@ -38,7 +39,7 @@ public class BodyXmlTests { XmlElement element = paragraphXml(ImmutableList.of(runXml(ImmutableList.of(textXml("Hello!"))))); assertThat( readBodyXmlElement(element), - isParagraphElement(isRunElement(isTextElement("Hello!")))); + isParagraph(paragraph(run(text("Hello!"))))); } private XmlElement paragraphXml(List<XmlNode> children) { @@ -50,24 +51,30 @@ public class BodyXmlTests { } private XmlElement textXml(String value) { - return element("w:t", ImmutableList.of(text(value))); + return element("w:t", ImmutableList.of(XmlNodes.text(value))); } - private Matcher<DocumentElement> isParagraphElement(Matcher<DocumentElement> child) { - return allOf( - instanceOf(ParagraphElement.class), - hasProperty("children", contains(child))); + private Matcher<DocumentElement> isParagraph(ParagraphElement expected) { + return new DeepReflectionMatcher<>(expected); } - private Matcher<DocumentElement> isRunElement(Matcher<DocumentElement> child) { - return allOf( - instanceOf(RunElement.class), - hasProperty("children", contains(child))); + private Matcher<DocumentElement> isRun(RunElement expected) { + return new DeepReflectionMatcher<>(expected); } private Matcher<DocumentElement> isTextElement(String value) { - return allOf( - instanceOf(TextElement.class), - hasProperty("value", equalTo(value))); + return new DeepReflectionMatcher<>(new TextElement(value)); + } + + private ParagraphElement paragraph(DocumentElement... children) { + return new ParagraphElement(asList(children)); + } + + private RunElement run(DocumentElement... children) { + return new RunElement(asList(children)); + } + + private TextElement text(String value) { + return new TextElement(value); } } |
