@Test public void canAppendChildElementAfterExistingElement() { SpinXmlElement child = XML("<child/>"); SpinXmlElement date = element.childElement("date"); element.appendAfter(child, date); SpinXmlElement insertedElement = element.childElements().get(1); assertThat(insertedElement.name()).isEqualTo("child"); }
@Test public void canAppendChildElementAfterLastChildElement() { SpinXmlElement child = XML("<child/>"); int childCount = element.childElements().size(); SpinXmlElement lastChildElement = element.childElements().get(childCount - 1); element.appendAfter(child, lastChildElement); SpinXmlElement insertedElement = element.childElements().get(childCount); assertThat(insertedElement.name()).isEqualTo("child"); }
@Test(expected = SpinXmlElementException.class) public void cannotAppendChildElementAfterNonChildElement() { SpinXmlElement child = XML("<child/>"); element.appendAfter(child, child); }