Search in sources :

Example 1 with AddRuleSetConfigurationWizardBot

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

Example 2 with AddRuleSetConfigurationWizardBot

use of ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot 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)

Example 3 with AddRuleSetConfigurationWizardBot

use of ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot in project eclipse-pmd by acanda.

the class PMDPropertyDialogTest method addProjectRuleSetInFirstProject.

private void addProjectRuleSetInFirstProject() {
    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();
    assertFalse("The finish button should be disabled as long as the name is missing", wizard.finish().isEnabled());
    wizard.project().click();
    wizard.next().click();
    assertFalse("The finish button should be disabled as long as the name is missing", wizard.finish().isEnabled());
    assertTrue("The browse button should be visible for a project rule set", wizard.isBrowseButtonVisible());
    final String projectRelativePath = PMD_XML.toString();
    wizard.location().setText(projectRelativePath);
    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);
    assertTrue("The finish button should be enabled if both a name and a location with a valid rule set is available", wizard.finish().isEnabled());
    wizard.name().setText("");
    wizard.waitUntilFinishIsDisabled("The finish button should be disabled if the name is not available");
    wizard.name().setText(PROJECT_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(), 3));
    assertTrue("The added rule set should be activated", dialog.ruleSets().getTableItem(2).isChecked());
    assertEquals("Name of the rule set", PROJECT_RULE_SET_NAME, dialog.ruleSets().cell(2, "Name"));
    assertEquals("Type of the rule set", "Project", dialog.ruleSets().cell(2, "Type"));
    assertEquals("Location of the rule set", projectRelativePath, dialog.ruleSets().cell(2, "Location"));
    dialog.ok().click();
    dialog.bot().waitUntil(shellCloses(dialog));
}
Also used : AddRuleSetConfigurationWizardBot(ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot) PMDPropertyDialogBot(ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)

Example 4 with AddRuleSetConfigurationWizardBot

use of ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot in project eclipse-pmd by acanda.

the class PMDPropertyDialogTest method addRemoteRuleSetInFirstProject.

private void addRemoteRuleSetInFirstProject() {
    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 is missing");
    wizard.remote().click();
    wizard.next().click();
    wizard.waitUntilFinishIsDisabled("The finish button should be disabled as long as the name is missing");
    assertFalse("The browse button should not be visible for a remote rule set", wizard.isBrowseButtonVisible());
    final String uri = rules.toURI().toString();
    wizard.location().setText(uri);
    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(REMOTE_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(), 4));
    assertTrue("The added rule set should be activated", dialog.ruleSets().getTableItem(3).isChecked());
    assertEquals("Name of the rule set", REMOTE_RULE_SET_NAME, dialog.ruleSets().cell(3, "Name"));
    assertEquals("Type of the rule set", "Remote", dialog.ruleSets().cell(3, "Type"));
    assertEquals("Location of the rule set", uri, dialog.ruleSets().cell(3, "Location"));
    dialog.ok().click();
    dialog.bot().waitUntil(shellCloses(dialog));
}
Also used : 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)4 PMDPropertyDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)4 FileSelectionDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.FileSelectionDialogBot)1