Skip to content

Commit

Permalink
[FIXED JENKINS-20339] reverting pull request 5, which enables Jenkins…
Browse files Browse the repository at this point in the history
… to filter by execution status
  • Loading branch information
kinow committed Nov 14, 2013
1 parent 344c91d commit 1f80f15
Show file tree
Hide file tree
Showing 13 changed files with 905 additions and 1,297 deletions.
742 changes: 299 additions & 443 deletions src/main/java/hudson/plugins/testlink/AbstractTestLinkBuilder.java

Large diffs are not rendered by default.

200 changes: 97 additions & 103 deletions src/main/java/hudson/plugins/testlink/GraphHelper.java
Expand Up @@ -24,111 +24,105 @@
import org.kohsuke.stapler.StaplerResponse;

/**
* Helper class for trend graph generation.
* Helper class for trend graph generation.
*
* @author TestNG plug-in
* @author TestNG plug-in
* @since 1.0
*/
public class GraphHelper
{

/**
* Do not instantiate GraphHelper.
*/
private GraphHelper()
{
super();
}

public static void redirectWhenGraphUnsupported( StaplerResponse rsp,
StaplerRequest req ) throws IOException
{
// not available. send out error message
rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
}

public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {

final JFreeChart chart = ChartFactory.createStackedAreaChart(
null, // chart title
null, // unused
"TestLink Tests Count", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);

// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
final LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);

chart.setBackgroundPaint(Color.white);

final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setForegroundAlpha(0.8f);
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);

CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);

final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

StackedAreaRenderer ar = new StackedAreaRenderer2() {
private static final long serialVersionUID = 331915263367089058L;

@Override
public String generateURL(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
//return label.build.getNumber() + "/" + PluginImpl.URL + "/";
return label.build.getNumber() + "/" + TestLinkBuildAction.URL_NAME;
}

@Override
public String generateToolTip(CategoryDataset dataset, int row, int column)
{
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
TestLinkBuildAction build = label.build.getAction(TestLinkBuildAction.class);
TestLinkResult result = build.getResult();
Report report = result.getReport();

switch (row) {
case 0:
return String.valueOf(report.getBlocked()) + " Blocked";
case 1:
return String.valueOf(report.getFailed()) + " Failed";
case 2:
return String.valueOf(report.getNotRun()) + " Not Run";
case 3:
return String.valueOf(report.getPassed()) + " Passed";
default:
return "";
}
}

};

plot.setRenderer(ar);
ar.setSeriesPaint(0, ColorPalette.YELLOW); // Blocked
ar.setSeriesPaint(1, ColorPalette.RED); // Failures
ar.setSeriesPaint(2, ColorPalette.GREY); // Not Run
ar.setSeriesPaint(3, ColorPalette.BLUE); // Pass

// crop extra space around the graph
plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

return chart;
}
public class GraphHelper {

/**
* Do not instantiate GraphHelper.
*/
private GraphHelper() {
super();
}

public static void redirectWhenGraphUnsupported(StaplerResponse rsp, StaplerRequest req) throws IOException {
// not available. send out error message
rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
}

public static JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {

final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart title
null, // unused
"TestLink Tests Count", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);

// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
final LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.RIGHT);

chart.setBackgroundPaint(Color.white);

final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setForegroundAlpha(0.8f);
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);

CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);

final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

StackedAreaRenderer ar = new StackedAreaRenderer2() {
private static final long serialVersionUID = 331915263367089058L;

@Override
public String generateURL(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
// return label.build.getNumber() + "/" + PluginImpl.URL + "/";
return label.build.getNumber() + "/" + TestLinkBuildAction.URL_NAME;
}

@Override
public String generateToolTip(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
TestLinkBuildAction build = label.build.getAction(TestLinkBuildAction.class);
TestLinkResult result = build.getResult();
Report report = result.getReport();

switch (row) {
case 0:
return String.valueOf(report.getBlocked()) + " Blocked";
case 1:
return String.valueOf(report.getFailed()) + " Failed";
case 2:
return String.valueOf(report.getNotRun()) + " Not Run";
case 3:
return String.valueOf(report.getPassed()) + " Passed";
default:
return "";
}
}

};

plot.setRenderer(ar);
ar.setSeriesPaint(0, ColorPalette.YELLOW); // Blocked
ar.setSeriesPaint(1, ColorPalette.RED); // Failures
ar.setSeriesPaint(2, ColorPalette.GREY); // Not Run
ar.setSeriesPaint(3, ColorPalette.BLUE); // Pass

// crop extra space around the graph
plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

return chart;
}

}

0 comments on commit 1f80f15

Please sign in to comment.