use of hudson.model.Project in project blueocean-plugin by jenkinsci.
the class FavoritesApiTest method testFavoritePagination.
@Test
public void testFavoritePagination() throws IOException, Favorites.FavoriteException {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
hudson.model.User user = User.get("alice");
Project job1 = j.createFreeStyleProject("job1");
Project job2 = j.createFreeStyleProject("job2");
Favorites.addFavorite(user, job1);
Favorites.addFavorite(user, job2);
List<Map> favorites = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").auth("alice", "alice").build(List.class);
assertEquals(2, favorites.size());
favorites = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/?limit=1").auth("alice", "alice").build(List.class);
assertEquals(1, favorites.size());
}
use of hudson.model.Project in project blueocean-plugin by jenkinsci.
the class FavoritesApiTest method createAndFavorite.
private Project createAndFavorite(String jobName, String username, String password) throws IOException {
Project project = j.createFreeStyleProject(jobName);
new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/" + jobName + "/favorite/").auth(username, password).data(ImmutableMap.of("favorite", true)).build(Map.class);
return project;
}
use of hudson.model.Project in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method findAllPipelineByGlob.
@Test
public void findAllPipelineByGlob() throws IOException, ExecutionException, InterruptedException {
MockFolder folder1 = j.createFolder("folder1");
j.createFolder("afolder");
Project p1 = folder1.createProject(FreeStyleProject.class, "test1");
MockFolder folder2 = folder1.createProject(MockFolder.class, "folder2");
folder1.createProject(MockFolder.class, "folder3");
folder2.createProject(FreeStyleProject.class, "test2");
folder2.createProject(FreeStyleProject.class, "coolPipeline");
List<Map> resp = get("/search?q=type:pipeline;pipeline:*TEST*", List.class);
assertEquals(2, resp.size());
resp = get("/search?q=type:pipeline;pipeline:*cool*", List.class);
assertEquals(1, resp.size());
resp = get("/search?q=type:pipeline;pipeline:*nothing*", List.class);
assertEquals(0, resp.size());
resp = get("/search?q=type:pipeline;pipeline:*f*", List.class);
assertEquals(7, resp.size());
}
use of hudson.model.Project in project blueocean-plugin by jenkinsci.
the class ProfileApiTest method createUserFavouriteFolderTest.
// TODO: migrate to FavoritesApiTest after PR receives initial approval (trying to cut down on PR noise)
@Test
public void createUserFavouriteFolderTest() throws Exception {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
hudson.model.User user = User.get("alice");
user.setFullName("Alice Cooper");
MockFolder folder1 = j.createFolder("folder1");
Project p = folder1.createProject(FreeStyleProject.class, "pipeline1");
// String token = getJwtToken(j.jenkins,"alice", "alice");
Map map = new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/pipelines/pipeline1/favorite/").authAlice().data(ImmutableMap.of("favorite", true)).build(Map.class);
validatePipeline(p, (Map) map.get("item"));
List l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(1, l.size());
Map pipeline = (Map) ((Map) l.get(0)).get("item");
validatePipeline(p, pipeline);
String href = getHrefFromLinks((Map) l.get(0), "self");
assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/pipeline1/favorite/", href);
map = new RequestBuilder(baseUrl).put(href.substring("/blue/rest".length())).authAlice().data(ImmutableMap.of("favorite", false)).build(Map.class);
validatePipeline(p, (Map) map.get("item"));
l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(0, l.size());
new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/favorite/").authAlice().data(ImmutableMap.of("favorite", true)).status(405).build(Map.class);
new RequestBuilder(baseUrl).put("/organizations/jenkins/pipelines/folder1/favorite/").authAlice().data(ImmutableMap.of("favorite", false)).status(405).build(Map.class);
l = new RequestBuilder(baseUrl).get("/users/" + user.getId() + "/favorites/").authAlice().build(List.class);
assertEquals(0, l.size());
}
use of hudson.model.Project 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());
}
Aggregations