use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirement_alwaysNotApplicable.
@Test
public void submitRequirement_alwaysNotApplicable() {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"is:false", // redundant
"is:false", /* 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 globalSubmitRequirementEvaluated.
@Test
public void globalSubmitRequirementEvaluated() throws Exception {
SubmitRequirement globalSubmitRequirement = createSubmitRequirement(/*name=*/
"global-config-requirement", /* applicabilityExpr= */
"project:" + project.get(), /*submittabilityExpr= */
"is:true", /* overrideExpr= */
"", /*allowOverrideInChildProjects*/
false);
try (Registration registration = extensionRegistry.newRegistration().add(globalSubmitRequirement)) {
SubmitRequirement projectSubmitRequirement = createSubmitRequirement(/*name=*/
"project-config-requirement", /* applicabilityExpr= */
"project:" + project.get(), /*submittabilityExpr= */
"is:true", /* overrideExpr= */
"", /*allowOverrideInChildProjects*/
false);
configSubmitRequirement(project, projectSubmitRequirement);
Map<SubmitRequirement, SubmitRequirementResult> results = evaluator.evaluateAllRequirements(changeData, /* includeLegacy= */
false);
assertThat(results).hasSize(2);
assertThat(results.get(globalSubmitRequirement).status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
assertThat(results.get(projectSubmitRequirement).status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
}
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submittabilityAndOverrideEvaluated_whenApplicabilityIsEmpty.
@Test
public void submittabilityAndOverrideEvaluated_whenApplicabilityIsEmpty() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
null, /* submittabilityExpr= */
"message:\"Fix bug\"", /* overrideExpr= */
"label:\"build-cop-override=-1\"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
assertThat(result.applicabilityExpressionResult().isPresent()).isFalse();
assertThat(result.submittabilityExpressionResult().get().status()).isEqualTo(Status.PASS);
assertThat(result.overrideExpressionResult().get().status()).isEqualTo(Status.FAIL);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submittabilityAndOverrideEvaluated_whenApplicabilityIsTrue.
@Test
public void submittabilityAndOverrideEvaluated_whenApplicabilityIsTrue() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), /* submittabilityExpr= */
"message:\"Fix bug\"", /* overrideExpr= */
"label:\"build-cop-override=-1\"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
assertThat(result.applicabilityExpressionResult().get().status()).isEqualTo(Status.PASS);
assertThat(result.submittabilityExpressionResult().get().status()).isEqualTo(Status.PASS);
assertThat(result.overrideExpressionResult().get().status()).isEqualTo(Status.FAIL);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsError_whenApplicabilityExpressionHasInvalidSyntax.
@Test
public void submitRequirementIsError_whenApplicabilityExpressionHasInvalidSyntax() throws Exception {
addLabel("build-cop-override");
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"invalid_field:invalid_value", /* submittabilityExpr= */
"label:\"Code-Review=+2\"", /* overrideExpr= */
"label:\"build-cop-override=+1\"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.ERROR);
assertThat(result.applicabilityExpressionResult().get().errorMessage().get()).isEqualTo("Unsupported operator invalid_field:invalid_value");
}
Aggregations