@Test
public void createNodeAtPosition() throws Exception {

    String newNodeName = "NEW_NODE_NAME_0";
    String newNodeValue = "NEW_NODE_VALUE_=";
    Document document = DOMParserUtil.getDocument(XML);
    Map<Node, List<Node>> testNodesMap = DOMParserUtil.getChildrenNodesMap(document, MAIN_NODE, TEST_NODE);
    assertEquals(1, testNodesMap.size());
    Node mainNode = testNodesMap.keySet().iterator().next();
    Node retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, null);
    assertNotNull(retrieved);
    assertEquals(newNodeName, retrieved.getNodeName());
    assertEquals(newNodeValue, retrieved.getTextContent());
    assertEquals(retrieved, mainNode.getChildNodes().item(mainNode.getChildNodes().getLength() - 1));
    newNodeName = "NEW_NODE_NAME_1";
    newNodeValue = "NEW_NODE_VALUE_1";
    retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, 0);
    assertNotNull(retrieved);
    assertEquals(newNodeName, retrieved.getNodeName());
    assertEquals(newNodeValue, retrieved.getTextContent());
    assertEquals(retrieved, mainNode.getChildNodes().item(0));
    newNodeName = "NEW_NODE_NAME_2";
    newNodeValue = "NEW_NODE_VALUE_2";
    retrieved = DOMParserUtil.createNodeAtPosition(mainNode, newNodeName, newNodeValue, 2);
    assertNotNull(retrieved);
    assertEquals(newNodeName, retrieved.getNodeName());
    assertEquals(newNodeValue, retrieved.getTextContent());
    assertEquals(retrieved, mainNode.getChildNodes().item(2));
}