blob: 47e53fc88f703dd89a46d91a47fb3a121f5855fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package org.zwobble.mammoth.tests.docx;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.documents.Document;
import org.zwobble.mammoth.documents.Run;
import org.zwobble.mammoth.documents.Text;
import org.zwobble.mammoth.docx.BodyXmlReader;
import org.zwobble.mammoth.docx.DocumentXmlReader;
import org.zwobble.mammoth.xml.XmlElement;
import org.zwobble.mammoth.xml.XmlNodes;
import static com.natpryce.makeiteasy.MakeItEasy.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.CHILDREN;
import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class DocumentXmlTests {
private static final BodyXmlReader bodyReader = make(a(BodyXmlReaderMakers.bodyReader));
@Test
public void canReadTextWithinDocument() {
XmlElement documentElement = element("w:document", ImmutableList.of(
element("w:body", ImmutableList.of(
element("w:p", ImmutableList.of(
element("w:r", ImmutableList.of(
element("w:t", ImmutableList.of(
XmlNodes.text("Hello!")))))))))));
Document document = new DocumentXmlReader(bodyReader).readElement(documentElement);
assertThat(
document,
deepEquals(new Document(ImmutableList.of(
make(a(PARAGRAPH, with(CHILDREN, ImmutableList.of(
new Run(ImmutableList.of(
new Text("Hello!")))))))))));
}
}
|