use of com.google.gerrit.server.project.SubmitRuleEvaluator in project gerrit by GerritCodeReview.
the class SubmitRuleIT method submitRecordsForClosedChanges_recomputedIfRequested.
@Test
public void submitRecordsForClosedChanges_recomputedIfRequested() throws Exception {
SubmitRuleEvaluator submitRuleEvaluator = submitRuleEvaluatorFactory.create(SubmitRuleOptions.builder().recomputeOnClosedChanges(true).build());
PushOneCommit.Result r = createChange();
approve(r.getChangeId());
List<SubmitRecord> recordsBeforeSubmission = submitRuleEvaluator.evaluate(r.getChange());
assertThat(recordsBeforeSubmission.stream().map(record -> record.ruleName).collect(Collectors.toList())).containsExactly(DefaultSubmitRule.RULE_NAME);
gApi.changes().id(r.getChangeId()).current().submit();
// Add a new label that blocks submission if not granted. In case we reevaluate the rules,
// this would show up as blocking submission.
setupCustomBlockingLabel();
List<SubmitRecord> recordsAfterSubmission = submitRuleEvaluator.evaluate(r.getChange());
assertThat(recordsBeforeSubmission).isNotEqualTo(recordsAfterSubmission);
assertThat(recordsAfterSubmission).hasSize(1);
List<SubmitRecord.Label> recordLabels = recordsAfterSubmission.get(0).labels;
assertThat(recordLabels).hasSize(2);
assertCodeReviewApproved(recordLabels);
assertMyLabelNeed(recordLabels);
}
use of com.google.gerrit.server.project.SubmitRuleEvaluator in project gerrit by GerritCodeReview.
the class RulesIT method getStatus.
private SubmitRecord.Status getStatus(PushOneCommit.Result result) throws Exception {
ChangeData cd = result.getChange();
Collection<SubmitRecord> records;
try (AutoCloseable ignored1 = disableChangeIndex();
AutoCloseable ignored2 = disableAccountIndex()) {
SubmitRuleEvaluator ruleEvaluator = evaluatorFactory.create(SubmitRuleOptions.defaults());
records = ruleEvaluator.evaluate(cd);
}
assertThat(records).hasSize(1);
SubmitRecord record = records.iterator().next();
return record.status;
}
Aggregations