Skip to content
Permalink
Browse files

[FIXED JENKINS-30270] Fixed name of warnings trend graph cookie.

  • Loading branch information
uhafner committed Sep 6, 2015
1 parent e38955e commit cbd19d9145d8977d4ad909f498677b3448e05c22
@@ -19,4 +19,9 @@ public AnalysisCollectorAction(final Build parent) {
public AnalysisCollectorAction(final Job parent) {
super(parent, PLUGIN);
}

@Override
public AnalysisGraphConfigurationView configureTrendGraphForUser() {
return new AnalysisGraphConfigurationView(getParent());
}
}
@@ -0,0 +1,32 @@
package org.jenkinsci.test.acceptance.plugins.analysis_collector;

import org.jenkinsci.test.acceptance.plugins.analysis_core.GraphConfigurationView;
import org.jenkinsci.test.acceptance.po.ContainerPageObject;
import org.jenkinsci.test.acceptance.po.Control;

/**
* Configuration screen of trend graph for the analysis-collector plug-in.
*
* @author Ullrich Hafner
*/
public class AnalysisGraphConfigurationView extends GraphConfigurationView {
private final Control canDeacticateOtherTrendGraphs = control("/canDeacticateOtherTrendGraphs");

/**
* Creates a new instance of {@link AnalysisGraphConfigurationView}.
*
* @param parent Parent container page object
*/
public AnalysisGraphConfigurationView(final ContainerPageObject parent) {
super(parent, "analysis");
}

/**
* Deactivates or activates the other trend graphs.
*
* @param shouldDisable determines if the other trend graphs should be deactivated
*/
public void deactiveOtherTrendGraphs(final boolean shouldDisable) {
canDeacticateOtherTrendGraphs.check(shouldDisable);
}
}
@@ -19,6 +19,7 @@
* @author Martin Kurz
*/
public abstract class AnalysisAction extends ContainerPageObject {
private final String pluginUrl;
private final ContainerPageObject parent;
private final String plugin;

@@ -29,7 +30,7 @@
* @param plugin plug-in name
*/
public AnalysisAction(final Build parent, final String plugin) {
this(plugin + "Result", parent);
this(plugin + "Result", plugin, parent);
}

/**
@@ -39,12 +40,22 @@ 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, parent);
this(plugin, plugin, parent);
}

private AnalysisAction(String url, ContainerPageObject parent) {
/**
* Returns the parent of this action.
*
* @return the parent
*/
protected ContainerPageObject getParent() {
return parent;
}

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

this.pluginUrl = pluginUrl;
this.parent = parent;
plugin = url;
}
@@ -428,6 +439,10 @@ public String getAnnotationName() {
return "warning";
}

public GraphConfigurationView configureTrendGraphForUser() {
return new GraphConfigurationView(parent, pluginUrl);
}

public enum Tab {
MODULES, FILES, PACKAGES, WARNINGS, DETAILS, FIXED, NEW, CATEGORIES, TYPES
}
@@ -0,0 +1,40 @@
package org.jenkinsci.test.acceptance.plugins.analysis_core;

import org.jenkinsci.test.acceptance.po.ContainerPageObject;
import org.jenkinsci.test.acceptance.po.Control;
import org.openqa.selenium.WebDriver;

/**
* Configuration screen of trend graphs.
*
* @author Ullrich Hafner
*/
public class GraphConfigurationView extends ContainerPageObject {
private final Control width = control("/width");
private final Control height = control("/height");
private final Control buildCount = control("/buildCountString");
private final Control dayCount = control("/dayCountString");
private final Control parameterName = control("/parameterName");
private final Control parameterValue = control("/parameterValue");
private final Control useBuildDateAsDomain = control("/useBuildDateAsDomain");
private final Control fixed = control("/graphType[FIXED]");

public GraphConfigurationView(final ContainerPageObject parent, final String plugin) {
super(parent, parent.url("%s/configure/", plugin));
}

/**
* Saves the trend graph configuration.
*/
public void save() {
clickButton("Save");
}

@Override
public WebDriver open() {
WebDriver open = super.open();

elasticSleep(1000); // trend graphs take some time to compute...
return open;
}
}
@@ -106,11 +106,11 @@ public void should_have_trend_graph_with_relative_links() {

AnalysisAction action = createProjectAction(job);

verifyTrendGraphOveriew(job, action);
verifyTrendGraphOverview(job, action);
verifyTrendGraphDetails(job, action);
}

private void verifyTrendGraphOveriew(final FreeStyleJob job, final AnalysisAction action) {
private void verifyTrendGraphOverview(final FreeStyleJob job, final AnalysisAction action) {
job.open();
assertThatProjectPageTrendIsCorrect(job, action, "");
}
@@ -1,9 +1,12 @@
package plugins;

import java.util.Map;

import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorAction;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorColumn;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorFreestyleBuildSettings;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisGraphConfigurationView;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisPlugin;
import org.jenkinsci.test.acceptance.plugins.analysis_collector.WarningsPerProjectPortlet;
import org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisConfigurator;
@@ -18,14 +21,15 @@
import org.jenkinsci.test.acceptance.po.Job;
import org.jenkinsci.test.acceptance.po.ListView;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.openqa.selenium.WebElement;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.jenkinsci.test.acceptance.Matchers.*;
import static org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisPlugin.*;
import static org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView.*;
import static org.jenkinsci.test.acceptance.po.PageObject.createRandomName;
import static org.junit.Assert.*;

/**
* Acceptance tests for the Static Code Analysis Collector (analysis-collector) plug-in.
@@ -77,6 +81,44 @@ protected int getNumberOfWarnings() {
return TOTAL;
}

/**
* Verifies that no other trend graphs are shown if configured in the graph configuration screen per user.
*/
@Test @Issue("JENKINS-30270")
public void should_deactivate_all_other_trend_graphs() {
FreeStyleJob job = createFreeStyleJob();

buildSuccessfulJob(job);
buildSuccessfulJob(job);

job.open();
elasticSleep(500);

assertThatNumberOfGraphsIs(job, 48);

AnalysisCollectorAction action = new AnalysisCollectorAction(job);
AnalysisGraphConfigurationView view = action.configureTrendGraphForUser();

deactivateOtherTrendGraphs(view, true);

assertThatNumberOfGraphsIs(job, 6);

deactivateOtherTrendGraphs(view, false);

assertThatNumberOfGraphsIs(job, 48);
}

private void deactivateOtherTrendGraphs(final AnalysisGraphConfigurationView view, final boolean shouldDisable) {
view.open();
view.deactiveOtherTrendGraphs(shouldDisable);
view.save();
}

private void assertThatNumberOfGraphsIs(final FreeStyleJob job, final int expectedCount) {
Map<String, Integer> trends = job.getTrendGraphContent(".*");
assertThat(trends.size(), is(expectedCount));
}

/**
* Verifies that the plugin correctly collects and aggregates the warnings of all participating plugins.
*/

0 comments on commit cbd19d9

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