use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeNotesTest method approvalUUID_samePatchSet_differentUsers.
@Test
public void approvalUUID_samePatchSet_differentUsers() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
update.putApproval(LabelId.CODE_REVIEW, (short) -1);
update.putApprovalFor(otherUserId, LabelId.CODE_REVIEW, (short) -1);
update.commit();
ChangeNotes notes = newNotes(c);
assertThat(notes.getApprovals().keySet()).containsExactly(c.currentPatchSetId());
List<PatchSetApproval> patchSetApprovals = notes.getApprovals().get(c.currentPatchSetId());
assertThat(patchSetApprovals).hasSize(2);
assertThat(patchSetApprovals.stream().filter(psa -> psa.value() == (short) -1 && psa.label().equals(LabelId.CODE_REVIEW)).count()).isEqualTo(2);
// Count UUIDs to make sure they are unique
assertThat(patchSetApprovals.stream().map(psa -> psa.uuid().get()).distinct().count()).isEqualTo(2);
assertThat(patchSetApprovals.stream().map(psa -> psa.accountId()).collect(toImmutableSet())).containsExactly(changeOwner.getAccountId(), otherUserId);
}
use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.
the class IgnoreSelfApprovalRuleTest method filtersByLabel.
@Test
public void filtersByLabel() {
LabelType codeReview = makeLabel(LabelId.CODE_REVIEW);
PatchSetApproval approvalVerified = makeApproval(VERIFIED.getLabelId(), USER1, 2);
PatchSetApproval approvalCr = makeApproval(codeReview.getLabelId(), USER1, 2);
Collection<PatchSetApproval> filteredApprovals = IgnoreSelfApprovalRule.filterApprovalsByLabel(ImmutableList.of(approvalVerified, approvalCr), VERIFIED);
assertThat(filteredApprovals).containsExactly(approvalVerified);
}
use of com.google.gerrit.entities.PatchSetApproval in project gerrit by GerritCodeReview.
the class IgnoreSelfApprovalRuleTest method filtersVotesFromUser.
@Test
public void filtersVotesFromUser() {
PatchSetApproval approvalM2 = makeApproval(VERIFIED.getLabelId(), USER1, -2);
PatchSetApproval approvalM1 = makeApproval(VERIFIED.getLabelId(), USER1, -1);
ImmutableList<PatchSetApproval> approvals = ImmutableList.of(approvalM2, approvalM1, makeApproval(VERIFIED.getLabelId(), USER1, 0), makeApproval(VERIFIED.getLabelId(), USER1, +1), makeApproval(VERIFIED.getLabelId(), USER1, +2));
Collection<PatchSetApproval> filteredApprovals = IgnoreSelfApprovalRule.filterOutPositiveApprovalsOfUser(approvals, USER1);
assertThat(filteredApprovals).containsExactly(approvalM1, approvalM2);
}
Aggregations