Skip to content
Permalink
Browse files

Pulled column and portlet tests up to AbstractAnalysisTest.

Now all static analysis plug-ins have a common test that checks that the number of warnings is shown as a link in the warnings column and warnings table portlet.
Currently a test does not check the URL itself it rather clicks the link to see if the navigation works. This could be used as a basis for [JENKINS-39947].
  • Loading branch information...
uhafner committed Jan 3, 2017
1 parent 87a407e commit a94aef1e8d8d340bd7bd01ba67ba7716fbea8b36
Showing with 264 additions and 201 deletions.
  1. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_collector/AnalysisCollectorAction.java
  2. +3 −10 ...main/java/org/jenkinsci/test/acceptance/plugins/analysis_collector/WarningsPerProjectPortlet.java
  3. +22 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AbstractTablePortlet.java
  4. +40 −4 src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisAction.java
  5. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/checkstyle/CheckStyleAction.java
  6. +3 −4 src/main/java/org/jenkinsci/test/acceptance/plugins/checkstyle/CheckStylePortlet.java
  7. +6 −4 src/main/java/org/jenkinsci/test/acceptance/plugins/dashboard_view/AbstractDashboardViewPortlet.java
  8. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/findbugs/FindBugsAction.java
  9. +3 −3 src/main/java/org/jenkinsci/test/acceptance/plugins/findbugs/FindBugsPortlet.java
  10. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/pmd/PmdAction.java
  11. +3 −3 src/main/java/org/jenkinsci/test/acceptance/plugins/pmd/PmdWarningsPortlet.java
  12. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/tasks/TaskScannerAction.java
  13. +17 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/tasks/TasksColumn.java
  14. +18 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/tasks/TasksPortlet.java
  15. +12 −0 src/main/java/org/jenkinsci/test/acceptance/plugins/warnings/WarningsAction.java
  16. +2 −7 src/main/java/org/jenkinsci/test/acceptance/plugins/warnings/WarningsPortlet.java
  17. +1 −2 src/main/java/org/jenkinsci/test/acceptance/po/AbstractListViewColumn.java
  18. +9 −0 src/main/java/org/jenkinsci/test/acceptance/po/Build.java
  19. +59 −5 src/test/java/plugins/AbstractAnalysisTest.java
  20. +2 −1 src/test/java/plugins/AnalysisCollectorPluginTest.java
  21. +3 −53 src/test/java/plugins/CheckStylePluginTest.java
  22. +0 −48 src/test/java/plugins/FindBugsPluginTest.java
  23. +0 −41 src/test/java/plugins/PmdPluginTest.java
  24. +1 −16 src/test/java/plugins/WarningsPluginTest.java
@@ -2,6 +2,8 @@

import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisSettings;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.po.AbstractListViewColumn;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.Job;

@@ -26,6 +28,16 @@ public String getPluginName() {
return "Static Analysis";
}

@Override
public Class<? extends AbstractDashboardViewPortlet> getTablePortlet() {
return WarningsPerProjectPortlet.class;
}

@Override
public Class<? extends AbstractListViewColumn> getViewColumn() {
return AnalysisCollectorColumn.class;
}

