Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 a94aef1
Show file tree
Hide file tree
Showing 24 changed files with 264 additions and 201 deletions.
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
@@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}
Expand Up @@ -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.
Expand All @@ -30,7 +33,7 @@ public abstract class AnalysisAction extends ContainerPageObject {
* @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());
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
@@ -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);
}

}
Expand Up @@ -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
*/
Expand All @@ -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");
}


}
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
@@ -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);
}
Expand Down
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
@@ -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);
}
Expand Down

0 comments on commit a94aef1

Please sign in to comment.