use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method pushCommitWithFooterOfOtherUser.
@Test
public void pushCommitWithFooterOfOtherUser() throws Exception {
// admin pushes commit that references 'user' in a footer
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT + "\n\n" + FooterConstants.REVIEWED_BY.getName() + ": " + user.getIdent().toExternalString(), PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
// check that 'user' was added as reviewer
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
Collection<AccountInfo> reviewers = change.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(user.getId().get());
assertThat(change.reviewers.get(CC)).isNull();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(user.emailAddress);
assertThat(m.body()).contains("Hello " + user.fullName + ",\n");
assertThat(m.body()).contains("I'd like you to do a code review.");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, admin.email);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class RevisionIT method createCherryPickableMerge.
private PushOneCommit.Result createCherryPickableMerge(String parent1FileName, String parent2FileName) throws Exception {
RevCommit initialCommit = getHead(repo());
String branchAName = "branchA";
createBranch(new Branch.NameKey(project, branchAName));
String branchBName = "branchB";
createBranch(new Branch.NameKey(project, branchBName));
PushOneCommit.Result changeAResult = pushFactory.create(db, admin.getIdent(), testRepo, "change a", parent1FileName, "Content of a").to("refs/for/" + branchAName);
testRepo.reset(initialCommit);
PushOneCommit.Result changeBResult = pushFactory.create(db, admin.getIdent(), testRepo, "change b", parent2FileName, "Content of b").to("refs/for/" + branchBName);
PushOneCommit pushableMergeCommit = pushFactory.create(db, admin.getIdent(), testRepo, "merge", ImmutableMap.of(parent1FileName, "Content of a", parent2FileName, "Content of b"));
pushableMergeCommit.setParents(ImmutableList.of(changeAResult.getCommit(), changeBResult.getCommit()));
PushOneCommit.Result mergeChangeResult = pushableMergeCommit.to("refs/for/" + branchAName);
mergeChangeResult.assertOkStatus();
return mergeChangeResult;
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushNewPatchSetForMasterWithApprovals.
@Test
public void pushNewPatchSetForMasterWithApprovals() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master/%l=Code-Review+2");
ChangeInfo ci = get(r.getChangeId());
LabelInfo cr = ci.labels.get("Code-Review");
assertThat(Iterables.getLast(ci.messages).message).isEqualTo("Uploaded patch set 2: Code-Review+2.");
// Check that the user who pushed the new patch set was added as a reviewer since they added
// a vote
assertThatUserIsOnlyReviewer(ci, admin);
assertThat(cr.all).hasSize(1);
assertThat(cr.all.get(0).name).isEqualTo("Administrator");
assertThat(cr.all.get(0).value).isEqualTo(2);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushSameCommitTwiceWhenIndexFailed.
@Test
public void pushSameCommitTwiceWhenIndexFailed() throws Exception {
ProjectConfig config = projectCache.checkedGet(project).getConfig();
config.getProject().setCreateNewChangeForAllNotInTarget(InheritableBoolean.TRUE);
saveProjectConfig(project, config);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
PushOneCommit.Result r = push.to("refs/for/master");
r.assertOkStatus();
push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
r = push.to("refs/for/master");
r.assertOkStatus();
indexer.delete(r.getChange().getId());
assertPushRejected(pushHead(testRepo, "refs/for/master", false), "refs/for/master", "commit(s) already exists (as current patchset)");
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushNewPatchsetToRefsChanges.
@Test
public void pushNewPatchsetToRefsChanges() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/changes/" + r.getChange().change().getId().get());
r.assertOkStatus();
}
Aggregations