use of com.google.gerrit.extensions.common.ApprovalInfo in project gerrit by GerritCodeReview.
the class ChangeJson method getApprovalInfo.
public static ApprovalInfo getApprovalInfo(Account.Id id, Integer value, VotingRangeInfo permittedVotingRange, String tag, Timestamp date) {
ApprovalInfo ai = new ApprovalInfo(id.get());
ai.value = value;
ai.permittedVotingRange = permittedVotingRange;
ai.date = date;
ai.tag = tag;
return ai;
}
use of com.google.gerrit.extensions.common.ApprovalInfo in project gerrit by GerritCodeReview.
the class ChangeJson method approvalInfo.
private ApprovalInfo approvalInfo(Account.Id id, Integer value, VotingRangeInfo permittedVotingRange, String tag, Timestamp date) {
ApprovalInfo ai = getApprovalInfo(id, value, permittedVotingRange, tag, date);
accountLoader.put(ai);
return ai;
}
use of com.google.gerrit.extensions.common.ApprovalInfo in project gerrit by GerritCodeReview.
the class ChangeIT method maxPermittedValueBlocked.
@Test
public void maxPermittedValueBlocked() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
blockLabel(cfg, "Code-Review", REGISTERED_USERS, "refs/heads/*");
saveProjectConfig(project, cfg);
PushOneCommit.Result r = createChange();
String triplet = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(triplet).addReviewer(user.username);
ChangeInfo c = gApi.changes().id(triplet).get(EnumSet.of(ListChangesOption.DETAILED_LABELS));
LabelInfo codeReview = c.labels.get("Code-Review");
assertThat(codeReview.all).hasSize(1);
ApprovalInfo approval = codeReview.all.get(0);
assertThat(approval._accountId).isEqualTo(user.id.get());
assertThat(approval.permittedVotingRange).isNull();
}
use of com.google.gerrit.extensions.common.ApprovalInfo in project gerrit by GerritCodeReview.
the class RevisionIT method postSubmitApprovalAfterVoteRemoved.
@Test
public void postSubmitApprovalAfterVoteRemoved() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
setApiUser(admin);
revision(r).review(ReviewInput.approve());
setApiUser(user);
revision(r).review(ReviewInput.recommend());
setApiUser(admin);
gApi.changes().id(changeId).reviewer(user.username).deleteVote("Code-Review");
Optional<ApprovalInfo> crUser = get(changeId, DETAILED_LABELS).labels.get("Code-Review").all.stream().filter(a -> a._accountId == user.id.get()).findFirst();
assertThat(crUser).isPresent();
assertThat(crUser.get().value).isEqualTo(0);
revision(r).submit();
setApiUser(user);
ReviewInput in = new ReviewInput();
in.label("Code-Review", 1);
in.message = "Still LGTM";
revision(r).review(in);
ApprovalInfo cr = gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS)).labels.get("Code-Review").all.stream().filter(a -> a._accountId == user.getId().get()).findFirst().get();
assertThat(cr.postSubmit).isTrue();
}
use of com.google.gerrit.extensions.common.ApprovalInfo in project gerrit by GerritCodeReview.
the class ChangeReviewersIT method addSelfAsCc.
@Test
public void addSelfAsCc() throws Exception {
// Create change owned by admin.
PushOneCommit.Result r = createChange();
// user adds self as CC.
ReviewInput input = new ReviewInput().reviewer(user.username, CC, false);
RestResponse resp = userRestSession.post("/changes/" + r.getChangeId() + "/revisions/" + r.getCommit().getName() + "/review", input);
ReviewResult result = readContentFromJson(resp, 200, ReviewResult.class);
assertThat(result.labels).isNull();
assertThat(result.reviewers).isNotNull();
assertThat(result.reviewers).hasSize(1);
// Verify reviewer state.
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
if (notesMigration.readChanges()) {
assertReviewers(c, REVIEWER);
assertReviewers(c, CC, user);
// Verify no approvals were added.
assertThat(c.labels).isNotNull();
LabelInfo label = c.labels.get("Code-Review");
assertThat(label).isNotNull();
assertThat(label.all).isNull();
} else {
// When approvals are stored in ReviewDb, we still create a label for
// the reviewing user, and force them into the REVIEWER state.
assertReviewers(c, REVIEWER, user);
assertReviewers(c, CC);
LabelInfo label = c.labels.get("Code-Review");
assertThat(label).isNotNull();
assertThat(label.all).isNotNull();
assertThat(label.all).hasSize(1);
ApprovalInfo approval = label.all.get(0);
assertThat(approval._accountId).isEqualTo(user.getId().get());
}
}
Aggregations