Object attr = pg.getAttribute("globalActions");
assertNotNull("Value provided", attr);
assertEquals(true, attr instanceof Calls);
Calls calls = (Calls)attr;
Map<String,Integer> all = calls.getTopTen(10, null, null, Actions.Invocations.ALL);
assertEquals("three elements:\n" + all, 3, all.size());
assertEquals("two OpenFile", 2, all.get("org.netbeans.modules.openfile.OpenFileAction").intValue());
assertEquals("two OpenProject", 2, all.get("org.netbeans.modules.project.ui.actions.OpenProject").intValue());
assertEquals("one goto type", 1, all.get("org.netbeans.modules.java.actions.GoToTypeAction").intValue());
{
// order is from most used to less used
Iterator<String> it;
it = all.keySet().iterator();
assertEquals("org.netbeans.modules.openfile.OpenFileAction", it.next());
assertEquals("org.netbeans.modules.project.ui.actions.OpenProject", it.next());
assertEquals("org.netbeans.modules.java.actions.GoToTypeAction", it.next());
}
{
// check includes
Map<String,Integer> type = calls.getTopTen(10, ".*GoTo.*", null, Actions.Invocations.ALL);
assertEquals("just one element:\n" + type, 1, type.size());
assertEquals("only goto type", 1, type.get("org.netbeans.modules.java.actions.GoToTypeAction").intValue());
}
{
// check excludes
Map<String,Integer> type = calls.getTopTen(10, null, ".*Open.*", Actions.Invocations.ALL);
assertEquals("just one element:\n" + type, 1, type.size());
assertEquals("only goto type", 1, type.get("org.netbeans.modules.java.actions.GoToTypeAction").intValue());
}
//verify invokations
Map<String,Integer> menu = calls.getTopTen(10, null, null, Actions.Invocations.MENU);
assertEquals("three elements:\n" + menu, 3, menu.size());
assertEquals("two OpenFile", 2, menu.get("org.netbeans.modules.openfile.OpenFileAction").intValue());
assertEquals("one OpenProject", 1, menu.get("org.netbeans.modules.project.ui.actions.OpenProject").intValue());
assertEquals("one goto type", 1, menu.get("org.netbeans.modules.java.actions.GoToTypeAction").intValue());
Map<String,Integer> toolbar = calls.getTopTen(10, null, null, Actions.Invocations.TOOLBAR);
assertEquals("one element:\n" + toolbar, 1, toolbar.size());
assertEquals("one OpenProject", 1, toolbar.get("org.netbeans.modules.project.ui.actions.OpenProject").intValue());
Map<String,Integer> shortCut = calls.getTopTen(10, null, null, Actions.Invocations.SHORTCUT);
assertEquals("no elements:\n" + shortCut, 0, shortCut.size());
}