Search in sources :

Example 11 with ListView

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

the class JobDslPluginTest method should_ignore_existing_views.

/**
 * Verifies whether previously generated views will be ignored or updated.
 * By default, all previous generated views will be updated.
 * If existing views should be ignored, the plugin do not modify previous
 * generated views.
 */
@Test
public void should_ignore_existing_views() {
    FreeStyleJob seedJob = createSeedJob();
    JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
    jobDsl.setScript("listView('Existing_View') {\n" + "   description('Existing description');\n" + "}");
    seedJob.save();
    seedJob.scheduleBuild().shouldSucceed();
    ListView existingView = getView("Existing_View");
    seedJob.configure(() -> {
        jobDsl.setScript("listView('Existing_View') {\n" + "   description('This is a description');\n" + "}");
        jobDsl.setIgnoreExisting(true);
    });
    Build build = seedJob.scheduleBuild().shouldSucceed();
    Pattern expected = Pattern.compile("Existing views:(\\s*)GeneratedView[{]name='Existing_View'}");
    assertThat(build.getConsole(), containsRegexp(expected));
    checkDescription(existingView, "Existing description");
    seedJob.configure(() -> jobDsl.setIgnoreExisting(false));
    Build build2 = seedJob.scheduleBuild().shouldSucceed();
    assertThat(build2.getConsole(), containsRegexp(expected));
    checkDescription(existingView, "This is a description");
}
Also used : Pattern(java.util.regex.Pattern) JobDslBuildStep(org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep) ListView(org.jenkinsci.test.acceptance.po.ListView) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 12 with ListView

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

the class JobDslPluginTest method should_delete_removed_views.

/**
 * Verifies whether a previously generated view will be deleted if it
 * is not referenced anymore.
 */
@Test
public void should_delete_removed_views() {
    FreeStyleJob seedJob = executeRemovedViewAction(JobDslRemovedViewAction.DELETE);
    Build build = seedJob.scheduleBuild().shouldSucceed();
    Pattern expected = Pattern.compile("Unreferenced views:(\\s*)GeneratedView[{]name='Old_View'}(\\s*)Removed views:(\\s*)GeneratedView[{]name='Old_View'}");
    assertThat(build.getConsole(), containsRegexp(expected));
    ListView oldView = getView("Old_View");
    assertThat(oldView, pageObjectDoesNotExist());
}
Also used : Pattern(java.util.regex.Pattern) ListView(org.jenkinsci.test.acceptance.po.ListView) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 13 with ListView

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

the class ViewTest method renameJob.

@Test
@Category(SmokeTest.class)
public void renameJob() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "original_name");
    ListView view = jenkins.views.create(ListView.class, "a_view");
    view.configure();
    view.check(job.name);
    view.save();
    assertThat(view, containsJob(job));
    job = job.renameTo("new_name");
    assertThat(view, containsJob(job));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Category(org.junit.experimental.categories.Category) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) SmokeTest(org.jenkinsci.test.acceptance.junit.SmokeTest) Test(org.junit.Test)

Example 14 with ListView

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

the class ViewTest method findJobThroughRegexp.

@Test
@Category(SmokeTest.class)
public void findJobThroughRegexp() {
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, "my_name");
    ListView view = jenkins.views.create(ListView.class, "a_view");
    view.configure();
    view.check("Use a regular expression to include jobs into the view");
    fillIn("includeRegex", "my.*");
    view.save();
    assertThat(view, containsJob(job));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Category(org.junit.experimental.categories.Category) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) SmokeTest(org.jenkinsci.test.acceptance.junit.SmokeTest) Test(org.junit.Test)

Example 15 with ListView

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

the class FormValidationTest method ajaxValidation.

private void ajaxValidation() {
    ListView lv = jenkins.views.create(ListView.class);
    lv.configure();
    lv.matchJobs(".*");
    assertThat(lv.includeRegex.getFormValidation(), silent());
    lv.matchJobs("[");
    assertThat(lv.includeRegex.getFormValidation().getKind(), equalTo(Kind.ERROR));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView)

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