use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsNotApplicable_whenApplicabilityExpressionIsFalse.
@Test
public void submitRequirementIsNotApplicable_whenApplicabilityExpressionIsFalse() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:non-existent-project", /* submittabilityExpr= */
"message:\"Fix bug\"", /* overrideExpr= */
"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.NOT_APPLICABLE);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submittabilityIsEvaluated_whenOverrideApplies.
@Test
public void submittabilityIsEvaluated_whenOverrideApplies() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
null, /* submittabilityExpr= */
"message:\"Fix bug\"", /* overrideExpr= */
"project:" + project.get());
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.OVERRIDDEN);
assertThat(result.applicabilityExpressionResult().isPresent()).isFalse();
assertThat(result.submittabilityExpressionResult().get().status()).isEqualTo(Status.PASS);
assertThat(result.overrideExpressionResult().get().status()).isEqualTo(Status.PASS);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsAdapterTest method defaultSubmitRule_withLabelStatusNeed_labelHasIgnoreSelfApproval.
@Test
public void defaultSubmitRule_withLabelStatusNeed_labelHasIgnoreSelfApproval() throws Exception {
SubmitRecord submitRecord = createSubmitRecord(DefaultSubmitRule.RULE_NAME, Status.NOT_READY, Arrays.asList(createLabel("ISA-Label", Label.Status.NEED)));
List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
false);
assertThat(requirements).hasSize(1);
assertResult(requirements.get(0), /* reqName= */
"ISA-Label", /* submitExpression= */
"label:ISA-Label=MAX,user=non_uploader -label:ISA-Label=MIN", SubmitRequirementResult.Status.UNSATISFIED, SubmitRequirementExpressionResult.Status.FAIL);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsAdapterTest method defaultSubmitRule_withLabelStatusOk_labelHasIgnoreSelfApproval.
@Test
public void defaultSubmitRule_withLabelStatusOk_labelHasIgnoreSelfApproval() throws Exception {
SubmitRecord submitRecord = createSubmitRecord(DefaultSubmitRule.RULE_NAME, Status.OK, Arrays.asList(createLabel("ISA-Label", Label.Status.OK)));
List<SubmitRequirementResult> requirements = SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId, /* isForced= */
false);
assertThat(requirements).hasSize(1);
assertResult(requirements.get(0), /* reqName= */
"ISA-Label", /* submitExpression= */
"label:ISA-Label=MAX,user=non_uploader -label:ISA-Label=MIN", SubmitRequirementResult.Status.SATISFIED, SubmitRequirementExpressionResult.Status.PASS);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class CheckSubmitRequirement method apply.
@Override
public Response<SubmitRequirementResultInfo> apply(ChangeResource resource, SubmitRequirementInput input) throws BadRequestException {
SubmitRequirement requirement = createSubmitRequirement(input);
SubmitRequirementResult res = evaluator.evaluateRequirement(requirement, resource.getChangeData());
return Response.ok(SubmitRequirementsJson.toInfo(requirement, res));
}
Aggregations