use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot in project eclipse-pmd by acanda.
the class PMDPropertyDialogTest method addFileSystemRuleSetInFirstProject.
public void addFileSystemRuleSetInFirstProject() {
final PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertTrue("PMD should be enabled", dialog.enablePMD().isChecked());
assertTrue("The button to add a new rule set should be enabled when PMD is enabled", dialog.addRuleSet().isEnabled());
dialog.addRuleSet().click();
final AddRuleSetConfigurationWizardBot wizard = AddRuleSetConfigurationWizardBot.getActive();
wizard.waitUntilFinishIsDisabled("The finish button should be disabled as long as the name and location are missing");
wizard.filesystem().click();
wizard.next().click();
wizard.waitUntilFinishIsDisabled("The finish button should be disabled as long as the name and location are missing");
assertTrue("The browse button should be visible for a file system rule set", wizard.isBrowseButtonVisible());
wizard.location().setText(rules.getAbsolutePath());
wizard.bot().waitUntil(tableHasRows(wizard.rules(), 2));
final String[] expectedNames = new String[] { "ExtendsObject", "BooleanInstantiation" };
final String[] actualNames = wizard.ruleNames();
assertEquals("The name of the ruleset should be loaded into the name text field", TEST_RULE_SET_NAME, wizard.name().getText());
assertArrayEquals("Rules of the PMD ", expectedNames, actualNames);
wizard.waitUntilFinishIsEnabled("The finish button should be enabled if both a name and a location is available");
wizard.name().setText("");
wizard.waitUntilFinishIsDisabled("The finish button should be disabled if the name is not available");
wizard.name().setText(FILE_SYSTEM_RULE_SET_NAME);
wizard.waitUntilFinishIsEnabled("The finish button should be enabled if the name is available");
wizard.finish().click();
wizard.bot().waitUntil(shellCloses(wizard));
dialog.bot().waitUntil(tableHasRows(dialog.ruleSets(), 1));
assertTrue("The added rule set should be activated", dialog.ruleSets().getTableItem(0).isChecked());
assertEquals("Name of the rule set", FILE_SYSTEM_RULE_SET_NAME, dialog.ruleSets().cell(0, "Name"));
assertEquals("Type of the rule set", "File System", dialog.ruleSets().cell(0, "Type"));
assertEquals("Location of the rule set", rules.getAbsolutePath(), dialog.ruleSets().cell(0, "Location"));
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
}
use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot in project eclipse-pmd by acanda.
the class PMDPropertyDialogTest method deactivateFileSystemRuleSet.
private void deactivateFileSystemRuleSet() {
PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertTrue("PMD should be enabled", dialog.enablePMD().isChecked());
final SWTBotTableItem fileSystemTableItem = dialog.ruleSets().getTableItem(FILE_SYSTEM_RULE_SET_NAME);
fileSystemTableItem.uncheck();
dialog.bot().waitWhile(isChecked(fileSystemTableItem));
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertFalse("The deactivated rule set should still be in the table since it is used by project " + PROJECT_NAME_2, dialog.ruleSets().getTableItem(FILE_SYSTEM_RULE_SET_NAME).isChecked());
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
}
use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot in project eclipse-pmd by acanda.
the class PMDPropertyDialogTest method addWorkspaceRuleSetInFirstProject.
private void addWorkspaceRuleSetInFirstProject() {
final PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertTrue("PMD should be enabled", dialog.enablePMD().isChecked());
assertTrue("The button to add a new rule set should be enabled when PMD is enabled", dialog.addRuleSet().isEnabled());
dialog.enablePMD().select();
dialog.addRuleSet().click();
final AddRuleSetConfigurationWizardBot wizard = AddRuleSetConfigurationWizardBot.getActive();
wizard.waitUntilFinishIsDisabled("The finish button should be disabled as long as the name is missing");
wizard.workspace().click();
wizard.next().click();
wizard.waitUntilFinishIsDisabled("The finish button should be disabled as long as the name is missing");
assertTrue("The browse button should be visible for a workspace rule set", wizard.isBrowseButtonVisible());
wizard.browse().click();
final FileSelectionDialogBot fileSelectionDialog = FileSelectionDialogBot.getActive();
fileSelectionDialog.select(PROJECT_NAME_1, PMD_XML.toString());
fileSelectionDialog.ok().click();
fileSelectionDialog.waitUntilClosed();
final String workspaceRelativePath = PROJECT_NAME_1 + '/' + PMD_XML;
assertEquals("The location should contain the project name and the path to the rule set file", wizard.location().getText(), workspaceRelativePath);
wizard.bot().waitUntil(tableHasRows(wizard.rules(), 2));
assertEquals("The name of the ruleset should be loaded into the name text field", TEST_RULE_SET_NAME, wizard.name().getText());
final String[] expectedNames = new String[] { "ExtendsObject", "BooleanInstantiation" };
final String[] actualNames = wizard.ruleNames();
assertArrayEquals("Rules of the PMD rule set", expectedNames, actualNames);
wizard.waitUntilFinishIsEnabled("The finish button should be enabled if both a name and a location are available");
wizard.name().setText("");
wizard.waitUntilFinishIsDisabled("The finish button should be disabled if the name is not available");
wizard.name().setText(WORKSPACE_RULE_SET_NAME);
wizard.waitUntilFinishIsEnabled("The finish button should be enabled if the name is available");
wizard.finish().click();
wizard.bot().waitUntil(shellCloses(wizard));
dialog.bot().waitUntil(tableHasRows(dialog.ruleSets(), 2));
assertTrue("The added rule set should be activated", dialog.ruleSets().getTableItem(1).isChecked());
assertEquals("Name of the rule set", WORKSPACE_RULE_SET_NAME, dialog.ruleSets().cell(1, "Name"));
assertEquals("Type of the rule set", "Workspace", dialog.ruleSets().cell(1, "Type"));
assertEquals("Location of the rule set", workspaceRelativePath, dialog.ruleSets().cell(1, "Location"));
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
}
use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot in project eclipse-pmd by acanda.
the class PMDPropertyDialogTest method deactivateWorkspaceRuleSet.
private void deactivateWorkspaceRuleSet() {
PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertTrue("PMD should be enabled", dialog.enablePMD().isChecked());
final SWTBotTableItem workspaceTableItem = dialog.ruleSets().getTableItem(WORKSPACE_RULE_SET_NAME);
workspaceTableItem.uncheck();
dialog.bot().waitWhile(isChecked(workspaceTableItem));
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
assertEquals("The deactivated rule set should not be in the table anymore since it is not used by any other project", 3, dialog.ruleSets().rowCount());
dialog.ok().click();
dialog.bot().waitUntil(shellCloses(dialog));
}
use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot in project eclipse-pmd by acanda.
the class JavaProjectClient method openPMDPropertyDialog.
/**
* Opens the PMD property dialog of the project with the provided name.
*
* @param name The name of the project.
* @return A bot for the open PMD property dialog.
*/
public static PMDPropertyDialogBot openPMDPropertyDialog(final String name) {
final SWTWorkbenchBot bot = new SWTWorkbenchBot();
bot.viewById("org.eclipse.jdt.ui.PackageExplorer").bot().tree().getTreeItem(name).select();
bot.menu("File").menu("Properties").click();
final PMDPropertyDialogBot dialog = new PMDPropertyDialogBot(bot.shell("Properties for " + name).widget);
dialog.bot().tree().getTreeItem("PMD").select();
return dialog;
}
Aggregations