use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_invalidFilePattern.
@Test
public void byFileEdits_invalidFilePattern() throws Exception {
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^**',withDiffContaining='content'\"");
SubmitRequirementExpressionResult srResult = evaluator.evaluateExpression(exp, changeData);
assertThat(srResult.status()).isEqualTo(SubmitRequirementExpressionResult.Status.ERROR);
assertThat(srResult.errorMessage().get()).isEqualTo("Invalid file pattern.");
}
use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_modifiedContent_matching.
@Test
public void byFileEdits_modifiedContent_matching() throws Exception {
Change.Id parent = changeOperations.newChange().file(FILE_NAME).content(CONTENT).create();
Change.Id childId = changeOperations.newChange().file(FILE_NAME).content(CONTENT.replace("line 3\n", "line three\n")).childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.txt',withDiffContaining='three'\"");
ChangeData childChangeData = changeQueryProvider.get().byLegacyChangeId(childId).get(0);
SubmitRequirementExpressionResult srResult = evaluator.evaluateExpression(exp, childChangeData);
assertThat(srResult.status()).isEqualTo(SubmitRequirementExpressionResult.Status.PASS);
}
use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_exactMatchingWithFilePath_nonMatching.
@Test
public void byFileEdits_exactMatchingWithFilePath_nonMatching() throws Exception {
Change.Id parent = changeOperations.newChange().file(FILE_NAME).content(CONTENT).create();
Change.Id childId = changeOperations.newChange().file(FILE_NAME).content(CONTENT.replace("line 3\n", "line three\n")).childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'non_existent.txt',withDiffContaining='three'\"");
ChangeData childChangeData = changeQueryProvider.get().byLegacyChangeId(childId).get(0);
SubmitRequirementExpressionResult srResult = evaluator.evaluateExpression(exp, childChangeData);
assertThat(srResult.status()).isEqualTo(SubmitRequirementExpressionResult.Status.FAIL);
}
use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementJsonSerializerTest method submitRequirementExpression_roundTrip.
@Test
public void submitRequirementExpression_roundTrip() throws Exception {
SubmitRequirementExpression exp = SubmitRequirementExpression.create("label:Code-Review=+2");
TypeAdapter<SubmitRequirementExpression> adapter = SubmitRequirementExpression.typeAdapter(gson);
assertThat(adapter.fromJson(adapter.toJson(exp))).isEqualTo(exp);
}
Aggregations