use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method buildStatisticsPortlet_Percentage.
@Test
public void buildStatisticsPortlet_Percentage() {
DashboardView v = createDashboardView();
BuildStatisticsPortlet stats = v.addBottomPortlet(BuildStatisticsPortlet.class);
v.save();
FreeStyleJob success = createFreeStyleJob();
FreeStyleJob failing = createFailingFreeStyleJob();
FreeStyleJob unstable = createUnstableFreeStyleJob();
buildSuccessfulJob(success);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("100.0"));
buildFailingJob(failing);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("50.0"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("50.0"));
buildFailingJob(failing);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("33.33"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("66.67"));
buildUnstableJob(unstable);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("25.0"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("50.0"));
assertThat(stats.getPercentageOfBuilds(JobType.UNSTABLE), is("25.0"));
}
use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method createDashboardView.
/**
* Creates a default dashboard view matching all jobs.
*
* @return default dashboard view
*/
private DashboardView createDashboardView() {
DashboardView v = jenkins.views.create(DashboardView.class);
v.configure();
v.matchAllJobs();
return v;
}
use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method testStatisticsChart_failure.
@Test
public void testStatisticsChart_failure() throws IOException {
DashboardView v = createDashboardView();
TestStatisticsChartPortlet chart = v.addBottomPortlet(TestStatisticsChartPortlet.class);
v.save();
FreeStyleJob unstableFreeStyleJob = createUnstableFreeStyleJob();
buildUnstableJob(unstableFreeStyleJob);
v.open();
Map<Integer, Integer> colorsOccurrences = getColorDistributionOfSignificantColors(chart.getImage());
assertThat(colorsOccurrences.size(), is(1));
Integer color = colorsOccurrences.keySet().iterator().next();
int blueComp = (color << 24) >>> 24;
int greenComp = (color << 16) >>> 24;
int redComp = (color << 8) >>> 24;
assertThat(redComp, greaterThan(150));
assertThat(redComp, greaterThan(blueComp));
assertThat(redComp, greaterThan(greenComp));
}
use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method configureDashboardNameAndDescription.
@Test
public void configureDashboardNameAndDescription() {
final String name = "MyDashboard";
final String description = "My Description";
DashboardView v = jenkins.views.create(DashboardView.class, name);
v.configure(() -> {
v.mainArea.setName(name);
v.mainArea.setDescription(description);
});
createFreeStyleJob();
v.open();
final String url = getCurrentUrl();
assertThat(url, endsWith(name + "/"));
final List<String> breadCrumbs = v.breadCrumbs.getBreadCrumbs();
assertThat(breadCrumbs, hasSize(2));
final String nameCrumb = breadCrumbs.get(breadCrumbs.size() - 1);
assertThat(nameCrumb, is(name));
assertThat(v.mainPanel.getTabName(), equalToIgnoringCase(name));
assertThat(v.mainPanel.getDescription(), is(description));
}
use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method testStatisticsChart_success.
@Test
public void testStatisticsChart_success() throws IOException {
DashboardView v = createDashboardView();
TestStatisticsChartPortlet chart = v.addBottomPortlet(TestStatisticsChartPortlet.class);
v.save();
FreeStyleJob successJob = createFreeStyleJob(job -> {
String resultFileName = "status.xml";
job.addShellStep("echo '<testsuite><testcase classname=\"\">" + "</testcase></testsuite>'>" + resultFileName);
job.addPublisher(JUnitPublisher.class).testResults.set(resultFileName);
});
buildSuccessfulJob(successJob);
v.open();
Map<Integer, Integer> colorsOccurrences = getColorDistributionOfSignificantColors(chart.getImage());
assertThat(colorsOccurrences.size(), is(1));
Integer color = colorsOccurrences.keySet().iterator().next();
int blueComp = (color << 24) >>> 24;
int greenComp = (color << 16) >>> 24;
int redComp = (color << 8) >>> 24;
assertThat(blueComp, greaterThan(150));
assertThat(blueComp, greaterThan(greenComp));
assertThat(blueComp, greaterThan(redComp));
}
Aggregations