Search in sources :

Example 31 with ProjectInfo

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

the class CreateProjectIT method createProjectWithCreateProjectCapabilityAndParentNotVisible.

@Test
public void createProjectWithCreateProjectCapabilityAndParentNotVisible() throws Exception {
    try (ProjectConfigUpdate u = updateProject(allProjects)) {
        u.getConfig().updateProject(p -> p.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN));
        u.save();
    }
    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 {
        try (ProjectConfigUpdate u = updateProject(allProjects)) {
            u.getConfig().updateProject(p -> p.setState(com.google.gerrit.extensions.client.ProjectState.ACTIVE));
            u.save();
        }
        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)

Example 32 with ProjectInfo

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

the class CreateProjectIT method createProjectThatEndsWithSlash.

@Test
public void createProjectThatEndsWithSlash() throws Exception {
    String newProjectName = name("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 33 with ProjectInfo

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

the class CreateProjectIT method createProjectHttp.

@Test
public void createProjectHttp() throws Exception {
    String newProjectName = name("newProject");
    RestResponse r = adminRestSession.put("/projects/" + newProjectName);
    r.assertCreated();
    ProjectInfo p = newGson().fromJson(r.getReader(), ProjectInfo.class);
    assertThat(p.name).isEqualTo(newProjectName);
    // Check that we populate the label data in the HTTP path. See GetProjectIT#getProject
    // for more extensive coverage of the LabelTypeInfo.
    assertThat(p.labels).hasSize(1);
    Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
    assertThat(projectState).isPresent();
    assertProjectInfo(projectState.get().getProject(), p);
    assertHead(newProjectName, "refs/heads/master");
}
Also used : RestResponse(com.google.gerrit.acceptance.RestResponse) 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 34 with ProjectInfo

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

the class ProjectAssert method assertThatNameList.

public static IterableSubject assertThatNameList(Iterable<ProjectInfo> actualIt) {
    List<ProjectInfo> actual = ImmutableList.copyOf(actualIt);
    for (ProjectInfo info : actual) {
        assertWithMessage("missing project name").that(info.name).isNotNull();
        assertWithMessage("project name does not match id").that(Url.decode(info.id)).isEqualTo(info.name);
    }
    return assertThat(Iterables.transform(actual, p -> Project.nameKey(p.name)));
}
Also used : AccountGroup(com.google.gerrit.entities.AccountGroup) Iterables(com.google.common.collect.Iterables) Truth.assertWithMessage(com.google.common.truth.Truth.assertWithMessage) ProjectState(com.google.gerrit.server.project.ProjectState) Set(java.util.Set) Truth.assertThat(com.google.common.truth.Truth.assertThat) Strings(com.google.common.base.Strings) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IterableSubject(com.google.common.truth.IterableSubject) Project(com.google.gerrit.entities.Project) Url(com.google.gerrit.extensions.restapi.Url) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo)

Example 35 with ProjectInfo

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

the class AbstractQueryProjectsTest method byInname.

@Test
public void byInname() throws Exception {
    String namePart = testName.getSanitizedMethodName();
    namePart = CharMatcher.is('_').removeFrom(namePart);
    ProjectInfo project1 = createProject(name("project1-" + namePart));
    ProjectInfo project2 = createProject(name("project2-" + namePart + "-foo"));
    ProjectInfo project3 = createProject(name("project3-" + namePart + "foo"));
    assertQuery("inname:" + namePart, project1, project2, project3);
    assertQuery("inname:" + namePart.toUpperCase(Locale.US), project1, project2, project3);
    assertQuery("inname:" + namePart.toLowerCase(Locale.US), project1, project2, project3);
}
Also used : ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) 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