use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_deletedContent_nonMatching.
@Test
public void byFileEdits_deletedContent_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 1\n", "")).childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.txt',withDiffContaining='line 2'\"");
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 SubmitRequirementsEvaluatorIT method expressionWithPassingPredicate.
@Test
public void expressionWithPassingPredicate() throws Exception {
SubmitRequirementExpression expression = SubmitRequirementExpression.create("branch:refs/heads/master");
SubmitRequirementExpressionResult result = evaluator.evaluateExpression(expression, changeData);
assertThat(result.status()).isEqualTo(Status.PASS);
assertThat(result.errorMessage()).isEqualTo(Optional.empty());
}
use of com.google.gerrit.entities.SubmitRequirementExpression in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_deletedContent_matching.
@Test
public void byFileEdits_deletedContent_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 2\n", "")).childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.txt',withDiffContaining='line 2'\"");
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_escapeDoubleQuotes.
@Test
public void byFileEdits_escapeDoubleQuotes() 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\" is modified\n")).childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.txt',withDiffContaining='line \\\"three\\\" is'\"");
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_addedContent_matching.
@Test
public void byFileEdits_addedContent_matching() throws Exception {
Change.Id parent = changeOperations.newChange().file(FILE_NAME).content(CONTENT).create();
Change.Id childId = changeOperations.newChange().file(FILE_NAME).content(CONTENT + "line 4\n").childOf().change(parent).create();
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.txt',withDiffContaining='line 4'\"");
ChangeData childChangeData = changeQueryProvider.get().byLegacyChangeId(childId).get(0);
SubmitRequirementExpressionResult srResult = evaluator.evaluateExpression(exp, childChangeData);
assertThat(srResult.status()).isEqualTo(SubmitRequirementExpressionResult.Status.PASS);
}
Aggregations