Search in sources :

Example 6 with Job

use of org.jenkinsci.test.acceptance.po.Job 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 7 with Job

use of org.jenkinsci.test.acceptance.po.Job 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)

Example 8 with Job

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

the class JobDslPluginTest method should_create_job_with_description.

/**
 * Tests whether a job description is registered to a new job build by JobDsl
 * when the seed job is build.
 */
@Test
public void should_create_job_with_description() {
    // Arrange
    String jobName = "MyJob";
    String jobDescription = "My sample despription";
    String jobDslScript = String.format("job('%s') { description('%s') }", jobName, jobDescription);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    // Assert
    Job job = jenkins.jobs.get(Job.class, jobName);
    job.open();
    assertThat(job.getDescription(), containsString(jobDescription));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 9 with Job

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

the class JobDslPluginTest method should_not_find_build_button.

/**
 * Tests whether a disabled job created by JobDsl doesn't offer an opportunity
 * to start the build process and throws an NoSuchElementException when the job
 * is tried to build.
 */
@Test(expected = NoSuchElementException.class)
public void should_not_find_build_button() {
    // Arrange
    String jobName = "MyJob";
    String jobDslScript = String.format("job('%s') { disabled() }", jobName);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    Job job = jenkins.jobs.get(Job.class, jobName);
    job.startBuild().waitUntilFinished();
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 10 with Job

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

the class JobDslPluginTest method should_create_job_with_label.

/**
 * Tests whether a label is set to a job created by JobDsl when a label text is set
 * to this job and the seed job is build.
 */
@Test
public void should_create_job_with_label() {
    // Arrange
    String jobName = "MyJob";
    String jobLabel = "x86 && ubuntu";
    String jobDslScript = String.format("job('%s') { label('%s') }", jobName, jobLabel);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    // Assert
    Job job = jenkins.jobs.get(Job.class, jobName);
    job.open();
    job.configure();
    WebElement labelElement = driver.findElement(By.xpath("//input[@name='_.label']"));
    assertEquals(jobLabel, labelElement.getAttribute("value"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WebElement(org.openqa.selenium.WebElement) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

Job (org.jenkinsci.test.acceptance.po.Job)55 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)48 Test (org.junit.Test)45 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)37 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)22 ListView (org.jenkinsci.test.acceptance.po.ListView)21 View (org.jenkinsci.test.acceptance.po.View)18 Build (org.jenkinsci.test.acceptance.po.Build)13 WebElement (org.openqa.selenium.WebElement)7 IOException (java.io.IOException)5 GerritTriggerJob (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerJob)5 GerritTriggerNewServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerNewServer)5 GerritTriggerServer (org.jenkinsci.test.acceptance.plugins.gerrit_trigger.GerritTriggerServer)5 GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)5 Since (org.jenkinsci.test.acceptance.junit.Since)4 AnalysisAction (org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction)4 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)4 Issue (org.jvnet.hudson.test.Issue)4 Arrays (java.util.Arrays)3