use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_evaluatedWithInternalUserCredentials.
@Test
public void submitRequirement_evaluatedWithInternalUserCredentials() throws Exception {
GroupInput in = new GroupInput();
in.name = "invisible-group";
in.visibleToAll = false;
in.ownerId = adminGroupUuid().get();
gApi.groups().create(in);
configSubmitRequirement(project, SubmitRequirement.builder().setName("My-Requirement").setApplicabilityExpression(SubmitRequirementExpression.of("ownerin:invisible-group")).setSubmittabilityExpression(SubmitRequirementExpression.create("is:true")).setAllowOverrideInChildProjects(false).build());
requestScopeOperations.setApiUser(user.id());
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
ChangeInfo change = gApi.changes().id(changeId).get();
SubmitRequirementResultInfo srResult = change.submitRequirements.stream().filter(sr -> sr.name.equals("My-Requirement")).collect(MoreCollectors.onlyElement());
assertThat(srResult.status).isEqualTo(Status.NOT_APPLICABLE);
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs.
@Test
public void submitRequirements_eliminatesDuplicatesForLegacyMatchingSRs() 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, but both are fulfilled (i.e. they both allow submission). The
// submit requirements API returns one SR result with status=SATISFIED.
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.OK, "CR", SubmitRecord.Label.Status.MAY);
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.SATISFIED, /* isLegacy= */
true);
}
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method submitRequirement_applicabilityExpressionIsAlwaysHidden.
@Test
public void submitRequirement_applicabilityExpressionIsAlwaysHidden() throws Exception {
configSubmitRequirement(project, SubmitRequirement.builder().setName("Code-Review").setApplicabilityExpression(SubmitRequirementExpression.of("branch:refs/heads/master")).setSubmittabilityExpression(SubmitRequirementExpression.maxCodeReview()).setAllowOverrideInChildProjects(false).build());
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
voteLabel(changeId, "Code-Review", 2);
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
SubmitRequirementResultInfo requirement = changeInfo.submitRequirements.stream().collect(MoreCollectors.onlyElement());
assertSubmitRequirementExpression(requirement.applicabilityExpressionResult, /* expression= */
null, /* passingAtoms= */
null, /* failingAtoms= */
null, /* fulfilled= */
true);
assertThat(requirement.submittabilityExpressionResult).isNotNull();
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method checkSubmitRequirement_error.
@Test
public void checkSubmitRequirement_error() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* submittabilityExpression= */
"!!!");
SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.ERROR);
}
use of com.google.gerrit.extensions.common.SubmitRequirementResultInfo in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method checkSubmitRequirement_overridden.
@Test
public void checkSubmitRequirement_overridden() throws Exception {
// label function has no effect
configLabel("Override-Label", LabelFunction.NO_OP);
projectOperations.project(project).forUpdate().add(allowLabel("Override-Label").ref("refs/heads/master").group(REGISTERED_USERS).range(-1, 1)).update();
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* applicableIf= */
null, /* submittableIf= */
"label:Code-Review=+2", /* overrideIf= */
"label:Override-Label=+1");
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);
voteLabel(changeId, "Override-Label", 1);
result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.OVERRIDDEN);
}
Aggregations