use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method submitRequirementIsSatisfied_whenSubmittabilityExpressionIsTrue.
@Test
public void submitRequirementIsSatisfied_whenSubmittabilityExpressionIsTrue() throws Exception {
SubmitRequirement sr = createSubmitRequirement(/* applicabilityExpr= */
"project:" + project.get(), /* submittabilityExpr= */
"message:\"Fix a bug\"", /* overrideExpr= */
"");
SubmitRequirementResult result = evaluator.evaluateRequirement(sr, changeData);
assertThat(result.status()).isEqualTo(SubmitRequirementResult.Status.SATISFIED);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method globalSubmitRequirement_duplicateInProjectConfig_overrideAllowed_projectResultReturned.
@Test
public void globalSubmitRequirement_duplicateInProjectConfig_overrideAllowed_projectResultReturned() throws Exception {
SubmitRequirement globalSubmitRequirement = createSubmitRequirement(/*name=*/
"config-requirement", /* applicabilityExpr= */
"project:" + project.get(), /*submittabilityExpr= */
"is:true", /* overrideExpr= */
"", /*allowOverrideInChildProjects*/
true);
try (Registration registration = extensionRegistry.newRegistration().add(globalSubmitRequirement)) {
SubmitRequirement projectSubmitRequirement = createSubmitRequirement(/*name=*/
"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(1);
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 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.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementJsonSerializerTest method submitRequirementResult_emptySubmittabilityExpressionResultField_roundTrip.
@Test
public void submitRequirementResult_emptySubmittabilityExpressionResultField_roundTrip() throws Exception {
SubmitRequirementResult srResult = srReqResult.toBuilder().submittabilityExpressionResult(Optional.empty()).applicabilityExpressionResult(Optional.empty()).overrideExpressionResult(Optional.empty()).build();
TypeAdapter<SubmitRequirementResult> adapter = SubmitRequirementResult.typeAdapter(gson);
assertThat(adapter.fromJson(adapter.toJson(srResult))).isEqualTo(srResult);
}
use of com.google.gerrit.entities.SubmitRequirementResult in project gerrit by GerritCodeReview.
the class SubmitRequirementJsonSerializerTest method submitRequirementResult_withHidden_roundTrip.
@Test
public void submitRequirementResult_withHidden_roundTrip() throws Exception {
SubmitRequirementResult srResultWithHidden = srReqResult.toBuilder().hidden(Optional.of(true)).build();
TypeAdapter<SubmitRequirementResult> adapter = SubmitRequirementResult.typeAdapter(gson);
assertThat(adapter.fromJson(adapter.toJson(srResultWithHidden))).isEqualTo(srResultWithHidden);
}
Aggregations