Search in sources :

Example 1 with LabelId

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);
}
Also used : Account(com.google.gerrit.entities.Account) LabelType(com.google.gerrit.entities.LabelType) LabelId(com.google.gerrit.entities.LabelId) LabelId(com.google.gerrit.entities.LabelId) PatchSetApproval(com.google.gerrit.entities.PatchSetApproval)

Example 2 with LabelId

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);
}
Also used : LabelId(com.google.gerrit.entities.LabelId) Test(org.junit.Test)

Example 3 with 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);
}
Also used : LabelId(com.google.gerrit.entities.LabelId) Entities(com.google.gerrit.proto.Entities) Test(org.junit.Test)

Aggregations

LabelId (com.google.gerrit.entities.LabelId)3 Test (org.junit.Test)2 Account (com.google.gerrit.entities.Account)1 LabelType (com.google.gerrit.entities.LabelType)1 PatchSetApproval (com.google.gerrit.entities.PatchSetApproval)1 Entities (com.google.gerrit.proto.Entities)1