Search in sources :

Example 1 with AttributeProcess

use of com.amalto.workbench.utils.callback.AttributeProcess in project tmdm-studio-se by Talend.

the class XmlUtilTest method testIterateAttribute.

/*
     * iterateAttribute(Element element, AttributeProcess attributeProcess)
     */
@Test
public void testIterateAttribute() {
    // $NON-NLS-1$
    String tag = "name";
    Element element = DocumentHelper.createElement(tag);
    // $NON-NLS-1$ //$NON-NLS-2$
    Attribute attr1 = DocumentHelper.createAttribute(element, "Attr1", "Value1");
    // $NON-NLS-1$ //$NON-NLS-2$
    Attribute attr2 = DocumentHelper.createAttribute(element, "Attr2", "Value2");
    // $NON-NLS-1$ //$NON-NLS-2$
    Attribute attr3 = DocumentHelper.createAttribute(element, "Attr3", "Value3");
    element.add(attr1);
    element.add(attr2);
    element.add(attr3);
    AttributeProcess mockAttributeProcess = mock(AttributeProcess.class);
    try {
        XmlUtil.iterateAttribute(element, mockAttributeProcess);
        verify(mockAttributeProcess).process(attr1);
        verify(mockAttributeProcess).process(attr2);
        verify(mockAttributeProcess).process(attr3);
    } catch (DocumentException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : Attribute(org.dom4j.Attribute) AttributeProcess(com.amalto.workbench.utils.callback.AttributeProcess) Element(org.dom4j.Element) DocumentException(org.dom4j.DocumentException) Test(org.junit.Test)

Aggregations

AttributeProcess (com.amalto.workbench.utils.callback.AttributeProcess)1 Attribute (org.dom4j.Attribute)1 DocumentException (org.dom4j.DocumentException)1 Element (org.dom4j.Element)1 Test (org.junit.Test)1