Search in sources :

Example 1 with FileSelectionDialogBot

use of ch.acanda.eclipse.pmd.swtbot.bot.FileSelectionDialogBot 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));
}
Also used : FileSelectionDialogBot(ch.acanda.eclipse.pmd.swtbot.bot.FileSelectionDialogBot) AddRuleSetConfigurationWizardBot(ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot) PMDPropertyDialogBot(ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)

Aggregations

AddRuleSetConfigurationWizardBot (ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot)1 FileSelectionDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.FileSelectionDialogBot)1 PMDPropertyDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)1