use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsUnsatisfied_whenSubmittabilityExpressionIsFalse.
@Test
public void submitRequirementIsUnsatisfied_whenSubmittabilityExpressionIsFalse() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), /* submittabilityExpr= */
"label:\"Code-Review=+2\"", /* overrideExpr= */
"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.UNSATISFIED);
assertThat(result.submittabilityExpressionResult().get().failingAtoms()).containsExactly("label:\"Code-Review=+2\"");
}
use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class ProjectConfigTest method readSubmitRequirementEmpty.
@Test
public void readSubmitRequirementEmpty() throws Exception {
RevCommit rev = tr.commit().add("groups", group(developers)).add("project.config", "[submit-requirement \"Code-Review\"]\n" + " submittableIf = label(Code-Review, +2)\n").create();
ProjectConfig cfg = read(rev);
Map<String, SubmitRequirement> submitRequirements = cfg.getSubmitRequirementSections();
assertThat(submitRequirements).containsExactly("Code-Review", SubmitRequirement.builder().setName("Code-Review").setSubmittabilityExpression(SubmitRequirementExpression.create("label(Code-Review, +2)")).setAllowOverrideInChildProjects(false).build());
}
use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class ProjectConfigTest method readSubmitRequirementsIdentical_WithCapitalizationDifference.
@Test
public void readSubmitRequirementsIdentical_WithCapitalizationDifference() throws Exception {
RevCommit rev = tr.commit().add("groups", group(developers)).add("project.config", "[submit-requirement \"code-review\"]\n" + " description = At least one Code Review +2\n" + " submittableIf = label(code-review, +2)\n" + "[submit-requirement \"Code-Review\"]\n" + " description = Another code review label\n" + " submittableIf = label(code-review, +2)\n" + " canOverrideInChildProjects = true\n").create();
ProjectConfig cfg = read(rev);
Map<String, SubmitRequirement> submitRequirements = cfg.getSubmitRequirementSections();
assertThat(submitRequirements).containsExactly("code-review", SubmitRequirement.builder().setName("code-review").setDescription(Optional.of("At least one Code Review +2")).setSubmittabilityExpression(SubmitRequirementExpression.create("label(code-review, +2)")).setAllowOverrideInChildProjects(false).build());
assertThat(cfg.getValidationErrors()).hasSize(1);
assertThat(Iterables.getOnlyElement(cfg.getValidationErrors()).getMessage()).isEqualTo("project.config: Submit requirement 'Code-Review' conflicts with 'code-review'.");
}
use of com.google.gerrit.entities.SubmitRequirement in project gerrit by GerritCodeReview.
the class ProjectConfigTest method readSubmitRequirementNoSubmittabilityExpression.
@Test
public void readSubmitRequirementNoSubmittabilityExpression() throws Exception {
RevCommit rev = tr.commit().add("groups", group(developers)).add("project.config", "[submit-requirement \"Code-Review\"]\n" + " applicableIf =label(Code-Review, +2)\n").create();
ProjectConfig cfg = read(rev);
Map<String, SubmitRequirement> submitRequirements = cfg.getSubmitRequirementSections();
assertThat(submitRequirements).isEmpty();
assertThat(cfg.getValidationErrors()).hasSize(1);
assertThat(Iterables.getOnlyElement(cfg.getValidationErrors()).getMessage()).isEqualTo("project.config: Setting a submittability expression for submit requirement" + " 'Code-Review' is required: Missing" + " submit-requirement.Code-Review.submittableIf");
}
Aggregations