Search in sources :

Example 1 with DashboardView

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method addDashboardViewAndBottomPortlet.

/**
 * Creates a new Dashboard-View and adds the given portlet as "bottom portlet".
 *
 * @param <T>     the type constraint of the portlet
 * @param portlet the portlet to add
 * @param owner   the owner of the view
 * @return The view.
 */
protected <T extends AbstractDashboardViewPortlet> DashboardView addDashboardViewAndBottomPortlet(final Class<T> portlet, final Container owner) {
    DashboardView view = createNewViewForAllJobs(DashboardView.class, owner);
    view.addBottomPortlet(portlet);
    view.save();
    return view;
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)

Example 2 with DashboardView

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.

the class AnalysisCollectorPluginTest method should_aggregate_warnings_in_dashboard_portlet.

/**
 * Sets up a dashboard view with a warnings-per-project portlet. Builds a job and checks if the portlet shows the
 * correct number of warnings. Then one of the tools is deselected. The portlet should then show only the remaining
 * number of warnings.
 */
@Test
@WithPlugins("dashboard-view")
public void should_aggregate_warnings_in_dashboard_portlet() {
    // avoid JENKINS-49026
    checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);
    FreeStyleJob job = createFreeStyleJob();
    buildSuccessfulJob(job);
    DashboardView dashboard = jenkins.views.create(DashboardView.class, createRandomName());
    dashboard.configure();
    dashboard.matchAllJobs();
    WarningsPerProjectPortlet portlet = addWarningsPortlet(dashboard);
    dashboard.save();
    dashboard.open();
    verifyWarningsCountInPortlet(job.name, dashboard);
    // uncheck Open Tasks
    dashboard.configure(() -> portlet.checkCollectedPlugin(TASKS, false));
    dashboard.open();
    assertThat(dashboard, not(hasWarnings(job.name, TASKS.getId(), TASKS_ALL)));
}
Also used : WarningsPerProjectPortlet(org.jenkinsci.test.acceptance.plugins.analysis_collector.WarningsPerProjectPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 3 with DashboardView

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.

the class AnalysisCollectorPluginTest method hasWarnings.

public static Matcher<DashboardView> hasWarnings(final String jobName, final String pluginId, final int warningsCount) {
    return new Matcher<DashboardView>(" shows %s warnings for plugin %s and job %s", warningsCount, pluginId, jobName) {

        @Override
        public boolean matchesSafely(final DashboardView view) {
            view.open();
            try {
                WebElement warningsLink = findPortletLink(view, jobName, pluginId);
                String linkText = warningsLink.getText();
                return Integer.parseInt(linkText) == warningsCount;
            } catch (NoSuchElementException | NumberFormatException e) {
                return false;
            }
        }

        @Override
        public void describeMismatchSafely(final DashboardView view, final Description desc) {
            desc.appendText("Portlet does not show expected warnings for plugin " + pluginId);
        }
    };
}
Also used : Description(org.hamcrest.Description) Matcher(org.jenkinsci.test.acceptance.Matcher) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 4 with DashboardView

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.

the class DashboardViewPluginTest method jobsGridPortlet_notFillColumnsFirst.

@Test
public void jobsGridPortlet_notFillColumnsFirst() {
    createFreeStyleJob();
    createFreeStyleJob();
    createFreeStyleJob();
    createFreeStyleJob();
    DashboardView v = createDashboardView();
    JobsGridPortlet jobsGridPortlet = v.addBottomPortlet(JobsGridPortlet.class);
    jobsGridPortlet.setNumberOfColumns(3);
    jobsGridPortlet.setFillColumnFirst(false);
    v.save();
    assertThat(jobsGridPortlet.getJob(1, 3), notNullValue());
    assertThat(jobsGridPortlet.getJob(2, 2), nullValue());
}
Also used : JobsGridPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.JobsGridPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) Test(org.junit.Test)

Example 5 with DashboardView

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView in project acceptance-test-harness by jenkinsci.

the class DashboardViewPluginTest method jobsGridPortlet_invalidNumberOfColumn.

@Test
public void jobsGridPortlet_invalidNumberOfColumn() {
    // One job is required for the portlet to be displayed
    createFreeStyleJob();
    DashboardView v = createDashboardView();
    JobsGridPortlet jobsGridPortlet = v.addBottomPortlet(JobsGridPortlet.class);
    jobsGridPortlet.setNumberOfColumns(2);
    v.save();
    expectedException.expect(NoSuchElementException.class);
    jobsGridPortlet.getJob(1, 3);
}
Also used : JobsGridPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.JobsGridPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) 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