use of com.google.gerrit.extensions.common.SubmitRequirementInput 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.SubmitRequirementInput in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method createSubmitRequirementInput.
private static SubmitRequirementInput createSubmitRequirementInput(String name, String submittabilityExpression) {
SubmitRequirementInput input = new SubmitRequirementInput();
input.name = name;
input.submittabilityExpression = submittabilityExpression;
return input;
}
use of com.google.gerrit.extensions.common.SubmitRequirementInput in project gerrit by GerritCodeReview.
the class SubmitRequirementIT method checkSubmitRequirement_notApplicable.
@Test
public void checkSubmitRequirement_notApplicable() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
SubmitRequirementInput in = createSubmitRequirementInput("Code-Review", /* applicableIf= */
"branch:non-existent", /* submittableIf= */
"label:Code-Review=+2", /* overrideIf= */
null);
SubmitRequirementResultInfo result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.NOT_APPLICABLE);
voteLabel(changeId, "Code-Review", 2);
result = gApi.changes().id(changeId).checkSubmitRequirement(in);
assertThat(result.status).isEqualTo(SubmitRequirementResultInfo.Status.NOT_APPLICABLE);
}
use of com.google.gerrit.extensions.common.SubmitRequirementInput 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.SubmitRequirementInput 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