Search in sources :

Example 6 with PMDPropertyDialogBot

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

the class PMDPropertyDialogTest method enablePMD.

private void enablePMD() {
    final PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_1);
    assertFalse("PMD should be disabled by default", dialog.enablePMD().isChecked());
    assertFalse("The button to add a new rule set should be disabled as long as PMD is disabled", dialog.addRuleSet().isEnabled());
    dialog.enablePMD().select();
    dialog.ok().click();
    dialog.bot().waitUntil(shellCloses(dialog));
}
Also used : PMDPropertyDialogBot(ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)

Example 7 with PMDPropertyDialogBot

use of ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot 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 8 with PMDPropertyDialogBot

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

the class PMDPropertyDialogTest method activateTheSameFileSystemRuleSetInSecondProject.

private void activateTheSameFileSystemRuleSetInSecondProject() {
    PMDPropertyDialogBot dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_2);
    assertFalse("PMD should be disabled by default", dialog.enablePMD().isChecked());
    dialog.enablePMD().select();
    assertEquals("The previously added rule set should als be available in the second project", 1, dialog.ruleSets().rowCount());
    assertFalse("The available rule set should not 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.ruleSets().getTableItem(0).check();
    dialog.ok().click();
    dialog.bot().waitUntil(shellCloses(dialog));
    dialog = JavaProjectClient.openPMDPropertyDialog(PROJECT_NAME_2);
    assertTrue("PMD should be enabled", dialog.enablePMD().isChecked());
    assertTrue("The rule set should be activated", dialog.ruleSets().getTableItem(0).isChecked());
    dialog.ok().click();
    dialog.bot().waitUntil(shellCloses(dialog));
}
Also used : PMDPropertyDialogBot(ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)

Example 9 with PMDPropertyDialogBot

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

PMDPropertyDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.PMDPropertyDialogBot)9 AddRuleSetConfigurationWizardBot (ch.acanda.eclipse.pmd.swtbot.bot.AddRuleSetConfigurationWizardBot)4 SWTBotTableItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem)2 FileSelectionDialogBot (ch.acanda.eclipse.pmd.swtbot.bot.FileSelectionDialogBot)1 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)1