use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class WatchedProjectsIT method setAndDeleteWatchedProjects.
@Test
public void setAndDeleteWatchedProjects() throws Exception {
String projectName1 = createProject(NEW_PROJECT_NAME).get();
String projectName2 = createProject(NEW_PROJECT_NAME + "2").get();
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
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);
// Persist watched projects
gApi.accounts().self().setWatchedProjects(projectsToWatch);
List<ProjectWatchInfo> d = Lists.newArrayList(pwi);
gApi.accounts().self().deleteWatchedProjects(d);
projectsToWatch.remove(pwi);
List<ProjectWatchInfo> persistedWatchedProjects = gApi.accounts().self().getWatchedProjects();
assertThat(persistedWatchedProjects).doesNotContain(pwi);
assertThat(persistedWatchedProjects).containsAllIn(projectsToWatch);
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class PostWatchedProjects method asMap.
private Map<ProjectWatchKey, Set<NotifyType>> asMap(List<ProjectWatchInfo> input) throws BadRequestException, UnprocessableEntityException, IOException, PermissionBackendException {
Map<ProjectWatchKey, Set<NotifyType>> m = new HashMap<>();
for (ProjectWatchInfo info : input) {
if (info.project == null) {
throw new BadRequestException("project name must be specified");
}
ProjectWatchKey key = ProjectWatchKey.create(projectsCollection.parse(info.project).getNameKey(), info.filter);
if (m.containsKey(key)) {
throw new BadRequestException("duplicate entry for project " + format(info.project, info.filter));
}
Set<NotifyType> notifyValues = EnumSet.noneOf(NotifyType.class);
if (toBoolean(info.notifyAbandonedChanges)) {
notifyValues.add(NotifyType.ABANDONED_CHANGES);
}
if (toBoolean(info.notifyAllComments)) {
notifyValues.add(NotifyType.ALL_COMMENTS);
}
if (toBoolean(info.notifyNewChanges)) {
notifyValues.add(NotifyType.NEW_CHANGES);
}
if (toBoolean(info.notifyNewPatchSets)) {
notifyValues.add(NotifyType.NEW_PATCHSETS);
}
if (toBoolean(info.notifySubmittedChanges)) {
notifyValues.add(NotifyType.SUBMITTED_CHANGES);
}
m.put(key, notifyValues);
}
return m;
}
use of com.google.gerrit.extensions.client.ProjectWatchInfo in project gerrit by GerritCodeReview.
the class AbstractQueryAccountsTest method watch.
protected void watch(AccountInfo account, Project.NameKey project, String filter) throws RestApiException {
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
ProjectWatchInfo pwi = new ProjectWatchInfo();
pwi.project = project.get();
pwi.filter = filter;
pwi.notifyAbandonedChanges = true;
pwi.notifyNewChanges = true;
pwi.notifyAllComments = true;
projectsToWatch.add(pwi);
gApi.accounts().id(account._accountId).setWatchedProjects(projectsToWatch);
}
Aggregations