use of com.google.gerrit.extensions.common.LabelInfo in project gerrit by GerritCodeReview.
the class CustomLabelIT method customLabelMaxNoBlock_MaxVoteSubmittable.
@Test
public void customLabelMaxNoBlock_MaxVoteSubmittable() throws Exception {
saveLabelConfig(LABEL.toBuilder().setFunction(MAX_NO_BLOCK), P.toBuilder().setFunction(NO_OP));
PushOneCommit.Result r = createChange();
assertThat(info(r.getChangeId()).submittable).isNull();
revision(r).review(ReviewInput.approve().label(LABEL_NAME, 1));
ChangeInfo c = getWithLabels(r);
assertThat(c.submittable).isTrue();
LabelInfo q = c.labels.get(LABEL_NAME);
assertThat(q.all).hasSize(1);
assertThat(q.approved).isNotNull();
assertThat(q.recommended).isNull();
assertThat(q.disliked).isNull();
assertThat(q.rejected).isNull();
assertThat(q.blocking).isNull();
}
use of com.google.gerrit.extensions.common.LabelInfo in project gerrit by GerritCodeReview.
the class CustomLabelIT method customLabelMaxWithBlock_MaxVoteNegativeVoteBlock.
@Test
public void customLabelMaxWithBlock_MaxVoteNegativeVoteBlock() throws Exception {
saveLabelConfig(LABEL.toBuilder().setFunction(MAX_WITH_BLOCK));
PushOneCommit.Result r = createChange();
revision(r).review(new ReviewInput().label(LABEL_NAME, 1));
revision(r).review(new ReviewInput().label(LABEL_NAME, -1));
ChangeInfo c = getWithLabels(r);
LabelInfo q = c.labels.get(LABEL_NAME);
assertThat(q.all).hasSize(1);
assertThat(q.approved).isNull();
assertThat(q.recommended).isNull();
assertThat(q.disliked).isNull();
assertThat(q.rejected).isNotNull();
assertThat(q.blocking).isTrue();
}
use of com.google.gerrit.extensions.common.LabelInfo in project gerrit by GerritCodeReview.
the class CommentAddedEventIT method reviewChange_MultipleVotes.
@Test
public void reviewChange_MultipleVotes() throws Exception {
TestListener listener = new TestListener();
try (Registration registration = extensionRegistry.newRegistration().add(listener)) {
saveLabelConfig();
PushOneCommit.Result r = createChange();
ReviewInput reviewInput = new ReviewInput().label(label.getName(), -1);
reviewInput.message = label.getName();
revision(r).review(reviewInput);
ChangeInfo c = get(r.getChangeId(), DETAILED_LABELS);
LabelInfo q = c.labels.get(label.getName());
assertThat(q.all).hasSize(1);
ApprovalValues labelAttr = getApprovalValues(label, listener);
assertThat(labelAttr.oldValue).isEqualTo(0);
assertThat(labelAttr.value).isEqualTo(-1);
assertThat(listener.getLastCommentAddedEvent().getComment()).isEqualTo(String.format("Patch Set 1: %s-1\n\n%s", label.getName(), label.getName()));
// there should be 3 approval labels (label, pLabel, and CRVV)
assertThat(listener.getLastCommentAddedEvent().getApprovals()).hasSize(3);
// check the approvals that were not voted on
ApprovalValues pLabelAttr = getApprovalValues(pLabel, listener);
assertThat(pLabelAttr.oldValue).isNull();
assertThat(pLabelAttr.value).isEqualTo(0);
LabelType crLabel = LabelType.withDefaultValues("Code-Review");
ApprovalValues crlAttr = getApprovalValues(crLabel, listener);
assertThat(crlAttr.oldValue).isNull();
assertThat(crlAttr.value).isEqualTo(0);
// update pLabel approval
reviewInput = new ReviewInput().label(pLabel.getName(), 1);
reviewInput.message = pLabel.getName();
revision(r).review(reviewInput);
c = get(r.getChangeId(), DETAILED_LABELS);
q = c.labels.get(label.getName());
assertThat(q.all).hasSize(1);
pLabelAttr = getApprovalValues(pLabel, listener);
assertThat(pLabelAttr.oldValue).isEqualTo(0);
assertThat(pLabelAttr.value).isEqualTo(1);
assertThat(listener.getLastCommentAddedEvent().getComment()).isEqualTo(String.format("Patch Set 1: %s+1\n\n%s", pLabel.getName(), pLabel.getName()));
// check the approvals that were not voted on
labelAttr = getApprovalValues(label, listener);
assertThat(labelAttr.oldValue).isNull();
assertThat(labelAttr.value).isEqualTo(-1);
crlAttr = getApprovalValues(crLabel, listener);
assertThat(crlAttr.oldValue).isNull();
assertThat(crlAttr.value).isEqualTo(0);
}
}
Aggregations