Search in sources :

Example 16 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project promoted-builds-plugin by jenkinsci.

the class ItemPathResolverTest method shouldRetainTheLegacyBehaviorIfEnabled.

@Test
public void shouldRetainTheLegacyBehaviorIfEnabled() throws Exception {
    assertsPath("prj", null, projectInTop);
    // FOO exists on both top level and within the folder
    final MockFolder folder = rule.createFolder("F");
    final FreeStyleProject prjInRoot = rule.createFreeStyleProject("FOO");
    final FreeStyleProject prjInFolder = folder.createProject(FreeStyleProject.class, "FOO");
    // Raw addressing with different roots, should always point to the root
    assertsPath("FOO", null, prjInRoot);
    assertsPath("FOO", prjInRoot, prjInRoot);
    assertsPath("FOO", folder, prjInRoot);
    assertsPath("FOO", prjInFolder, prjInRoot);
}
Also used : MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 17 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class LinkResolverTest method runLinkResolveTest.

@Test
public void runLinkResolveTest() throws IOException, ExecutionException, InterruptedException {
    Project f = j.createFreeStyleProject("fstyle1");
    MockFolder folder1 = j.createFolder("folder1");
    Project p1 = folder1.createProject(FreeStyleProject.class, "test1");
    MockFolder folder2 = folder1.createProject(MockFolder.class, "folder2");
    MockFolder folder3 = folder2.createProject(MockFolder.class, "folder3");
    Project p2 = folder2.createProject(FreeStyleProject.class, "test2");
    Project p3 = folder3.createProject(FreeStyleProject.class, "test3");
    Run r = (Run) f.scheduleBuild2(0).get();
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/fstyle1/runs/" + r.getId() + "/", LinkResolver.resolveLink(r).getHref());
    r = (Run) p1.scheduleBuild2(0).get();
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/test1/runs/" + r.getId() + "/", LinkResolver.resolveLink(r).getHref());
    r = (Run) p2.scheduleBuild2(0).get();
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/test2/runs/" + r.getId() + "/", LinkResolver.resolveLink(r).getHref());
    r = (Run) p3.scheduleBuild2(0).get();
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/folder3/pipelines/test3/runs/" + r.getId() + "/", LinkResolver.resolveLink(r).getHref());
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Run(hudson.model.Run) MockFolder(org.jvnet.hudson.test.MockFolder) Test(org.junit.Test)

Example 18 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class LinkResolverTest method nestedFolderJobLinkResolveTest.

@Test
public void nestedFolderJobLinkResolveTest() throws IOException {
    Project f = j.createFreeStyleProject("fstyle1");
    MockFolder folder1 = j.createFolder("folder1");
    Project p1 = folder1.createProject(FreeStyleProject.class, "test1");
    MockFolder folder2 = folder1.createProject(MockFolder.class, "folder2");
    MockFolder folder3 = folder2.createProject(MockFolder.class, "folder3");
    Project p2 = folder2.createProject(FreeStyleProject.class, "test2");
    Project p3 = folder3.createProject(FreeStyleProject.class, "test3");
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/fstyle1/", LinkResolver.resolveLink(f).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/", LinkResolver.resolveLink(folder1).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/test1/", LinkResolver.resolveLink(p1).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/", LinkResolver.resolveLink(folder2).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/test2/", LinkResolver.resolveLink(p2).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/folder3/", LinkResolver.resolveLink(folder3).getHref());
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/folder2/pipelines/folder3/pipelines/test3/", LinkResolver.resolveLink(p3).getHref());
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) MockFolder(org.jvnet.hudson.test.MockFolder) Test(org.junit.Test)

Example 19 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method linkStartLimitTest.

@Test
public void linkStartLimitTest() throws IOException, UnirestException {
    MockFolder folder = j.createFolder("folder1");
    Project p = folder.createProject(FreeStyleProject.class, "test1");
    HttpResponse<String> response = Unirest.get(getBaseUrl("/organizations/jenkins/pipelines/folder1/pipelines/")).header("Accept-Encoding", "").header("Authorization", "Bearer " + jwtToken).asString();
    String link = response.getHeaders().get("Link").get(0);
    assertEquals("</jenkins/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/?start=100&limit=100>; rel=\"next\"", link);
    response = Unirest.get(getBaseUrl("/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject,hudson.matrix.MatrixProject&filter1=no-folders&start=0&limit=26")).header("Accept-Encoding", "").header("Authorization", "Bearer " + jwtToken).asString();
    link = response.getHeaders().get("Link").get(0);
    assertEquals("</jenkins/blue/rest/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject,hudson.matrix.MatrixProject&filter1=no-folders&start=26&limit=26>; rel=\"next\"", link);
    response = Unirest.get(getBaseUrl("/organizations/jenkins/pipelines/folder1/pipelines/?start=10&limit=10&foo=bar")).header("Accept-Encoding", "").header("Authorization", "Bearer " + jwtToken).asString();
    link = response.getHeaders().get("Link").get(0);
    assertEquals("</jenkins/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/?foo=bar&start=20&limit=10>; rel=\"next\"", link);
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) MockFolder(org.jvnet.hudson.test.MockFolder) Test(org.junit.Test)

Example 20 with MockFolder

use of org.jvnet.hudson.test.MockFolder in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getFolderPipelineTest.

@Test
public void getFolderPipelineTest() throws IOException {
    MockFolder folder = j.createFolder("folder1");
    Project p = folder.createProject(FreeStyleProject.class, "test1");
    Map response = get("/organizations/jenkins/pipelines/folder1/pipelines/test1");
    validatePipeline(p, response);
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) MockFolder(org.jvnet.hudson.test.MockFolder) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 MockFolder (org.jvnet.hudson.test.MockFolder)22 FreeStyleProject (hudson.model.FreeStyleProject)18 Project (hudson.model.Project)11 ImmutableMap (com.google.common.collect.ImmutableMap)10 Map (java.util.Map)10 FreeStyleBuild (hudson.model.FreeStyleBuild)4 BranchSource (jenkins.branch.BranchSource)4 DefaultBranchPropertyStrategy (jenkins.branch.DefaultBranchPropertyStrategy)4 GitSCMSource (jenkins.plugins.git.GitSCMSource)4 SCMSource (jenkins.scm.api.SCMSource)4 WorkflowMultiBranchProject (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject)4 User (hudson.model.User)3 ImmutableList (com.google.common.collect.ImmutableList)2 EnvVars (hudson.EnvVars)2 Action (hudson.model.Action)2 ParameterValue (hudson.model.ParameterValue)2 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)2 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)2 LegacyAuthorizationStrategy (hudson.security.LegacyAuthorizationStrategy)2