use of org.dom4j.Entity in project tmdm-studio-se by Talend.
the class XmlUtilTest method testTreeWalk.
/*
* treeWalk(Element element, NodeProcess nodeProcess)
*/
@Test
public void testTreeWalk() {
// $NON-NLS-1$
String tag = "name";
Element parent = DocumentHelper.createElement(tag);
// $NON-NLS-1$ //$NON-NLS-2$
Attribute attr1 = DocumentHelper.createAttribute(parent, "Attr", "Value");
// $NON-NLS-1$
CDATA cDATA1 = DocumentHelper.createCDATA("cdata");
// $NON-NLS-1$
Comment comment1 = DocumentHelper.createComment("comment");
// $NON-NLS-1$ //$NON-NLS-2$
Entity entity1 = DocumentHelper.createEntity("entity", "entityname");
// $NON-NLS-1$
Text text1 = DocumentHelper.createText("text");
parent.add(attr1);
parent.add(cDATA1);
parent.add(comment1);
parent.add(entity1);
parent.add(text1);
// $NON-NLS-1$
Element childElement = DocumentHelper.createElement("child");
parent.add(childElement);
// $NON-NLS-1$ //$NON-NLS-2$
Attribute attr2 = DocumentHelper.createAttribute(parent, "Attr", "Value");
// $NON-NLS-1$
CDATA cDATA2 = DocumentHelper.createCDATA("cdata");
// $NON-NLS-1$
Comment comment2 = DocumentHelper.createComment("comment");
// $NON-NLS-1$ //$NON-NLS-2$
Entity entity2 = DocumentHelper.createEntity("entity", "entityname");
// $NON-NLS-1$
Text text2 = DocumentHelper.createText("text");
childElement.add(attr2);
childElement.add(cDATA2);
childElement.add(comment2);
childElement.add(entity2);
childElement.add(text2);
NodeProcess mockNodeProcess = mock(NodeProcess.class);
XmlUtil.treeWalk(parent, mockNodeProcess);
verify(mockNodeProcess, times(0)).process(attr1);
verify(mockNodeProcess).process(cDATA1);
verify(mockNodeProcess).process(comment1);
verify(mockNodeProcess).process(entity1);
verify(mockNodeProcess).process(text1);
verify(mockNodeProcess, times(0)).process(attr2);
verify(mockNodeProcess).process(cDATA2);
verify(mockNodeProcess).process(comment2);
verify(mockNodeProcess).process(entity2);
verify(mockNodeProcess).process(text2);
}