Search in sources :

Example 16 with DashboardView

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"));
}
Also used : BuildStatisticsPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.BuildStatisticsPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 17 with DashboardView

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;
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)

Example 18 with DashboardView

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));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TestStatisticsChartPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet) Test(org.junit.Test)

Example 19 with DashboardView

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));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) Test(org.junit.Test)

Example 20 with DashboardView

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));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TestStatisticsChartPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet) Test(org.junit.Test)

Aggregations

DashboardView (org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)35 Test (org.junit.Test)32 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)16 BuildStatisticsPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.BuildStatisticsPortlet)7 JobsGridPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.JobsGridPortlet)4 LatestBuildsPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.LatestBuildsPortlet)4 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)3 TestStatisticsChartPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet)3 UnstableJobsPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.UnstableJobsPortlet)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 NestedView (org.jenkinsci.test.acceptance.plugins.nested_view.NestedView)2 Build (org.jenkinsci.test.acceptance.po.Build)2 Folder (org.jenkinsci.test.acceptance.po.Folder)2 Issue (org.jvnet.hudson.test.Issue)2 Description (org.hamcrest.Description)1 Matcher (org.jenkinsci.test.acceptance.Matcher)1 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)1 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)1 AnalysisPlugin (org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisPlugin)1