From d91ddfe924176707062ce447722993d9d9aac415 Mon Sep 17 00:00:00 2001
From: Michael Williamson
Date: Thu, 31 Dec 2015 16:00:54 +0000
Subject: Remove equals and hashCode from XML nodes
---
.../zwobble/mammoth/tests/xml/XmlParserTests.java | 83 +++++++++++++++-------
1 file changed, 57 insertions(+), 26 deletions(-)
(limited to 'src/test')
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 00f8fb2..b93838e 100644
--- a/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/xml/XmlParserTests.java
@@ -1,18 +1,23 @@
package org.zwobble.mammoth.tests.xml;
-import java.io.ByteArrayInputStream;
-
+import com.google.common.collect.ImmutableBiMap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.hamcrest.Matcher;
+import org.hamcrest.collection.IsEmptyIterable;
+import org.hamcrest.collection.IsIterableContainingInOrder;
import org.junit.Test;
import org.zwobble.mammoth.xml.XmlElement;
+import org.zwobble.mammoth.xml.XmlNode;
import org.zwobble.mammoth.xml.XmlParser;
import org.zwobble.mammoth.xml.XmlTextNode;
-import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.Map;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
public class XmlParserTests {
private final XmlParser parser = new XmlParser(ImmutableBiMap.of());
@@ -21,59 +26,56 @@ public class XmlParserTests {
public void canParseSelfClosingElement() {
assertThat(
parser.parseString(""),
- is(new XmlElement("body")));
+ isElement("body"));
assertThat(
parser.parseString(""),
- is(new XmlElement("values")));
+ isElement("values"));
}
@Test
public void canParseEmptyElementWithSeparateClosingTag() {
assertThat(
parser.parseString("
"),
- is(new XmlElement("body")));
+ isElement("body"));
}
@Test
public void canParseAttributesOfTag() {
assertThat(
parser.parseString(""),
- is(new XmlElement("body", ImmutableMap.of("name", "bob"))));
+ isElement("body", ImmutableMap.of("name", "bob")));
}
@Test
public void canParseElementWithDescendantElements() {
assertThat(
parser.parseString(""),
- is(new XmlElement("body", ImmutableMap.of(), ImmutableList.of(
- new XmlElement("a", ImmutableMap.of(), ImmutableList.of(
- new XmlElement("b")
- )),
- new XmlElement("a")
- ))));
+ isElement("body", ImmutableMap.of(), ImmutableList.of(
+ isElement("a", ImmutableMap.of(), ImmutableList.of(
+ isElement("b"))),
+ isElement("a"))));
}
-
+
@Test
public void canParseTextNodes() {
assertThat(
parser.parseString("Hello!"),
- is(new XmlElement("body", ImmutableMap.of(), ImmutableList.of(
- new XmlTextNode("Hello!")
- ))));
+ isElement("body", ImmutableMap.of(), ImmutableList.of(
+ isTextNode("Hello!"))));
}
@Test
public void unmappedNamespaceUrisInElementNamesAreIncludedInBracesAsPrefix() {
assertThat(
parser.parseString(""),
- is(new XmlElement("{word}body")));
+ isElement("{word}body"));
}
@Test
public void unmappedNamespaceUrisInAttributeNamesAreIncludedInBracesAsPrefix() {
assertThat(
parser.parseString(""),
- is(new XmlElement("body", ImmutableMap.of("{word}name", "bob"))));
+ isElement("body", ImmutableMap.of("{word}name", "bob")));
}
@Test
@@ -81,7 +83,7 @@ public class XmlParserTests {
XmlParser parser = new XmlParser(ImmutableBiMap.of("x", "word"));
assertThat(
parser.parseString(""),
- is(new XmlElement("x:body")));
+ isElement("x:body"));
}
@Test
@@ -89,13 +91,42 @@ public class XmlParserTests {
XmlParser parser = new XmlParser(ImmutableBiMap.of("x", "word"));
assertThat(
parser.parseString("