use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs.
@Test
public void submitRequirements_eliminatesDuplicatesForLegacyNonMatchingSRs() throws Exception {
// If a custom/prolog submit rule emits the same label name multiple times, we merge these into
// a single submit requirement result: in this test, we have two different submit rules that
// return the same label name, one as "OK" and the other as "NEED". The submit requirements
// API favours the blocking entry and returns one SR result with status=UNSATISFIED.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
SubmitRule r2 = createSubmitRule("r2", SubmitRecord.Status.NOT_READY, "CR", SubmitRecord.Label.Status.NEED);
try (Registration registration = extensionRegistry.newRegistration().add(r1).add(r2)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(2);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
assertSubmitRequirementStatus(submitRequirements, "CR", Status.UNSATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_overriden_submittabilityEvaluated.
@Test
public void submitRequirement_overriden_submittabilityEvaluated() throws Exception {
configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setApplicabilityExpression(Optional.empty()).setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setOverrideExpression(SubmitRequirementExpression.of("project:" + project.get())).setAllowOverrideInChildProjects(false).build());
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
voteLabel(changeId, "Code-Review", 1);
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
assertSubmitRequirementStatus(changeInfo.submitRequirements, "Code-Review", Status.OVERRIDDEN, /* isLegacy= */
false);
SubmitRequirementResultInfo requirement = changeInfo.submitRequirements.stream().filter(sr -> !sr.isLegacy).collect(MoreCollectors.onlyElement());
assertThat(requirement.applicabilityExpressionResult).isNull();
assertSubmitRequirementExpression(requirement.submittabilityExpressionResult, /* expression= */
SubmitRequirementExpression.maxCodeReview().expressionString(), /* passingAtoms= */
ImmutableList.of(), /* failingAtoms= */
ImmutableList.of(SubmitRequirementExpression.maxCodeReview().expressionString()), /* fulfilled= */
false);
assertSubmitRequirementExpression(requirement.overrideExpressionResult, /* expression= */
"project:" + project.get(), /* passingAtoms= */
ImmutableList.of("project:" + project.get()), /* failingAtoms= */
ImmutableList.of(), /* fulfilled= */
true);
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method checkSubmitRequirement_satisfied.
@Test
public void checkSubmitRequirement_satisfied() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* submittabilityExpression= */
"label:Code-Review=+2");
SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.UNSATISFIED);
voteLabel(changeId, "Code-Review", 2);
result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.SATISFIED);
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_skippedIfLegacySRIsBasedOnOptionalLabel.
@Test
public void submitRequirements_skippedIfLegacySRIsBasedOnOptionalLabel() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.MAY);
try (Registration registration = extensionRegistry.newRegistration().add(r1)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(1);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel.
@Test
public void submitRequirement_notSkippedIfLegacySRIsBasedOnNonOptionalLabel() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRule r1 = createSubmitRule("r1", SubmitRecord.Status.OK, "CR", SubmitRecord.Label.Status.OK);
try (Registration registration = extensionRegistry.newRegistration().add(r1)) {
ChangeInfo change = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = change.submitRequirements;
assertThat(submitRequirements).hasSize(2);
assertSubmitRequirementStatus(submitRequirements, "Code-Review", Status.UNSATISFIED, /* isLegacy= */
true);
assertSubmitRequirementStatus(submitRequirements, "CR", Status.SATISFIED, /* isLegacy= */
true);
}
}
Aggregations