use of com.google.gerrit.reviewdb.client.LabelId in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchSetApprovals.
@Test
public void diffPatchSetApprovals() throws Exception {
Change c = TestChanges.newChange(project, accountId);
PatchSetApproval a1 = new PatchSetApproval(new PatchSetApproval.Key(c.currentPatchSetId(), accountId, new LabelId("Code-Review")), (short) 1, TimeUtil.nowTs());
PatchSetApproval a2 = clone(a1);
ChangeBundle b1 = new ChangeBundle(c, messages(), latest(c), approvals(a1), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), latest(c), approvals(a2), comments(), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
a2.setValue((short) -1);
assertDiffs(b1, b2, "value differs for PatchSetApproval.Key " + c.getId() + "%2C1,100,Code-Review: {1} != {-1}");
}
use of com.google.gerrit.reviewdb.client.LabelId in project gerrit by GerritCodeReview.
the class ApprovalsUtil method addReviewers.
private List<PatchSetApproval> addReviewers(ReviewDb db, ChangeUpdate update, LabelTypes labelTypes, Change change, PatchSet.Id psId, Account.Id authorId, Account.Id committerId, Iterable<Account.Id> wantReviewers, Collection<Account.Id> existingReviewers) throws OrmException {
List<LabelType> allTypes = labelTypes.getLabelTypes();
if (allTypes.isEmpty()) {
return ImmutableList.of();
}
Set<Account.Id> need = Sets.newLinkedHashSet(wantReviewers);
if (authorId != null && canSee(db, update.getNotes(), authorId)) {
need.add(authorId);
}
if (committerId != null && canSee(db, update.getNotes(), committerId)) {
need.add(committerId);
}
need.remove(change.getOwner());
need.removeAll(existingReviewers);
if (need.isEmpty()) {
return ImmutableList.of();
}
List<PatchSetApproval> cells = Lists.newArrayListWithCapacity(need.size());
LabelId labelId = Iterables.getLast(allTypes).getLabelId();
for (Account.Id account : need) {
cells.add(new PatchSetApproval(new PatchSetApproval.Key(psId, account, labelId), (short) 0, update.getWhen()));
update.putReviewer(account, REVIEWER);
}
db.patchSetApprovals().upsert(cells);
return Collections.unmodifiableList(cells);
}
Aggregations