use of com.google.gerrit.reviewdb.client.Project 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);
}
use of com.google.gerrit.reviewdb.client.Project 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);
}
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class ProjectWatchIT method watchProjectNotifyOnPrivateChange.
@Test
public void watchProjectNotifyOnPrivateChange() throws Exception {
String watchedProject = createProject("watchedProject").get();
// create group that can view all private changes
GroupInfo groupThatCanViewPrivateChanges = gApi.groups().create("groupThatCanViewPrivateChanges").get();
grant(new Project.NameKey(watchedProject), "refs/*", Permission.VIEW_PRIVATE_CHANGES, false, new AccountGroup.UUID(groupThatCanViewPrivateChanges.id));
// watch project as user that can't view private changes
setApiUser(user);
watch(watchedProject, null);
// watch project as user that can view all private change
TestAccount userThatCanViewPrivateChanges = accounts.create("user2", "user2@test.com", "User2", groupThatCanViewPrivateChanges.name);
setApiUser(userThatCanViewPrivateChanges);
watch(watchedProject, null);
// push a private change to watched project -> should trigger email notification for
// userThatCanViewPrivateChanges, but not for user
setApiUser(admin);
TestRepository<InMemoryRepository> watchedRepo = cloneProject(new Project.NameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), watchedRepo, "TRIGGER", "a", "a1").to("refs/for/master%private");
r.assertOkStatus();
// assert email notification
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(userThatCanViewPrivateChanges.emailAddress);
assertThat(m.body()).contains("Change subject: TRIGGER\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class ProjectWatchIT method watchKeyword.
@Test
public void watchKeyword() throws Exception {
String watchedProject = createProject("watchedProject").get();
setApiUser(user);
// watch keyword in project as user
watch(watchedProject, "multimaster");
// push a change with keyword -> should trigger email notification
setApiUser(admin);
TestRepository<InMemoryRepository> watchedRepo = cloneProject(new Project.NameKey(watchedProject), admin);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), watchedRepo, "Document multimaster setup", "a.txt", "a1").to("refs/for/master");
r.assertOkStatus();
// assert email notification for user
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress);
assertThat(m.body()).contains("Change subject: Document multimaster setup\n");
assertThat(m.body()).contains("Gerrit-PatchSet: 1\n");
sender.clear();
// push a change without keyword -> should not trigger email notification
r = pushFactory.create(db, admin.getIdent(), watchedRepo, "Cleanup cache implementation", "b.txt", "b1").to("refs/for/master");
r.assertOkStatus();
// assert email notification
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class AccessMap method get.
public static void get(Set<Project.NameKey> projects, AsyncCallback<AccessMap> callback) {
RestApi api = new RestApi("/access/");
for (Project.NameKey p : projects) {
api.addParameter("project", p.get());
}
api.get(NativeMap.copyKeysIntoChildren(callback));
}
Aggregations