Search in sources :

Example 11 with ProjectEx

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");
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) ApiOperation(io.swagger.annotations.ApiOperation)

Example 12 with ProjectEx

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());
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test)

Example 13 with ProjectEx

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());
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test)

Example 14 with ProjectEx

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());
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test)

Example 15 with ProjectEx

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());
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test)

Aggregations

ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)52 Test (org.testng.annotations.Test)42 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)16 SUser (jetbrains.buildServer.users.SUser)10 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)8 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)7 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)7 BuildType (jetbrains.buildServer.server.rest.model.buildType.BuildType)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)5 Fields (jetbrains.buildServer.server.rest.model.Fields)5 TestName (jetbrains.buildServer.tests.TestName)5 ApiOperation (io.swagger.annotations.ApiOperation)4 SUserGroup (jetbrains.buildServer.groups.SUserGroup)4 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)4 Mutes (jetbrains.buildServer.server.rest.model.problem.Mutes)3 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)3 SProject (jetbrains.buildServer.serverSide.SProject)3 STest (jetbrains.buildServer.serverSide.STest)3 Permissions (jetbrains.buildServer.serverSide.auth.Permissions)3