use of com.google.gerrit.entities.LabelId in project gerrit by GerritCodeReview.
the class ApprovalsUtil method addReviewers.
private List<PatchSetApproval> addReviewers(ChangeUpdate update, LabelTypes labelTypes, Change change, PatchSet.Id psId, Account.Id authorId, Account.Id committerId, Iterable<Account.Id> wantReviewers, Collection<Account.Id> existingReviewers) {
List<LabelType> allTypes = labelTypes.getLabelTypes();
if (allTypes.isEmpty()) {
return ImmutableList.of();
}
Set<Account.Id> need = Sets.newLinkedHashSet(wantReviewers);
if (authorId != null && canSee(update.getNotes(), authorId)) {
need.add(authorId);
}
if (committerId != null && canSee(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(PatchSetApproval.builder().key(PatchSetApproval.key(psId, account, labelId)).value(0).granted(update.getWhen()).build());
update.putReviewer(account, REVIEWER);
}
return Collections.unmodifiableList(cells);
}
use of com.google.gerrit.entities.LabelId in project gerrit by GerritCodeReview.
the class LabelIdProtoConverterTest method allValuesConvertedToProtoAndBackAgain.
@Test
public void allValuesConvertedToProtoAndBackAgain() {
LabelId labelId = LabelId.create("label-5");
LabelId convertedLabelId = labelIdProtoConverter.fromProto(labelIdProtoConverter.toProto(labelId));
assertThat(convertedLabelId).isEqualTo(labelId);
}
use of com.google.gerrit.entities.LabelId in project gerrit by GerritCodeReview.
the class LabelIdProtoConverterTest method allValuesConvertedToProto.
@Test
public void allValuesConvertedToProto() {
LabelId labelId = LabelId.create("Label ID 42");
Entities.LabelId proto = labelIdProtoConverter.toProto(labelId);
Entities.LabelId expectedProto = Entities.LabelId.newBuilder().setId("Label ID 42").build();
assertThat(proto).isEqualTo(expectedProto);
}