use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class WatchedProjectsIT method watchNonExistingProject.
@Test
public void watchNonExistingProject() throws Exception {
String projectName = NEW_PROJECT_NAME + "3";
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>(2);
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = projectName;
pwi.notifyAbandonedChanges = true;
pwi.notifyNewChanges = true;
pwi.notifyAllComments = true;
projectsToWatch.add(pwi);
exception.expect(UnprocessableEntityException.class);
gApi.accounts().self().setWatchedProjects(projectsToWatch);
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method watch.
protected void watch(String project, String filter) throws RestApiException {
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = project;
pwi.filter = filter;
pwi.notifyAbandonedChanges = true;
pwi.notifyNewChanges = true;
pwi.notifyAllComments = true;
projectsToWatch.add(pwi);
gApi.accounts().self().setWatchedProjects(projectsToWatch);
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithNotify.
@Test
public void pushForMasterWithNotify() throws Exception {
// create a user that watches the project
TestAccount user3 = accounts.create("user3", "user3@example.com", "User3");
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = project.get();
pwi.filter = "*";
pwi.notifyNewChanges = true;
projectsToWatch.add(pwi);
setApiUser(user3);
gApi.accounts().self().setWatchedProjects(projectsToWatch);
TestAccount user2 = accounts.user2();
String pushSpec = "refs/for/master%reviewer=" + user.email + ",cc=" + user2.email;
sender.clear();
PushOneCommit.Result r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE);
r.assertOkStatus();
assertThat(sender.getMessages()).isEmpty();
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.OWNER);
r.assertOkStatus();
// no email notification about own changes
assertThat(sender.getMessages()).isEmpty();
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.OWNER_REVIEWERS);
r.assertOkStatus();
assertThat(sender.getMessages()).hasSize(1);
Message m = sender.getMessages().get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.ALL);
r.assertOkStatus();
assertThat(sender.getMessages()).hasSize(1);
m = sender.getMessages().get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress, user2.emailAddress, user3.emailAddress);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + user3.email);
r.assertOkStatus();
assertNotifyTo(user3);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-cc=" + user3.email);
r.assertOkStatus();
assertNotifyCc(user3);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-bcc=" + user3.email);
r.assertOkStatus();
assertNotifyBcc(user3);
// request that sender gets notified as TO, CC and BCC, email should be sent
// even if the sender is the only recipient
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + admin.email);
assertNotifyTo(admin);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-cc=" + admin.email);
r.assertOkStatus();
assertNotifyCc(admin);
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-bcc=" + admin.email);
r.assertOkStatus();
assertNotifyBcc(admin);
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class WatchedProjectsIT method setAndGetWatchedProjects.
@Test
public void setAndGetWatchedProjects() throws Exception {
String projectName1 = createProject(NEW_PROJECT_NAME).get();
String projectName2 = createProject(NEW_PROJECT_NAME + "2").get();
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>(2);
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = projectName1;
pwi.notifyAbandonedChanges = true;
pwi.notifyNewChanges = true;
pwi.notifyAllComments = true;
projectsToWatch.add(pwi);
pwi = new ProjectWatchInfo();
pwi.project = projectName2;
pwi.filter = "branch:master";
pwi.notifySubmittedChanges = true;
pwi.notifyNewPatchSets = true;
projectsToWatch.add(pwi);
List<ProjectWatchInfo> persistedWatchedProjects = gApi.accounts().self().setWatchedProjects(projectsToWatch);
assertThat(persistedWatchedProjects).containsAllIn(projectsToWatch).inOrder();
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class WatchedProjectsIT method deleteNonExistingProjectWatch.
@Test
public void deleteNonExistingProjectWatch() throws Exception {
String projectName = project.get();
// Let another user watch a project
setApiUser(admin);
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = projectName;
pwi.notifyAbandonedChanges = true;
pwi.notifyNewChanges = true;
pwi.notifyAllComments = true;
projectsToWatch.add(pwi);
gApi.accounts().self().setWatchedProjects(projectsToWatch);
// Try to delete a watched project using a different user
List<ProjectWatchInfo> d = Lists.newArrayList(pwi);
gApi.accounts().self().deleteWatchedProjects(d);
// Check that trying to delete a non-existing watch doesn't fail
setApiUser(user);
gApi.accounts().self().deleteWatchedProjects(d);
}
Aggregations