use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsOverridden_whenOverrideExpressionIsTrue.
@Test
public void submitRequirementIsOverridden_whenOverrideExpressionIsTrue() throws Exception {
addLabel("build-cop-override");
voteLabel(changeId, "build-cop-override", 1);
// Reload change data after applying the vote
changeData = changeQueryProvider.get().byLegacyChangeId(changeData.getId()).stream().collect(MoreCollectors.onlyElement());
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), /* submittabilityExpr= */
"label:\"Code-Review=+2\"", /* overrideExpr= */
"label:\"build-cop-override=+1\"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.OVERRIDDEN);
}
use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsError_whenOverrideExpressionHasInvalidSyntax.
@Test
public void submitRequirementIsError_whenOverrideExpressionHasInvalidSyntax() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), /* submittabilityExpr= */
"label:\"Code-Review=+2\"", /* overrideExpr= */
"invalid_field:invalid_value");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.ERROR);
assertThat(result.overrideExpressionResult().get().errorMessage().get()).isEqualTo("Unsupported operator invalid_field:invalid_value");
}
use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method checkSubmitRequirementResult.
private void checkSubmitRequirementResult(ChangeData cd, String submittabilityExpr, SubmitRequirementResult.Status expectedStatus) {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), submittabilityExpr, /* overrideExpr= */
"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, cd);
assertThat(result.status()).isEqualTo(expectedStatus);
}
use of com.google.gerrit.entities.SubmitRequirement 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.SubmitRequirement 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);
}
Aggregations