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();
}
}
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");
}
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");
}
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)));
}
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);
}
Aggregations