Search in sources :

Example 1 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class AnalysisCollectorPluginTest method should_set_warnings_count_in_list_view_column.

/**
 * Sets up a list view with a warnings column. Builds a job and checks if the column shows the correct number of
 * warnings and provides a direct link to the actual warning results. Also verifies that the mouse-over tooltip will
 * show the correct number of warnings per checked plugin.
 */
@Test
public void should_set_warnings_count_in_list_view_column() {
    FreeStyleJob job = createFreeStyleJob();
    buildSuccessfulJob(job);
    ListView view = jenkins.views.create(ListView.class, "list");
    view.configure();
    view.matchAllJobs();
    view.addColumn(AnalysisCollectorColumn.class);
    view.save();
    view.open();
    WebElement warningsCell = view.find(by.xpath(XPATH_LISTVIEW_WARNING_TD));
    assertThat(warningsCell.getText(), is(String.valueOf(TOTAL)));
    String tooltip = warningsCell.getAttribute("tooltip");
    assertThat(tooltip, allOf(containsString("<a href=\"view/list/job/" + job.name + "/checkstyle\">" + CHECKSTYLE_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/findbugs\">" + FINDBUGS_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/pmd\">" + PMD_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/warnings\">" + WARNINGS_ALL + "</a>")));
    view.configure();
    AnalysisCollectorColumn column = view.getColumn(AnalysisCollectorColumn.class);
    column.checkPlugin(PMD, false);
    view.save();
    view.open();
    // check that PMD warnings are not collected to total warning number and tooltip
    warningsCell = view.find(by.xpath(XPATH_LISTVIEW_WARNING_TD));
    assertThat(warningsCell.getText(), is(String.valueOf(TOTAL - PMD_ALL)));
    tooltip = warningsCell.getAttribute("tooltip");
    assertThat(tooltip, not(containsString("<a href=\"job/" + job.name + "/pmd\">" + PMD_ALL + "</a>")));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AnalysisCollectorColumn(org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorColumn) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 2 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_status_failed_exclude_unmatched.

/**
 * This test creates a job and runs a build which fails. Afterwards 4 new jobs get created as well as a listView.
 * The job filter of the listView is set to not show jobs which build status is not 'FAILED'.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_exclude_unmatched() {
    Job failedJob = createJobThatFails();
    List<Job> jobs = createAmountOfJobs(4, true);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs{\n" + "    names('" + failedJob.name + "','" + jobs.get(0).name + "','" + jobs.get(1).name + "','" + jobs.get(2).name + "','" + jobs.get(3).name + "')\n" + "  }\n" + "  jobFilters {\n" + "        status {\n" + "            matchType(MatchType.EXCLUDE_UNMATCHED)\n" + "            status(Status.FAILED)\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsJob(failedJob));
    assertThat(view, not(containsJob(jobs.get(0))));
    assertThat(view, not(containsJob(jobs.get(1))));
    assertThat(view, not(containsJob(jobs.get(2))));
    assertThat(view, not(containsJob(jobs.get(3))));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 3 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_regex_name_include_unmatched.

/**
 * This test creates a listView and 4 jobs. The job filters are checking the name with a regex and
 * jobs not matching the regex are included in the listView.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_regex_name_include_unmatched() {
    Job job1 = createJobWithName(EXAMPLE_DISABLED_NAME);
    Job job2 = createJobWithName(EXAMPLE_ENABLED_NAME);
    List<Job> jobs = createAmountOfJobs(2, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "        regex {\n" + "            matchType(MatchType.INCLUDE_UNMATCHED)\n" + "            matchValue(RegexMatchValue.NAME)\n" + "            regex('" + LIST_VIEW_REGEX + "')\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(job1)));
    assertThat(view, not(containsJob(job2)));
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 4 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_status_failed_include_unmatched.

/**
 * This test creates a job and runs a build which fails. Afterwards 4 new jobs get created as well as a listView.
 * The job filter of the listView is set to show jobs which build status is not 'FAILED'.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_include_unmatched() {
    Job failedJob = createJobThatFails();
    List<Job> jobs = createAmountOfJobs(4, true);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "        status {\n" + "            matchType(MatchType.INCLUDE_UNMATCHED)\n" + "            status(Status.FAILED)\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(failedJob)));
    assertThat(view, containsJob(jobs.get(0)));
    assertThat(view, containsJob(jobs.get(1)));
    assertThat(view, containsJob(jobs.get(2)));
    assertThat(view, containsJob(jobs.get(3)));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 5 with ListView

use of org.jenkinsci.test.acceptance.po.ListView in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_regex_name_include_matched.

/**
 * This test creates a listView and 4 jobs. The job filters are checking the name with a regex and
 * jobs matching the regex are included in the listView.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_regex_name_include_matched() {
    Job job1 = createJobWithName(EXAMPLE_DISABLED_NAME);
    Job job2 = createJobWithName(EXAMPLE_ENABLED_NAME);
    List<Job> jobs = createAmountOfJobs(2, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "        regex {\n" + "            matchType(MatchType.INCLUDE_MATCHED)\n" + "            matchValue(RegexMatchValue.NAME)\n" + "            regex('" + LIST_VIEW_REGEX + "')\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsJob(job1));
    assertThat(view, containsJob(job2));
    assertThat(view, not(containsJob(jobs.get(0))));
    assertThat(view, not(containsJob(jobs.get(1))));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

ListView (org.jenkinsci.test.acceptance.po.ListView)31 Test (org.junit.Test)28 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)27 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)26 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 View (org.jenkinsci.test.acceptance.po.View)20 Job (org.jenkinsci.test.acceptance.po.Job)18 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)13 Build (org.jenkinsci.test.acceptance.po.Build)4 Pattern (java.util.regex.Pattern)3 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)3 Category (org.junit.experimental.categories.Category)2 WebElement (org.openqa.selenium.WebElement)2 URL (java.net.URL)1 AnalysisCollectorColumn (org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorColumn)1 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)1 BuildWithParameters (org.jenkinsci.test.acceptance.po.BuildWithParameters)1 MatrixProject (org.jenkinsci.test.acceptance.po.MatrixProject)1 StringParameter (org.jenkinsci.test.acceptance.po.StringParameter)1 Issue (org.jvnet.hudson.test.Issue)1