use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.
the class ConfigChangeIT method onlyAdminMayUpdateProjectParent.
@Test
@TestProjectInput(cloneAs = "user")
public void onlyAdminMayUpdateProjectParent() throws Exception {
setApiUser(admin);
ProjectInput parent = new ProjectInput();
parent.name = name("parent");
parent.permissionsOnly = true;
gApi.projects().create(parent);
setApiUser(user);
Config cfg = readProjectConfig();
assertThat(cfg.getString("access", null, "inheritFrom")).isAnyOf(null, allProjects.get());
cfg.setString("access", null, "inheritFrom", parent.name);
PushOneCommit.Result r = createConfigChange(cfg);
String id = r.getChangeId();
gApi.changes().id(id).current().review(ReviewInput.approve());
try {
gApi.changes().id(id).current().submit();
fail("expected submit to fail");
} catch (ResourceConflictException e) {
int n = gApi.changes().id(id).info()._number;
assertThat(e).hasMessageThat().isEqualTo("Failed to submit 1 change due to the following problems:\n" + "Change " + n + ": Change contains a project configuration that" + " changes the parent project.\n" + "The change must be submitted by a Gerrit administrator.");
}
assertThat(gApi.projects().name(project.get()).get().parent).isEqualTo(allProjects.get());
fetchRefsMetaConfig();
assertThat(readProjectConfig().getString("access", null, "inheritFrom")).isAnyOf(null, allProjects.get());
setApiUser(admin);
gApi.changes().id(id).current().submit();
assertThat(gApi.changes().id(id).info().status).isEqualTo(ChangeStatus.MERGED);
assertThat(gApi.projects().name(project.get()).get().parent).isEqualTo(parent.name);
fetchRefsMetaConfig();
assertThat(readProjectConfig().getString("access", null, "inheritFrom")).isEqualTo(parent.name);
}
use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.
the class ProjectIT method createProjectDuplicate.
@Test
public void createProjectDuplicate() throws Exception {
ProjectInput in = new ProjectInput();
in.name = name("baz");
gApi.projects().create(in);
exception.expect(ResourceConflictException.class);
exception.expectMessage("Project already exists");
gApi.projects().create(in);
}
use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.
the class ProjectIT method createProjectWithInitialCommit.
@Test
public void createProjectWithInitialCommit() throws Exception {
String name = name("foo");
ProjectInput input = new ProjectInput();
input.name = name;
input.createEmptyCommit = true;
assertThat(name).isEqualTo(gApi.projects().create(input).get().name);
RevCommit head = getRemoteHead(name, RefNames.REFS_CONFIG);
eventRecorder.assertRefUpdatedEvents(name, RefNames.REFS_CONFIG, null, head);
head = getRemoteHead(name, "refs/heads/master");
eventRecorder.assertRefUpdatedEvents(name, "refs/heads/master", null, head);
}
use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.
the class CreateProjectIT method createChildProjectUnderNonExistingParent_UnprocessableEntity.
@Test
public void createChildProjectUnderNonExistingParent_UnprocessableEntity() throws Exception {
ProjectInput in = new ProjectInput();
in.name = name("newProjectName");
in.parent = "non-existing-project";
assertCreateFails(in, UnprocessableEntityException.class);
}
use of com.google.gerrit.extensions.api.projects.ProjectInput in project gerrit by GerritCodeReview.
the class CreateProjectIT method createChildProject.
@Test
public void createChildProject() throws Exception {
String parentName = name("parent");
ProjectInput in = new ProjectInput();
in.name = parentName;
gApi.projects().create(in);
String childName = name("child");
in = new ProjectInput();
in.name = childName;
in.parent = parentName;
gApi.projects().create(in);
Project project = projectCache.get(new Project.NameKey(childName)).getProject();
assertThat(project.getParentName()).isEqualTo(in.parent);
}
Aggregations