for (String filename : getToolList()) {
Document gmftool = getToolCache().get(filename);
Document gmfmap = loadGmfmap(filename);
IterableElementList roots = xpath(gmftool, "/ToolRegistry/palette/tools");
IterableElementList tools = getAllGmfTools(roots, filename);
for (Element tool : tools) {
// EventTrigger
String toolName = tool.getAttribute("title");
// remove any selectors
String selector = getSelector(toolName);
toolName = removeSelectors(toolName);
String nodeXpath, linkXpath;
if (selector == null) {
// a normal node
nodeXpath = "/Mapping/nodes/ownedChild/domainMetaElement[contains(@href, '" + toolName + "')]";
linkXpath = "/Mapping/links/domainMetaElement[contains(@href, '" + toolName + "')]";
} else {
nodeXpath = "/Mapping/nodes/ownedChild/domainMetaElement[contains(@href, '" + toolName + "') and contains(../../containmentFeature/@href, '" + selector + "')]";
linkXpath = "/Mapping/links/domainMetaElement[contains(@href, '" + toolName + "')]";
}
// should match either a node..
IterableElementList matches = xpath(gmfmap, nodeXpath);
boolean matched = false;
if (selector == null) {
// TODO not sure how to test this yet
continue;
}
for (Element match : matches) {
String href = match.getAttribute("href");
if (href.endsWith(toolName)) {
if (selector != null) {
assertFalse(filename + ": More than one mapping for tool '" + toolName + "': " + selector, matched);
matched = true;
}
if (selector == null) {
// TODO not sure how to test this yet
/*
assertEquals(filename + ": More than one non-selector mapping for tool '" + toolName + "': " + selector, 0, nullCount);
nullCount++;
*/
}
}
}
// or a link
IterableElementList matches2 = xpath(gmfmap, linkXpath);
for (Element match : matches2) {
String href = match.getAttribute("href");
if (href.endsWith(toolName)) {
if (selector != null) {
assertFalse(filename + ": More than one mapping for tool '" + toolName + "': " + selector, matched);