Search in sources :

Example 11 with Job

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

the class JobDslPluginTest method job_filters_include_jobs_built_at_least_once.

/**
 * This test creates 5 jobs and builds 3 of them immediately. A list view is created with its job filter set to only
 * include jobs that were built at least once.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_include_jobs_built_at_least_once() {
    List<Job> notBuiltJobs = createAmountOfJobs(2, false);
    List<Job> builtJobs = createAmountOfJobs(3, true);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "    buildTrend {\n" + "      matchType(MatchType.INCLUDE_MATCHED)\n" + "      buildCountType(BuildCountType.AT_LEAST_ONE)\n" + "    }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, not(containsJob(notBuiltJobs.get(0))));
    assertThat(view, not(containsJob(notBuiltJobs.get(1))));
    assertThat(view, containsJob(builtJobs.get(0)));
    assertThat(view, containsJob(builtJobs.get(1)));
    assertThat(view, containsJob(builtJobs.get(2)));
}
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 12 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_display_name.

/**
 * Tests whether a job display name is registered to a new job build by JobDsl
 * when the seed job is build.
 */
@Test
public void should_create_job_with_display_name() {
    // Arrange
    String jobName = "MyJob";
    String jobDisplayName = "My job display name";
    String jobDslScript = String.format("job('%s') { displayName('%s') }", jobName, jobDisplayName);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    // Assert
    Job job = jenkins.jobs.get(Job.class, jobName);
    job.open();
    assertThat(job.getDisplayName(), containsString(jobDisplayName));
}
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 13 with Job

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

the class JobDslPluginTest method job_filters_all_jobs_are_added.

/**
 * This test creates a listView and creates two additional jobs. The job filter of the script is set to "all jobs".
 * The two additional jobs as well as the seed job is added to the listView.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_all_jobs_are_added() {
    List<Job> jobs = createAmountOfJobs(2, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "        all()\n" + "  }\n" + "\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    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 14 with Job

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

the class JobDslPluginTest method should_create_build_with_environment_variable.

/**
 * Tests whether an environment variable is set to a build of a job created by JobDsl when
 * an environment variable is set to this job and the seed job and this job are build.
 */
@Test
@WithPlugins("envinject")
public void should_create_build_with_environment_variable() {
    // Arrange
    String jobName = "MyJob";
    String envVariableKey = "FOO";
    String envVariableValue = "test";
    String jobDslScript = String.format("job('%s') { environmentVariables(%s: '%s') }", jobName, envVariableKey, envVariableValue);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    Job job = jenkins.jobs.get(Job.class, jobName);
    Build build = job.startBuild().waitUntilFinished();
    // Assert
    build.open();
    driver.findElement(By.partialLinkText("Environment Variables")).click();
    assertThat(driver, hasElement(by.xpath(String.format("//tr/td[contains(text(), '%s')]", envVariableKey))));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) 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) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 15 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_sidebar_link.

/**
 * Tests whether a sidebar link is set to a job created by JobDsl when a link url and link label
 * are set to this job and the seed job is build.
 */
@Test
@WithPlugins("sidebar-link")
public void should_create_job_with_sidebar_link() {
    // Arrange
    String jobName = "MyJob";
    String linkUrl = "https://jenkins.io";
    String linkLabel = "jenkins.io";
    String jobDslScript = String.format("job('%s') { properties { sidebarLinks { link('%s', '%s') } } }", jobName, linkUrl, linkLabel);
    Job seed = createSeedJobWithJobDsl(jobDslScript);
    // Act
    seed.startBuild().waitUntilFinished();
    Job job = jenkins.jobs.get(Job.class, jobName);
    // Assert
    job.open();
    assertThat(driver, hasElement(by.href(linkUrl)));
}
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) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

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