use of com.google.gerrit.server.query.change.ChangeData in project gerrit by GerritCodeReview.
the class PermissionBackendConditionIT method changePermissions_sameResourceDifferentUserDoesNotEqual.
@Test
public void changePermissions_sameResourceDifferentUserDoesNotEqual() throws Exception {
ChangeData change = createChange().getChange();
BooleanCondition cond1 = pb.user(user()).change(change).testCond(ChangePermission.READ);
BooleanCondition cond2 = pb.user(admin()).change(change).testCond(ChangePermission.READ);
assertNotEquals(cond1, cond2);
assertNotEquals(cond1.hashCode(), cond2.hashCode());
}
use of com.google.gerrit.server.query.change.ChangeData in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byAuthorEmail.
@Test
public void byAuthorEmail() throws Exception {
TestAccount user2 = accountCreator.create("Foo", "user@example.com", "User", /* displayName = */
null);
requestScopeOperations.setApiUser(user2.id());
ChangeInfo info = gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get();
ChangeData cd = changeQueryProvider.get().byLegacyChangeId(Change.Id.tryParse(Integer.toString(info._number)).get()).get(0);
// Match by email works
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^.*@example\\.com\"", SubmitRequirementResult.Status.SATISFIED);
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^user@.*\\.com\"", SubmitRequirementResult.Status.SATISFIED);
// Match by name does not work
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^Foo$\"", SubmitRequirementResult.Status.UNSATISFIED);
checkSubmitRequirementResult(cd, /* submittabilityExpr= */
"authoremail:\"^User$\"", SubmitRequirementResult.Status.UNSATISFIED);
}
use of com.google.gerrit.server.query.change.ChangeData 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);
}
use of com.google.gerrit.server.query.change.ChangeData in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_notMatchingWithFilePath.
@Test
public void byFileEdits_notMatchingWithFilePath() 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();
// commit edit only matches with files ending with ".java". Since our modified file name ends
// with ".txt", the applicability expression will not match.
SubmitRequirementExpression exp = SubmitRequirementExpression.create("file:\"'^.*\\.java',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.server.query.change.ChangeData in project gerrit by GerritCodeReview.
the class SubmitRequirementsEvaluatorIT method byFileEdits_modifiedContent_nonMatching.
@Test
public void byFileEdits_modifiedContent_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:\"'^.*\\.txt',withDiffContaining='ten'\"");
ChangeData childChangeData = changeQueryProvider.get().byLegacyChangeId(childId).get(0);
SubmitRequirementExpressionResult srResult = evaluator.evaluateExpression(exp, childChangeData);
assertThat(srResult.status()).isEqualTo(SubmitRequirementExpressionResult.Status.FAIL);
}
Aggregations