@Override
public Class<? extends AnalysisSettings> getFreeStyleSettings() {
return AnalysisCollectorSettings.class;
@@ -1,6 +1,6 @@
package org.jenkinsci.test.acceptance.plugins.analysis_collector;

import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AbstractTablePortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.Describable;
@@ -11,22 +11,16 @@
* @author Michael Prankl
*/
@Describable("Warnings per project")
public class WarningsPerProjectPortlet extends AbstractDashboardViewPortlet {
public class WarningsPerProjectPortlet extends AbstractTablePortlet {
private AnalysisCollectorPluginArea pluginArea;

private Control hideZeroWarningsProjects = control("canHideZeroWarningsProjects");
private Control showImagesInTableHeader = control("useImages");

public WarningsPerProjectPortlet(DashboardView parent, String path) {
super(parent, path);
this.pluginArea = new AnalysisCollectorPluginArea(parent, path);
}

public WarningsPerProjectPortlet hideZeroWarningsProjects(boolean checked) {
hideZeroWarningsProjects.check(checked);
return this;
}

public WarningsPerProjectPortlet showImagesInTableHeader(boolean checked) {
showImagesInTableHeader.check(checked);
return this;
@@ -35,11 +29,10 @@ public WarningsPerProjectPortlet showImagesInTableHeader(boolean checked) {
/**
* Select if the warnings of given plugin should be included in the portlet.
*
* @param plugin the Plugin
* @param plugin the plug-in
* @param checked true or false
*/
public void checkCollectedPlugin(AnalysisPlugin plugin, boolean checked) {
plugin.check(this.pluginArea, checked);
}

}
@@ -0,0 +1,22 @@
package org.jenkinsci.test.acceptance.plugins.analysis_core;

import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.po.Control;

/**
* A portlet that show the number of warnings in a table.
*
* @author Ullrich Hafner
*/
public class AbstractTablePortlet extends AbstractDashboardViewPortlet {
private Control hideZeroWarningsProjects = control("canHideZeroWarningsProjects");

protected AbstractTablePortlet(DashboardView parent, String path) {
super(parent, path);
}

public void hideZeroWarningsProjects(final boolean checked) {
hideZeroWarningsProjects.check(checked);
}
}
@@ -8,20 +8,23 @@
import java.util.TreeMap;

import org.apache.commons.lang3.StringUtils;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.po.AbstractListViewColumn;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.ContainerPageObject;
import org.jenkinsci.test.acceptance.po.Job;
import org.openqa.selenium.WebElement;

/**
* Abstract action class for static analysis plugins with getters for warnings.
* Action for static analysis plugins with getters for warnings.
*
* @author Martin Kurz
*/
public abstract class AnalysisAction extends ContainerPageObject {
private final String pluginUrl;
private final ContainerPageObject parent;
private final String plugin;
private final String parentName;

/**
* Creates a new instance of a static analysis action.
@@ -30,7 +33,7 @@
* @param plugin plug-in name
*/
public AnalysisAction(final Build parent, final String plugin) {
this(plugin + "Result", plugin, parent);
this(plugin + "Result", plugin, parent, parent.getName());
}

/**
@@ -40,7 +43,7 @@ public AnalysisAction(final Build parent, final String plugin) {
* @param plugin Path to plugin without / at the end
*/
public AnalysisAction(final Job parent, final String plugin) {
this(plugin, plugin, parent);
this(plugin, plugin, parent, parent.name);
}

/**
@@ -52,12 +55,13 @@ protected ContainerPageObject getParent() {
return parent;
}

private AnalysisAction(final String url, final String pluginUrl, final ContainerPageObject parent) {
private AnalysisAction(final String url, final String pluginUrl, final ContainerPageObject parent, final String parentName) {
super(parent, parent.url(url + '/'));

this.pluginUrl = pluginUrl;
this.parent = parent;
plugin = url;
this.parentName = parentName;
}

/**
@@ -67,6 +71,29 @@ private AnalysisAction(final String url, final String pluginUrl, final Container
*/
public abstract String getPluginName();

/**
* Returns the class of the table dashboard portlet.
*
* @return class of the table portlet
*/
public abstract Class<? extends AbstractDashboardViewPortlet> getTablePortlet();

/**
* Returns the class of the view column.
*
* @return class of the view column
*/
public abstract Class<? extends AbstractListViewColumn> getViewColumn();

/**
* Returns the human readable name of the parent of this action.
*
* @return the parent name
*/
public String getParentName() {
return parentName;
}

/**
* Returns the human readable name of this action.
*
@@ -83,6 +110,15 @@ public String getName() {
*/
public abstract Class<? extends AnalysisSettings> getFreeStyleSettings();

/**
* Returns the URL of the associated plug-in.
*
* @return URL of this action
*/
public String getPluginUrl() {
return pluginUrl;
}

/**
* Returns the URL of this action.
*
@@ -2,6 +2,8 @@

import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisSettings;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.po.AbstractListViewColumn;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.Job;

@@ -26,6 +28,16 @@ public String getPluginName() {
return "Checkstyle";
}

@Override
public Class<? extends AbstractDashboardViewPortlet> getTablePortlet() {
return CheckStylePortlet.class;
}

@Override
public Class<? extends AbstractListViewColumn> getViewColumn() {
return CheckStyleColumn.class;
}

@Override
public Class<? extends AnalysisSettings> getFreeStyleSettings() {
return CheckStyleFreestyleSettings.class;
@@ -1,18 +1,17 @@
package org.jenkinsci.test.acceptance.plugins.checkstyle;

import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AbstractTablePortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.po.Describable;

/**
* A Checkstyle portlet for {@link org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView}.
* A Checkstyle portlet for {@link DashboardView}.
*
* @author Fabian Trampusch
*/
@Describable("Checkstyle warnings per project")
public class CheckStylePortlet extends AbstractDashboardViewPortlet {
public class CheckStylePortlet extends AbstractTablePortlet {
public CheckStylePortlet(final DashboardView parent, final String path) {
super(parent, path);
}

}
@@ -4,7 +4,7 @@
import org.jenkinsci.test.acceptance.po.PageAreaImpl;

/**
* Abstract base class for Dashboard View Portlets.
* A portlet that is shown in the {@link DashboardView}.
*
* @author Fabian Trampusch
*/
@@ -16,25 +16,27 @@ protected AbstractDashboardViewPortlet(DashboardView parent, String path) {
}

/**
* Presses "delete" on the portlet.
* Deletes the portlet, i.e. removes it from the dashboard.
*/
public void delete() {
control("repeatable-delete").click();
}

/**
* Sets the name of the portlet.
*
* @param name the name of the portlet
*/
public void setName(String name) {
this.name.set(name);
}

/**
* Returns the name of the portlet.
*
* @return the name of the portlet
*/
public String getName() {
return this.name.resolve().getAttribute("value");
}


}
@@ -2,6 +2,8 @@

import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisSettings;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.po.AbstractListViewColumn;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.Job;

@@ -26,6 +28,16 @@ public String getPluginName() {
return "FindBugs";
}

@Override
public Class<? extends AbstractDashboardViewPortlet> getTablePortlet() {
return FindBugsPortlet.class;
}

@Override
public Class<? extends AbstractListViewColumn> getViewColumn() {
return FindBugsColumn.class;
}

@Override
public Class<? extends AnalysisSettings> getFreeStyleSettings() {
return FindBugsFreestyleSettings.class;
@@ -1,16 +1,16 @@
package org.jenkinsci.test.acceptance.plugins.findbugs;

import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AbstractTablePortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.po.Describable;

/**
* A FindBugs portlet for {@link org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView}.
* A FindBugs portlet for {@link DashboardView}.
*
* @author Fabian Trampusch
*/
@Describable("FindBugs warnings per project")
public class FindBugsPortlet extends AbstractDashboardViewPortlet {
public class FindBugsPortlet extends AbstractTablePortlet {
public FindBugsPortlet(final DashboardView parent, final String path) {
super(parent, path);
}
@@ -2,6 +2,8 @@

import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisSettings;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.po.AbstractListViewColumn;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.Job;

@@ -26,6 +28,16 @@ public String getPluginName() {
return "PMD";
}

@Override
public Class<? extends AbstractDashboardViewPortlet> getTablePortlet() {
return PmdWarningsPortlet.class;
}

@Override
public Class<? extends AbstractListViewColumn> getViewColumn() {
return PmdColumn.class;
}

@Override
public Class<? extends AnalysisSettings> getFreeStyleSettings() {
return PmdFreestyleSettings.class;
@@ -1,16 +1,16 @@
package org.jenkinsci.test.acceptance.plugins.pmd;

import org.jenkinsci.test.acceptance.plugins.dashboard_view.AbstractDashboardViewPortlet;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AbstractTablePortlet;
import org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView;
import org.jenkinsci.test.acceptance.po.Describable;

/**
* A PMD portlet for {@link org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView}.
* A PMD portlet for {@link DashboardView}.
*
* @author Fabian Trampusch
*/
@Describable("PMD warnings per project")
public class PmdWarningsPortlet extends AbstractDashboardViewPortlet {
public class PmdWarningsPortlet extends AbstractTablePortlet {
public PmdWarningsPortlet(final DashboardView parent, final String path) {
super(parent, path);
}

0 comments on commit a94aef1

Please sign in to comment.
You can’t perform that action at this time.