aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-01-03 14:42:50 +0000
committerMichael Williamson <mike@zwobble.org>2016-01-03 14:42:50 +0000
commit4f8c4b581f16551a364e203fd8142f7717101a2f (patch)
tree077bb2fd98d675a039478980b90ffe77616de42f /src/test/java/org
parent6e97bf5bb28ad5a63f396873399a457be6fe779d (diff)
Add list as shorter alias of ImmutableList.of
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java4
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java20
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/ContentTypesXmlTests.java6
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java18
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java14
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/NumberingXmlTests.java12
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java4
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/RelationshipsXmlTests.java4
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/docx/StylesXmlTests.java18
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java10
10 files changed, 55 insertions, 55 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java b/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
index 0d83882..deb2500 100644
--- a/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
+++ b/src/test/java/org/zwobble/mammoth/tests/documents/DocumentElementMakers.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.documents;
-import com.google.common.collect.ImmutableList;
import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Property;
import org.zwobble.mammoth.documents.DocumentElement;
@@ -11,6 +10,7 @@ import java.util.List;
import java.util.Optional;
import static com.natpryce.makeiteasy.Property.newProperty;
+import static org.zwobble.mammoth.util.MammothLists.list;
public class DocumentElementMakers {
public static final Property<HasChildren, List<DocumentElement>> CHILDREN = newProperty();
@@ -18,5 +18,5 @@ public class DocumentElementMakers {
public static final Instantiator<Paragraph> PARAGRAPH =
propertyLookup -> new Paragraph(
Optional.empty(),
- propertyLookup.valueOf(CHILDREN, ImmutableList.of()));
+ propertyLookup.valueOf(CHILDREN, list()));
}
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 42fd5c7..77ecd86 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlTests.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import com.natpryce.makeiteasy.Maker;
import org.hamcrest.Matcher;
import org.junit.Test;
@@ -24,6 +23,7 @@ import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.CHILDREN
import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH;
import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.STYLES;
import static org.zwobble.mammoth.tests.docx.BodyXmlReaderMakers.bodyReader;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
@@ -37,7 +37,7 @@ public class BodyXmlTests {
@Test
public void canReadTextWithinRun() {
- XmlElement element = runXml(ImmutableList.of(textXml("Hello!")));
+ XmlElement element = runXml(list(textXml("Hello!")));
assertThat(
read(a(bodyReader), element),
isRun(run(text("Hello!"))));
@@ -45,10 +45,10 @@ public class BodyXmlTests {
@Test
public void canReadTextWithinParagraph() {
- XmlElement element = paragraphXml(ImmutableList.of(runXml(ImmutableList.of(textXml("Hello!")))));
+ XmlElement element = paragraphXml(list(runXml(list(textXml("Hello!")))));
assertThat(
read(a(bodyReader), element),
- isParagraph(make(a(PARAGRAPH, with(CHILDREN, asList(run(text("Hello!"))))))));
+ isParagraph(make(a(PARAGRAPH, with(CHILDREN, list(run(text("Hello!"))))))));
}
@Test
@@ -61,8 +61,8 @@ public class BodyXmlTests {
@Test
public void paragraphHasStyleIdReadFromParagraphPropertiesIfPresent() {
- XmlElement element = paragraphXml(ImmutableList.of(
- element("w:pPr", ImmutableList.of(
+ XmlElement element = paragraphXml(list(
+ element("w:pPr", list(
element("w:pStyle", map("w:val", "Heading1"))))));
assertThat(
read(a(bodyReader), element),
@@ -71,8 +71,8 @@ public class BodyXmlTests {
@Test
public void whenParagraphHasStyleIdInStylesThenStyleNameIsReadFromStyles() {
- XmlElement element = paragraphXml(ImmutableList.of(
- element("w:pPr", ImmutableList.of(
+ XmlElement element = paragraphXml(list(
+ element("w:pPr", list(
element("w:pStyle", map("w:val", "Heading1"))))));
Style style = new Style("Heading1", Optional.of("Heading 1"));
@@ -89,7 +89,7 @@ public class BodyXmlTests {
}
private XmlElement paragraphXml() {
- return paragraphXml(ImmutableList.of());
+ return paragraphXml(list());
}
private XmlElement paragraphXml(List<XmlNode> children) {
@@ -101,7 +101,7 @@ public class BodyXmlTests {
}
private XmlElement textXml(String value) {
- return element("w:t", ImmutableList.of(XmlNodes.text(value)));
+ return element("w:t", list(XmlNodes.text(value)));
}
private Matcher<DocumentElement> isParagraph(Paragraph expected) {
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/ContentTypesXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/ContentTypesXmlTests.java
index 287a709..293e3d1 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/ContentTypesXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/ContentTypesXmlTests.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.docx.ContentTypes;
import org.zwobble.mammoth.xml.XmlElement;
@@ -9,13 +8,14 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.zwobble.mammoth.docx.ContentTypesXml.readContentTypesXmlElement;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class ContentTypesXmlTests {
@Test
public void contentTypeIsBasedOnDefaultForExtensionIfThereIsNoOverride() {
- XmlElement element = element("content-types:Types", ImmutableList.of(
+ XmlElement element = element("content-types:Types", list(
element("content-types:Default", map(
"Extension", "png",
"ContentType", "image/png"))));
@@ -27,7 +27,7 @@ public class ContentTypesXmlTests {
@Test
public void contentTypeIsBasedOnOverrideIfPresent() {
- XmlElement element = element("content-types:Types", ImmutableList.of(
+ XmlElement element = element("content-types:Types", list(
element("content-types:Default", map(
"Extension", "png",
"ContentType", "image/png")),
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java
index 47e53fc..0f547a8 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/DocumentXmlTests.java
@@ -1,6 +1,5 @@
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;
@@ -15,6 +14,7 @@ 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.util.MammothLists.list;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class DocumentXmlTests {
@@ -22,20 +22,20 @@ public class DocumentXmlTests {
@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(
+ XmlElement documentElement = element("w:document", list(
+ element("w:body", list(
+ element("w:p", list(
+ element("w:r", list(
+ element("w:t", list(
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(
+ deepEquals(new Document(list(
+ make(a(PARAGRAPH, with(CHILDREN, list(
+ new Run(list(
new Text("Hello!")))))))))));
}
}
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java
index 58edf54..b8ada2e 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/NotesXmlReaderTests.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.documents.Note;
import org.zwobble.mammoth.docx.BodyXmlReader;
@@ -14,6 +13,7 @@ import static com.natpryce.makeiteasy.MakeItEasy.make;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
import static org.zwobble.mammoth.tests.documents.DocumentElementMakers.PARAGRAPH;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
@@ -22,8 +22,8 @@ public class NotesXmlReaderTests {
@Test
public void idAndBodyOfFootnoteAreRead() {
- XmlElement element = element("w:footnotes", ImmutableList.of(
- element("w:footnote", map("w:id", "1"), ImmutableList.of(
+ XmlElement element = element("w:footnotes", list(
+ element("w:footnote", map("w:id", "1"), list(
element("w:p")))));
NotesXmlReader reader = new NotesXmlReader(bodyReader, "footnote");
@@ -31,7 +31,7 @@ public class NotesXmlReaderTests {
assertThat(
notes,
- deepEquals(ImmutableList.of(new Note("1", ImmutableList.of(make(a(PARAGRAPH)))))));
+ deepEquals(list(new Note("1", list(make(a(PARAGRAPH)))))));
}
@Test
@@ -45,13 +45,13 @@ public class NotesXmlReaderTests {
}
private void assertFootnoteTypeIsIgnored(String noteType) {
- XmlElement element = element("w:footnotes", ImmutableList.of(
- element("w:footnote", map("w:id", "1", "w:type", noteType), ImmutableList.of(
+ XmlElement element = element("w:footnotes", list(
+ element("w:footnote", map("w:id", "1", "w:type", noteType), list(
element("w:p")))));
NotesXmlReader reader = new NotesXmlReader(bodyReader, "footnote");
List<Note> notes = reader.readElement(element);
- assertThat(notes, deepEquals(ImmutableList.of()));
+ assertThat(notes, deepEquals(list()));
}
}
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/NumberingXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/NumberingXmlTests.java
index dc4d5f6..029a8ce 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/NumberingXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/NumberingXmlTests.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.docx.Numbering;
import org.zwobble.mammoth.xml.XmlElement;
@@ -9,17 +8,18 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.zwobble.mammoth.docx.NumberingXml.readNumberingXmlElement;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class NumberingXmlTests {
- private final static XmlElement SAMPLE_NUMBERING_XML = element("w:numbering", ImmutableList.of(
- element("w:abstractNum", map("w:abstractNumId", "42"), ImmutableList.of(
- element("w:lvl", map("w:ilvl", "0"), ImmutableList.of(
+ private final static XmlElement SAMPLE_NUMBERING_XML = element("w:numbering", list(
+ element("w:abstractNum", map("w:abstractNumId", "42"), list(
+ element("w:lvl", map("w:ilvl", "0"), list(
element("w:numFmt", map("w:val", "bullet")))),
- element("w:lvl", map("w:ilvl", "1"), ImmutableList.of(
+ element("w:lvl", map("w:ilvl", "1"), list(
element("w:numFmt", map("w:val", "decimal")))))),
- element("w:num", map("w:numId", "47"), ImmutableList.of(
+ element("w:num", map("w:numId", "47"), list(
element("w:abstractNumId", map("w:val", "42"))))));
@Test
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java
index 6b2fb77..ff58f75 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/OfficeXmlTests.java
@@ -1,7 +1,6 @@
package org.zwobble.mammoth.tests.docx;
import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.docx.OfficeXml;
import org.zwobble.mammoth.xml.XmlElement;
@@ -10,6 +9,7 @@ import java.io.ByteArrayInputStream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class OfficeXmlTests {
@@ -29,6 +29,6 @@ public class OfficeXmlTests {
"</numbering>";
XmlElement result = OfficeXml.parseXml(new ByteArrayInputStream(xmlString.getBytes(Charsets.UTF_8)));
- assertThat(result.children(), deepEquals(ImmutableList.of(element("fallback"))));
+ assertThat(result.children(), deepEquals(list(element("fallback"))));
}
}
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/RelationshipsXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/RelationshipsXmlTests.java
index 19e74f3..58f2bb8 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/RelationshipsXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/RelationshipsXmlTests.java
@@ -1,19 +1,19 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.docx.Relationships;
import org.zwobble.mammoth.xml.XmlElement;
import static org.junit.Assert.assertEquals;
import static org.zwobble.mammoth.docx.RelationshipsXml.readRelationshipsXmlElement;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
public class RelationshipsXmlTests {
@Test
public void targetIsReadFromRelationshipElement() {
- XmlElement element = element("relationship:Relationships", ImmutableList.of(
+ XmlElement element = element("relationship:Relationships", list(
element("relationships:Relationship", map(
"Id", "rId8",
"Type", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
diff --git a/src/test/java/org/zwobble/mammoth/tests/docx/StylesXmlTests.java b/src/test/java/org/zwobble/mammoth/tests/docx/StylesXmlTests.java
index 398c7ca..6b5de50 100644
--- a/src/test/java/org/zwobble/mammoth/tests/docx/StylesXmlTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/docx/StylesXmlTests.java
@@ -1,6 +1,5 @@
package org.zwobble.mammoth.tests.docx;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.zwobble.mammoth.docx.Styles;
import org.zwobble.mammoth.xml.XmlElement;
@@ -9,6 +8,7 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.zwobble.mammoth.docx.StylesXml.readStylesXmlElement;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
import static org.zwobble.mammoth.xml.XmlNodes.element;
@@ -24,8 +24,8 @@ public class StylesXmlTests {
@Test
public void paragraphStyleCanBeFoundById() {
- XmlElement element = element("w:styles", ImmutableList.of(
- element("w:style", map("w:type", "paragraph", "w:styleId", "Heading1"), ImmutableList.of(
+ XmlElement element = element("w:styles", list(
+ element("w:style", map("w:type", "paragraph", "w:styleId", "Heading1"), list(
nameElement("Heading 1")))));
Styles styles = readStylesXmlElement(element);
@@ -35,8 +35,8 @@ public class StylesXmlTests {
@Test
public void characterStyleCanBeFoundById() {
- XmlElement element = element("w:styles", ImmutableList.of(
- element("w:style", map("w:type", "character", "w:styleId", "Heading1Char"), ImmutableList.of(
+ XmlElement element = element("w:styles", list(
+ element("w:style", map("w:type", "character", "w:styleId", "Heading1Char"), list(
nameElement("Heading 1 Char")))));
Styles styles = readStylesXmlElement(element);
@@ -46,10 +46,10 @@ public class StylesXmlTests {
@Test
public void paragraphAndCharacterStylesAreDistinct() {
- XmlElement element = element("w:styles", ImmutableList.of(
- element("w:style", map("w:type", "paragraph", "w:styleId", "Heading1"), ImmutableList.of(
+ XmlElement element = element("w:styles", list(
+ element("w:style", map("w:type", "paragraph", "w:styleId", "Heading1"), list(
nameElement("Heading 1"))),
- element("w:style", map("w:type", "character", "w:styleId", "Heading1Char"), ImmutableList.of(
+ element("w:style", map("w:type", "character", "w:styleId", "Heading1Char"), list(
nameElement("Heading 1 Char")))));
Styles styles = readStylesXmlElement(element);
@@ -60,7 +60,7 @@ public class StylesXmlTests {
@Test
public void styleNameIsNoneIfNameElementDoesNotExist() {
- XmlElement element = element("w:styles", ImmutableList.of(
+ XmlElement element = element("w:styles", list(
element("w:style", map("w:type", "paragraph", "w:styleId", "Heading1")),
element("w:style", map("w:type", "character", "w:styleId", "Heading1Char"))));
diff --git a/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java b/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java
index c19ec4c..a14688f 100644
--- a/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java
@@ -1,7 +1,6 @@
package org.zwobble.mammoth.tests.xml;
import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableList;
import org.hamcrest.Matcher;
import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.collection.IsIterableContainingInOrder;
@@ -17,6 +16,7 @@ import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
+import static org.zwobble.mammoth.util.MammothLists.list;
import static org.zwobble.mammoth.util.MammothMaps.map;
public class XmlParserTests {
@@ -50,8 +50,8 @@ public class XmlParserTests {
public void canParseElementWithDescendantElements() {
assertThat(
parser.parseString("<body><a><b/></a><a/></body>"),
- isElement("body", map(), ImmutableList.of(
- isElement("a", map(), ImmutableList.of(
+ isElement("body", map(), list(
+ isElement("a", map(), list(
isElement("b"))),
isElement("a"))));
}
@@ -60,7 +60,7 @@ public class XmlParserTests {
public void canParseTextNodes() {
assertThat(
parser.parseString("<body>Hello!</body>"),
- isElement("body", map(), ImmutableList.of(
+ isElement("body", map(), list(
isTextNode("Hello!"))));
}
@@ -106,7 +106,7 @@ public class XmlParserTests {
}
private Matcher<XmlElement> isElement(String name, Map<String, String> attributes) {
- return isElement(name, attributes, ImmutableList.of());
+ return isElement(name, attributes, list());
}
private Matcher<XmlElement> isElement(String name, Map<String, String> attributes, List<Matcher<? extends XmlNode>> children) {