use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_nonApplicable_submittabilityAndOverrideNotEvaluated.
@Test
public void submitRequirement_nonApplicable_submittabilityAndOverrideNotEvaluated() throws Exception {
configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setApplicabilityExpression(SubmitRequirementExpression.of("branch:refs/heads/non-existent")).setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setOverrideExpression(SubmitRequirementExpression.of("project:" + project.get())).setAllowOverrideInChildProjects(false).build());
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
voteLabel(changeId, "Code-Review", 2);
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
assertSubmitRequirementStatus(changeInfo.submitRequirements, "Code-Review", Status.NOT_APPLICABLE, /* isLegacy= */
false);
SubmitRequirementResultInfo requirement = changeInfo.submitRequirements.stream().collect(MoreCollectors.onlyElement());
assertSubmitRequirementExpression(requirement.applicabilityExpressionResult, /* expression= */
null, /* passingAtoms= */
null, /* failingAtoms= */
null, /* fulfilled= */
false);
assertThat(requirement.submittabilityExpressionResult).isNull();
assertThat(requirement.overrideExpressionResult).isNull();
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method legacySubmitRequirementWithIgnoreSelfApproval.
@Test
public void legacySubmitRequirementWithIgnoreSelfApproval() throws Exception {
LabelType verified = label(LabelId.VERIFIED, value(1, "Passes"), value(0, "No score"), value(-1, "Failed"));
verified = verified.toBuilder().setIgnoreSelfApproval(true).build();
try (ProjectConfigUpdate u = updateProject(project)) {
u.getConfig().upsertLabelType(verified);
u.save();
}
projectOperations.project(project).forUpdate().add(allowLabel(verified.getName()).ref(RefNames.REFS_HEADS + "*").group(REGISTERED_USERS).range(-1, 1)).update();
// The DefaultSubmitRule emits an "OK" submit record for Verified, while the
// ignoreSelfApprovalRule emits a "NEED" submit record. The "submit requirements" adapter merges
// both results and returns the blocking one only.
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
gApi.changes().id(changeId).addReviewer(user.id().toString());
voteLabel(changeId, verified.getName(), +1);
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
Collection<SubmitRequirementResultInfo> submitRequirements = changeInfo.submitRequirements;
assertSubmitRequirementStatus(submitRequirements, "Verified", Status.UNSATISFIED, /* isLegacy= */
true);
}
Aggregations