use of hudson.matrix.MatrixProject in project blueocean-plugin by jenkinsci.
the class PipelineApiTest method matrixProjectTest.
@Test
public void matrixProjectTest() throws Exception {
MatrixProject mp = j.jenkins.createProject(MatrixProject.class, "mp1");
mp.getAxes().add(new Axis("os", "linux", "windows"));
mp.getAxes().add(new Axis("jdk", "1.7", "1.8"));
MatrixBuild matrixBuild = mp.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(matrixBuild);
List<Map> pipelines = get("/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject,hudson.matrix.MatrixProject", List.class);
Assert.assertEquals(1, pipelines.size());
Map p = pipelines.get(0);
Assert.assertEquals("mp1", p.get("name"));
String href = getHrefFromLinks(p, "self");
Assert.assertEquals("/job/mp1/", href);
}
use of hudson.matrix.MatrixProject in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testOnCopiedFrom.
@Test
public void testOnCopiedFrom() {
Hudson hudson = createMock(Hudson.class);
AuthorizationStrategy authorizationStrategy = createMock(ProjectMatrixAuthorizationStrategy.class);
expect(hudson.getAuthorizationStrategy()).andReturn(authorizationStrategy);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
User user = createMock(User.class);
expect(user.getId()).andReturn(USER).times(2);
mockStatic(User.class);
expect(User.current()).andReturn(user);
replayAll();
MatrixProject matrixProjectProject = new MatrixProject("matrixProject");
FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
freeStyleProject.onCopiedFrom(matrixProjectProject);
verifyAll();
assertEquals(freeStyleProject.getNextBuildNumber(), 1);
assertTrue(freeStyleProject.isHoldOffBuildUntilSave());
assertNotNull(freeStyleProject.getCreationTime());
assertEquals(freeStyleProject.getCreatedBy(), USER);
List properties = freeStyleProject.getAllProperties();
assertEquals(properties.size(), 1);
AuthorizationMatrixProperty property = (AuthorizationMatrixProperty) properties.get(0);
assertEquals(property.getGrantedPermissions().keySet().size(), 7);
assertNotNull(property.getGrantedPermissions().get(Item.CONFIGURE));
assertTrue(property.getGrantedPermissions().get(Item.CONFIGURE).contains(USER));
}
use of hudson.matrix.MatrixProject in project hudson-2.x by hudson.
the class ProjectServiceImpl method findProject.
public AbstractProject<?, ?> findProject(final String projectName) {
checkProjectName(projectName);
// Handle matrix-project/configuration projects.
// First part is matrix-project name, second part is
// matrix-configuration name
String[] parts = projectName.split("/", 2);
if (parts.length == 2) {
log.debug("Detected matrix name: {}", projectName);
AbstractProject<?, ?> parent = findProject(parts[0]);
if (parent instanceof MatrixProject) {
for (MatrixConfiguration config : ((MatrixProject) parent).getItems()) {
if (parts[1].equals(config.getName())) {
log.debug("Selected matrix configuration: {}", config);
// config.checkPermission(Item.READ); // TODO needed?
return config;
}
}
}
}
if (!getProjectNames().contains(projectName)) {
log.debug("Project {} not in the list of job names.", projectName);
return null;
}
AbstractProject<?, ?> project = getProjectByFullName(projectName);
log.debug("Selected project: {}", project);
return project;
}
use of hudson.matrix.MatrixProject in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testOnCopiedFromAnonymousAuthentication.
@Test
public void testOnCopiedFromAnonymousAuthentication() {
Hudson hudson = createMock(Hudson.class);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
mockStatic(User.class);
expect(User.current()).andReturn(null);
replayAll();
MatrixProject matrixProjectProject = new MatrixProject("matrixProject");
FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
freeStyleProject.onCopiedFrom(matrixProjectProject);
verifyAll();
assertEquals(freeStyleProject.getNextBuildNumber(), 1);
assertTrue(freeStyleProject.isHoldOffBuildUntilSave());
assertNotNull(freeStyleProject.getCreationTime());
assertNull(freeStyleProject.getCreatedBy());
List properties = freeStyleProject.getAllProperties();
assertEquals(properties.size(), 0);
}
use of hudson.matrix.MatrixProject in project hudson-2.x by hudson.
the class FreeStyleProjectTest method testOnCopiedFromGlobalMatrixAuthorizationStrategy.
@Test
public void testOnCopiedFromGlobalMatrixAuthorizationStrategy() {
Hudson hudson = createMock(Hudson.class);
AuthorizationStrategy authorizationStrategy = createMock(GlobalMatrixAuthorizationStrategy.class);
expect(hudson.getAuthorizationStrategy()).andReturn(authorizationStrategy);
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
User user = createMock(User.class);
expect(user.getId()).andReturn(USER).times(1);
mockStatic(User.class);
expect(User.current()).andReturn(user);
replayAll();
MatrixProject matrixProjectProject = new MatrixProject("matrixProject");
FreeStyleProject freeStyleProject = new FreeStyleProjectMock("testJob");
freeStyleProject.onCopiedFrom(matrixProjectProject);
verifyAll();
assertEquals(freeStyleProject.getNextBuildNumber(), 1);
assertTrue(freeStyleProject.isHoldOffBuildUntilSave());
assertNotNull(freeStyleProject.getCreationTime());
assertEquals(freeStyleProject.getCreatedBy(), USER);
assertEquals(freeStyleProject.getAllProperties().size(), 0);
}
Aggregations