Search in sources :

Example 26 with ProjectInfo

use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.

the class GetProjectIT method getProject.

@Test
public void getProject() throws Exception {
    String name = project.get();
    ProjectInfo p = gApi.projects().name(name).get();
    assertThat(p.name).isEqualTo(name);
    assertThat(p.labels).hasSize(1);
    LabelTypeInfo l = p.labels.get("Code-Review");
    ImmutableMap<String, String> want = ImmutableMap.of(" 0", "No score", "-1", "I would prefer this is not merged as is", "-2", "This shall not be merged", "+1", "Looks good to me, but someone else must approve", "+2", "Looks good to me, approved");
    assertThat(l.values).isEqualTo(want);
    assertThat(l.defaultValue).isEqualTo(0);
}
Also used : ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) LabelTypeInfo(com.google.gerrit.extensions.common.LabelTypeInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 27 with ProjectInfo

use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.

the class GetProjectIT method getProjectWithGitSuffix.

@Test
public void getProjectWithGitSuffix() throws Exception {
    String name = project.get();
    ProjectInfo p = gApi.projects().name(name).get();
    assertThat(p.name).isEqualTo(name);
}
Also used : ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 28 with ProjectInfo

use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.

the class CreateProjectIT method createProjectThatContainsSlash.

@Test
public void createProjectThatContainsSlash() throws Exception {
    String newProjectName = name("newProject/newProject");
    ProjectInfo p = gApi.projects().create(newProjectName).get();
    assertThat(p.name).isEqualTo(newProjectName);
    Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
    assertThat(projectState).isPresent();
    assertProjectInfo(projectState.get().getProject(), p);
    assertHead(newProjectName, "refs/heads/master");
}
Also used : ProjectAssert.assertProjectInfo(com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) ProjectState(com.google.gerrit.server.project.ProjectState) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 29 with ProjectInfo

use of com.google.gerrit.extensions.common.ProjectInfo 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(Project.nameKey(newProjectName)).get().getProject();
    assertProjectInfo(project, p);
    assertThat(project.getDescription()).isEqualTo(in.description);
    assertThat(project.getSubmitType()).isEqualTo(in.submitType);
    assertThat(project.getBooleanConfig(BooleanProjectConfig.USE_CONTRIBUTOR_AGREEMENTS)).isEqualTo(in.useContributorAgreements);
    assertThat(project.getBooleanConfig(BooleanProjectConfig.USE_SIGNED_OFF_BY)).isEqualTo(in.useSignedOffBy);
    assertThat(project.getBooleanConfig(BooleanProjectConfig.USE_CONTENT_MERGE)).isEqualTo(in.useContentMerge);
    assertThat(project.getBooleanConfig(BooleanProjectConfig.REQUIRE_CHANGE_ID)).isEqualTo(in.requireChangeId);
}
Also used : Project(com.google.gerrit.entities.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) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 30 with ProjectInfo

use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.

the class CreateProjectIT method createProjectWithCapability.

@Test
public void createProjectWithCapability() throws Exception {
    projectOperations.allProjectsForUpdate().add(allowCapability(GlobalCapability.CREATE_PROJECT).group(SystemGroupBackend.REGISTERED_USERS)).update();
    try {
        requestScopeOperations.setApiUser(user.id());
        ProjectInput in = new ProjectInput();
        in.name = name("newProject");
        ProjectInfo p = gApi.projects().create(in).get();
        assertThat(p.name).isEqualTo(in.name);
    } finally {
        projectOperations.allProjectsForUpdate().remove(capabilityKey(GlobalCapability.CREATE_PROJECT).group(SystemGroupBackend.REGISTERED_USERS)).update();
    }
}
Also used : 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) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

ProjectInfo (com.google.gerrit.extensions.common.ProjectInfo)38 Test (org.junit.Test)25 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)15 ProjectAssert.assertProjectInfo (com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo)10 ProjectState (com.google.gerrit.server.project.ProjectState)10 Project (com.google.gerrit.entities.Project)8 ProjectInput (com.google.gerrit.extensions.api.projects.ProjectInput)5 ImmutableList (com.google.common.collect.ImmutableList)3 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)3 Project (com.google.gerrit.reviewdb.client.Project)3 ProjectResource (com.google.gerrit.server.project.ProjectResource)3 ArrayList (java.util.ArrayList)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)2 RestResponse (com.google.gerrit.acceptance.RestResponse)2 AccountGroup (com.google.gerrit.entities.AccountGroup)2 ConfigInput (com.google.gerrit.extensions.api.projects.ConfigInput)2 LabelTypeInfo (com.google.gerrit.extensions.common.LabelTypeInfo)2 WebLinkInfo (com.google.gerrit.extensions.common.WebLinkInfo)2 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)2 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)2