use of com.google.gerrit.extensions.api.changes.DeleteVoteInput in project gerrit by GerritCodeReview.
the class ChangeIT method deleteVoteNotifyNone.
@Test
public void deleteVoteNotifyNone() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
DeleteVoteInput in = new DeleteVoteInput();
in.label = "Code-Review";
in.notify = NotifyHandling.NONE;
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.DeleteVoteInput in project gerrit by GerritCodeReview.
the class ChangeIT method deleteVoteNotifyAccount.
@Test
public void deleteVoteNotifyAccount() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
DeleteVoteInput in = new DeleteVoteInput();
in.label = "Code-Review";
in.notify = NotifyHandling.NONE;
// notify unrelated account as TO
TestAccount user2 = accounts.user2();
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.TO, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyTo(user2);
// notify unrelated account as CC
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.CC, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyCc(user2);
// notify unrelated account as BCC
setApiUser(user);
recommend(r.getChangeId());
setApiUser(admin);
sender.clear();
in.notifyDetails = new HashMap<>();
in.notifyDetails.put(RecipientType.BCC, new NotifyInfo(ImmutableList.of(user2.email)));
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote(in);
assertNotifyBcc(user2);
}
use of com.google.gerrit.extensions.api.changes.DeleteVoteInput in project gerrit by GerritCodeReview.
the class DeleteVote method applyImpl.
@Override
protected Response<?> applyImpl(BatchUpdate.Factory updateFactory, VoteResource rsrc, DeleteVoteInput input) throws RestApiException, UpdateException {
if (input == null) {
input = new DeleteVoteInput();
}
if (input.label != null && !rsrc.getLabel().equals(input.label)) {
throw new BadRequestException("label must match URL");
}
if (input.notify == null) {
input.notify = NotifyHandling.ALL;
}
ReviewerResource r = rsrc.getReviewer();
Change change = r.getChange();
if (r.getRevisionResource() != null && !r.getRevisionResource().isCurrent()) {
throw new MethodNotAllowedException("Cannot delete vote on non-current patch set");
}
try (BatchUpdate bu = updateFactory.create(db.get(), change.getProject(), r.getControl().getUser(), TimeUtil.nowTs())) {
bu.addOp(change.getId(), new Op(r.getReviewerUser().getAccountId(), rsrc.getLabel(), input));
bu.execute();
}
return Response.none();
}
Aggregations