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());
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations