in javatests/com/google/gerrit/plugins/checks/acceptance/api/ChecksEmailIT.java [80:139]
public void setup() throws Exception {
// Create a bot account, create a bots group and add the bot as member and allow the bots group
// to post checks.
bot = accountCreator.create("bot", "bot@example.com", "Bot", null);
AccountGroup.UUID botsAccountGroupUuid =
groupOperations.newGroup().name("bots").addMember(bot.id()).create();
projectOperations
.project(allProjects)
.forUpdate()
.add(allowCapability("checks-administrateCheckers").group(botsAccountGroupUuid))
.update();
// Create a change.
owner = admin;
PushOneCommit.Result result = createChange();
change = result.getChange().change();
patchSetId = result.getPatchSetId();
// Add a reviewer.
reviewer = accountCreator.create("reviewer", "reviewer@example.com", "Reviewer", null);
gApi.changes().id(patchSetId.changeId().get()).addReviewer(reviewer.username());
// Star the change from some user.
starrer = accountCreator.create("starred", "starrer@example.com", "Starrer", null);
requestScopeOperations.setApiUser(starrer.id());
gApi.accounts().self().starChange(patchSetId.changeId().toString());
// Watch all comments of change from some user.
watcher = accountCreator.create("watcher", "watcher@example.com", "Watcher", null);
requestScopeOperations.setApiUser(watcher.id());
ProjectWatchInfo projectWatchInfo = new ProjectWatchInfo();
projectWatchInfo.project = project.get();
projectWatchInfo.filter = "*";
projectWatchInfo.notifyAllComments = true;
gApi.accounts().self().setWatchedProjects(ImmutableList.of(projectWatchInfo));
// Watch only change creations from some user --> user doesn't get notified by checks plugin.
TestAccount changeCreationWatcher =
accountCreator.create(
"changeCreationWatcher",
"changeCreationWatcher@example.com",
"Change Creation Watcher",
null);
requestScopeOperations.setApiUser(changeCreationWatcher.id());
projectWatchInfo = new ProjectWatchInfo();
projectWatchInfo.project = project.get();
projectWatchInfo.filter = "*";
projectWatchInfo.notifyNewChanges = true;
gApi.accounts().self().setWatchedProjects(ImmutableList.of(projectWatchInfo));
// Add a reviewer that ignores the change --> user doesn't get notified by checks plugin.
ignoringReviewer = accountCreator.create("ignorer", "ignorer@example.com", "Ignorer", null);
requestScopeOperations.setApiUser(admin.id());
gApi.changes().id(patchSetId.changeId().get()).addReviewer(ignoringReviewer.username());
requestScopeOperations.setApiUser(ignoringReviewer.id());
gApi.changes().id(patchSetId.changeId().get()).ignore(true);
// Reset request scope to admin.
requestScopeOperations.setApiUser(admin.id());
}