Search in sources :

Example 16 with ProjectInput

use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.

the class ProjectIT method createProjectNoNameInInput.

@Test
public void createProjectNoNameInInput() throws Exception {
    ProjectInput in = new ProjectInput();
    exception.expect(BadRequestException.class);
    exception.expectMessage("input.name is required");
    gApi.projects().create(in);
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 17 with ProjectInput

use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.

the class ProjectIT method createProjectWithMismatchedInput.

@Test
public void createProjectWithMismatchedInput() throws Exception {
    ProjectInput in = new ProjectInput();
    in.name = name("foo");
    exception.expect(BadRequestException.class);
    exception.expectMessage("name must match input.name");
    gApi.projects().name("bar").create(in);
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 18 with ProjectInput

use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.

the class CreateProjectIT method createProjectWithProperties.

@Test
public void createProjectWithProperties() throws Exception {
    String newProjectName = name("newProject");
    ProjectInput in = new ProjectInput();
    in.name = newProjectName;
    in.description = "Test description";
    in.submitType = SubmitType.CHERRY_PICK;
    in.useContributorAgreements = InheritableBoolean.TRUE;
    in.useSignedOffBy = InheritableBoolean.TRUE;
    in.useContentMerge = InheritableBoolean.TRUE;
    in.requireChangeId = InheritableBoolean.TRUE;
    ProjectInfo p = gApi.projects().create(in).get();
    assertThat(p.name).isEqualTo(newProjectName);
    Project project = projectCache.get(new Project.NameKey(newProjectName)).getProject();
    assertProjectInfo(project, p);
    assertThat(project.getDescription()).isEqualTo(in.description);
    assertThat(project.getSubmitType()).isEqualTo(in.submitType);
    assertThat(project.getUseContributorAgreements()).isEqualTo(in.useContributorAgreements);
    assertThat(project.getUseSignedOffBy()).isEqualTo(in.useSignedOffBy);
    assertThat(project.getUseContentMerge()).isEqualTo(in.useContentMerge);
    assertThat(project.getRequireChangeID()).isEqualTo(in.requireChangeId);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) ProjectAssert.assertProjectInfo(com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 19 with ProjectInput

use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.

the class CreateProjectIT method createProjectWithCreateProjectCapabilityAndParentNotVisible.

@Test
public void createProjectWithCreateProjectCapabilityAndParentNotVisible() throws Exception {
    Project parent = projectCache.get(allProjects).getProject();
    parent.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN);
    allowGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
    try {
        setApiUser(user);
        ProjectInput in = new ProjectInput();
        in.name = name("newProject");
        ProjectInfo p = gApi.projects().create(in).get();
        assertThat(p.name).isEqualTo(in.name);
    } finally {
        parent.setState(com.google.gerrit.extensions.client.ProjectState.ACTIVE);
        removeGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
    }
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) ProjectAssert.assertProjectInfo(com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 20 with ProjectInput

use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.

the class CreateProjectIT method createProjectWithBranches.

@Test
public void createProjectWithBranches() throws Exception {
    String newProjectName = name("newProject");
    ProjectInput in = new ProjectInput();
    in.name = newProjectName;
    in.createEmptyCommit = true;
    in.branches = Lists.newArrayListWithCapacity(3);
    in.branches.add("refs/heads/test");
    in.branches.add("refs/heads/master");
    // without 'refs/heads' prefix
    in.branches.add("release");
    gApi.projects().create(in);
    assertHead(newProjectName, "refs/heads/test");
    assertEmptyCommit(newProjectName, "refs/heads/test", "refs/heads/master", "refs/heads/release");
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ProjectInput (com.google.gerrit.extensions.api.projects.ProjectInput)24 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)19 Test (org.junit.Test)19 Project (com.google.gerrit.reviewdb.client.Project)6 ProjectAssert.assertProjectInfo (com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo)3 ProjectInfo (com.google.gerrit.extensions.common.ProjectInfo)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)1 TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)1 ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)1 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)1 ProjectState (com.google.gerrit.server.project.ProjectState)1 ProjectCreationValidationListener (com.google.gerrit.server.validators.ProjectCreationValidationListener)1 ValidationException (com.google.gerrit.server.validators.ValidationException)1 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)1