use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class CustomLabelIT method customLabelAnyWithBlock_Addreviewer_ZeroVote.
@Test
public void customLabelAnyWithBlock_Addreviewer_ZeroVote() throws Exception {
P.setFunctionName("AnyWithBlock");
saveLabelConfig();
PushOneCommit.Result r = createChange();
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes().id(r.getChangeId()).addReviewer(in);
ReviewInput input = new ReviewInput().label(P.getName(), 0);
input.message = "foo";
revision(r).review(input);
ChangeInfo c = get(r.getChangeId());
LabelInfo q = c.labels.get(P.getName());
assertThat(q.all).hasSize(2);
assertThat(q.disliked).isNull();
assertThat(q.rejected).isNull();
assertThat(q.blocking).isNull();
assertThat(lastCommentAddedEvent.getComment()).isEqualTo("Patch Set 1:\n\n" + input.message);
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method reviewerAndCcByEmailWithQueryForDifferentUser.
@Test
public void reviewerAndCcByEmailWithQueryForDifferentUser() throws Exception {
assume().that(notesMigration.enabled()).isTrue();
Project.NameKey project = new Project.NameKey("repo");
TestRepository<Repo> repo = createProject(project.get());
ConfigInput conf = new ConfigInput();
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
gApi.projects().name(project.get()).config(conf);
String userByEmail = "John Doe <un.registered@reviewer.com>";
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
insert(repo, newChange(repo));
AddReviewerInput rin = new AddReviewerInput();
rin.reviewer = userByEmail;
rin.state = ReviewerState.REVIEWER;
gApi.changes().id(change1.getId().get()).addReviewer(rin);
rin = new AddReviewerInput();
rin.reviewer = userByEmail;
rin.state = ReviewerState.CC;
gApi.changes().id(change2.getId().get()).addReviewer(rin);
if (getSchemaVersion() >= 41) {
assertQuery("reviewer:\"someone@example.com\"");
assertQuery("cc:\"someone@example.com\"");
} else {
assertMissingField(ChangeField.REVIEWER_BY_EMAIL);
String someoneEmail = "someone@example.com";
assertFailingQuery("reviewer:\"" + someoneEmail + "\"", "User " + someoneEmail + " not found");
assertFailingQuery("cc:\"" + someoneEmail + "\"", "User " + someoneEmail + " not found");
}
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method reviewerAndCc.
@Test
public void reviewerAndCc() throws Exception {
Account.Id user1 = createAccount("user1");
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
insert(repo, newChange(repo));
AddReviewerInput rin = new AddReviewerInput();
rin.reviewer = user1.toString();
rin.state = ReviewerState.REVIEWER;
gApi.changes().id(change1.getId().get()).addReviewer(rin);
rin = new AddReviewerInput();
rin.reviewer = user1.toString();
rin.state = ReviewerState.CC;
gApi.changes().id(change2.getId().get()).addReviewer(rin);
if (notesMigration.readChanges()) {
assertQuery("reviewer:" + user1, change1);
assertQuery("cc:" + user1, change2);
} else {
assertQuery("reviewer:" + user1, change2, change1);
assertQuery("cc:" + user1);
}
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class SetReviewersCommand method modifyOne.
private boolean modifyOne(ChangeResource changeRsrc) throws Exception {
boolean ok = true;
//
for (Account.Id reviewer : toRemove) {
ReviewerResource rsrc = reviewerFactory.create(changeRsrc, reviewer);
String error = null;
try {
deleteReviewer.apply(rsrc, new DeleteReviewerInput());
} catch (ResourceNotFoundException e) {
error = String.format("could not remove %s: not found", reviewer);
} catch (Exception e) {
error = String.format("could not remove %s: %s", reviewer, e.getMessage());
}
if (error != null) {
ok = false;
writeError("error", error);
}
}
//
for (String reviewer : toAdd) {
AddReviewerInput input = new AddReviewerInput();
input.reviewer = reviewer;
input.confirmed = true;
String error;
try {
error = postReviewers.apply(changeRsrc, input).error;
} catch (Exception e) {
error = String.format("could not add %s: %s", reviewer, e.getMessage());
}
if (error != null) {
ok = false;
writeError("error", error);
}
}
return ok;
}
use of com.google.gerrit.extensions.api.changes.AddReviewerInput in project gerrit by GerritCodeReview.
the class PutAssignee method addAssigneeAsCC.
private Addition addAssigneeAsCC(ChangeResource rsrc, String assignee) throws OrmException, IOException, PermissionBackendException {
AddReviewerInput reviewerInput = new AddReviewerInput();
reviewerInput.reviewer = assignee;
reviewerInput.state = ReviewerState.CC;
reviewerInput.confirmed = true;
reviewerInput.notify = NotifyHandling.NONE;
return postReviewers.prepareApplication(rsrc, reviewerInput, false);
}
Aggregations