Search in sources :

Example 11 with Project

use of hudson.model.Project 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 12 with Project

use of hudson.model.Project 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 13 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getFreeStyleJobTest.

@Test
public void getFreeStyleJobTest() throws Exception {
    Project p1 = j.createFreeStyleProject("pipeline1");
    Project p2 = j.createFreeStyleProject("pipeline2");
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = (FreeStyleBuild) p1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
    List<Map> resp = get("/organizations/jenkins/pipelines/", List.class);
    Project[] projects = { p1, p2 };
    assertEquals(projects.length, resp.size());
    for (int i = 0; i < projects.length; i++) {
        Map p = resp.get(i);
        validatePipeline(projects[i], p);
    }
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 14 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method findPipelinesTest.

@Test
public void findPipelinesTest() throws IOException {
    FreeStyleProject p1 = j.createFreeStyleProject("pipeline2");
    FreeStyleProject p2 = j.createFreeStyleProject("pipeline3");
    List<Map> resp = get("/search?q=type:pipeline;organization:jenkins", List.class);
    Project[] projects = { p1, p2 };
    assertEquals(projects.length, resp.size());
    for (int i = 0; i < projects.length; i++) {
        Map p = resp.get(i);
        validatePipeline(projects[i], p);
    }
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 15 with Project

use of hudson.model.Project in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getPipelinesTest.

@Test
public void getPipelinesTest() throws Exception {
    Project p2 = j.createFreeStyleProject("pipeline2");
    Project p1 = j.createFreeStyleProject("pipeline1");
    List<Map> responses = get("/search/?q=type:pipeline", List.class);
    assertEquals(2, responses.size());
    validatePipeline(p1, responses.get(0));
    validatePipeline(p2, responses.get(1));
    p1.getBuildersList().add(new Shell("echo hello!\nsleep 1"));
    FreeStyleBuild b = (FreeStyleBuild) p1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b);
}
Also used : Project(hudson.model.Project) FreeStyleProject(hudson.model.FreeStyleProject) Shell(hudson.tasks.Shell) FreeStyleBuild(hudson.model.FreeStyleBuild) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

Project (hudson.model.Project)25 Test (org.junit.Test)23 FreeStyleProject (hudson.model.FreeStyleProject)22 ImmutableMap (com.google.common.collect.ImmutableMap)14 Map (java.util.Map)14 MockFolder (org.jvnet.hudson.test.MockFolder)13 List (java.util.List)7 ImmutableList (com.google.common.collect.ImmutableList)5 User (hudson.model.User)4 FreeStyleBuild (hudson.model.FreeStyleBuild)3 Shell (hudson.tasks.Shell)2 BaseTest (io.jenkins.blueocean.service.embedded.BaseTest)2 AbstractProject (hudson.model.AbstractProject)1 Item (hudson.model.Item)1 Run (hudson.model.Run)1 HudsonPrivateSecurityRealm (hudson.security.HudsonPrivateSecurityRealm)1 LegacyAuthorizationStrategy (hudson.security.LegacyAuthorizationStrategy)1 BlueTrendFactory (io.jenkins.blueocean.rest.factory.BlueTrendFactory)1 BlueOrganization (io.jenkins.blueocean.rest.model.BlueOrganization)1 BluePipeline (io.jenkins.blueocean.rest.model.BluePipeline)1