use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class ProjectRequest method removeDefaultTemplate.
@DELETE
@Path("/{projectLocator}/defaultTemplate")
@ApiOperation(value = "Remove the default template from the matching project.", nickname = "removeDefaultTemplate")
public void removeDefaultTemplate(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, @QueryParam("fields") String fields) {
ProjectEx project = (ProjectEx) myProjectFinder.getItem(projectLocator, true);
if (project.getOwnDefaultTemplate() == null)
throw new NotFoundException("No own default template present");
project.setDefaultTemplate(null);
project.schedulePersisting("Default template removed");
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testAddProjectToPool.
@Test
public void testAddProjectToPool() throws AgentPoolCannotBeRenamedException {
final String poolName = "testPool";
final String projectName = "testProject";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project = createProject(projectName);
AssignProjectWithAgentPoolInput input = new AssignProjectWithAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawId(project.getExternalId());
DataFetcherResult<AssignProjectWithAgentPoolPayload> result = myMutation.assignProjectWithAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
AssignProjectWithAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertEquals(projectName, payload.getProject().getName());
assertContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project.getProjectId());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testBulkAddProjectsToPool.
@Test
public void testBulkAddProjectsToPool() throws AgentPoolCannotBeRenamedException {
final String poolName = "testPool";
final String projectName1 = "testProject1";
final String projectName2 = "testProject2";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project1 = createProject(projectName1);
ProjectEx project2 = createProject(projectName2);
BulkAssignProjectWithAgentPoolInput input = new BulkAssignProjectWithAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawIds(Arrays.asList(project1.getExternalId(), project2.getExternalId()));
input.setExclusively(false);
DataFetcherResult<BulkAssignProjectWithAgentPoolPayload> result = myMutation.bulkAssignProjectWithAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
BulkAssignProjectWithAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project1.getProjectId(), project2.getProjectId());
// Projects should be associated with default pool when exclusively == false
assertContains(myFixture.getAgentPoolManager().getPoolProjects(AgentPool.DEFAULT_POOL_ID), project1.getProjectId(), project2.getProjectId());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testBulkAddProjectsToPoolExclusively.
@Test
public void testBulkAddProjectsToPoolExclusively() throws AgentPoolCannotBeRenamedException {
final String poolName = "testPool";
final String projectName1 = "testProject1";
final String projectName2 = "testProject2";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project1 = createProject(projectName1);
ProjectEx project2 = createProject(projectName2);
BulkAssignProjectWithAgentPoolInput input = new BulkAssignProjectWithAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawIds(Arrays.asList(project1.getExternalId(), project2.getExternalId()));
input.setExclusively(true);
DataFetcherResult<BulkAssignProjectWithAgentPoolPayload> result = myMutation.bulkAssignProjectWithAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
BulkAssignProjectWithAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project1.getProjectId(), project2.getProjectId());
// check that no other pool has association with said projects
assertEquals(1, myFixture.getAgentPoolManager().getAgentPoolsWithProject(project1.getProjectId()).size());
assertEquals(1, myFixture.getAgentPoolManager().getAgentPoolsWithProject(project2.getProjectId()).size());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testRemoveProjectFromPoolNonRecursiveByDefault.
@Test
public void testRemoveProjectFromPoolNonRecursiveByDefault() throws AgentPoolCannotBeRenamedException, NoSuchAgentPoolException {
final String poolName = "testPool";
final String projectName = "testProject";
final String childProjectName = "testProjectChild";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project = createProject(projectName, projectName);
ProjectEx childProject = project.createProject(childProjectName, childProjectName);
Set<String> associateList = new HashSet<>();
associateList.add(project.getProjectId());
associateList.add(childProject.getProjectId());
myFixture.getAgentPoolManager().associateProjectsWithPool(pool.getAgentPoolId(), associateList);
UnassignProjectFromAgentPoolInput input = new UnassignProjectFromAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawId(project.getExternalId());
DataFetcherResult<UnassignProjectFromAgentPoolPayload> result = myMutation.unassignProjectFromAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
UnassignProjectFromAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertEquals(projectName, payload.getProject().getName());
Set<String> poolProjectsAfterRemoval = myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId());
assertNotContains(poolProjectsAfterRemoval, project.getProjectId());
// We didn't set recursive to true and expect it to be false by default, so the child project should remain in the pool.
assertContains(poolProjectsAfterRemoval, childProject.getProjectId());
}
Aggregations