org.testng.xml.XmlDependencies Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testng Show documentation
Show all versions of testng Show documentation
Testing framework for Java
package org.testng.xml;
import java.util.Map;
import org.testng.collections.Maps;
import org.testng.reporters.XMLStringBuffer;
import org.testng.xml.dom.OnElement;
import static org.testng.collections.CollectionUtils.hasElements;
public class XmlDependencies {
private Map m_xmlDependencyGroups = Maps.newHashMap();
@OnElement(tag = "group", attributes = { "name", "depends-on" })
public void onGroup(String name, String dependsOn) {
m_xmlDependencyGroups.put(name, dependsOn);
}
public Map getDependencies() {
return m_xmlDependencyGroups;
}
public String toXml(String indent) {
XMLStringBuffer xsb = new XMLStringBuffer(indent);
boolean hasElements = hasElements(m_xmlDependencyGroups);
if (hasElements) {
xsb.push("dependencies");
}
for (Map.Entry entry : m_xmlDependencyGroups.entrySet()) {
xsb.addEmptyElement("include", "name", entry.getKey(), "depends-on", entry.getValue());
}
if (hasElements) {
xsb.pop("dependencies");
}
return xsb.toXML();
}
}