use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class CommentsIT method listComments.
@Test
public void listComments() throws Exception {
String file = "file";
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, "first subject", file, "contents");
PushOneCommit.Result r = push.to("refs/for/master");
String changeId = r.getChangeId();
String revId = r.getCommit().getName();
assertThat(getPublishedComments(changeId, revId)).isEmpty();
List<CommentInput> expectedComments = new ArrayList<>();
for (Integer line : lines) {
ReviewInput input = new ReviewInput();
CommentInput comment = newComment(file, Side.REVISION, line, "comment " + line, false);
expectedComments.add(comment);
input.comments = new HashMap<>();
input.comments.put(comment.path, Lists.newArrayList(comment));
revision(r).review(input);
}
Map<String, List<CommentInfo>> result = getPublishedComments(changeId, revId);
assertThat(result).isNotEmpty();
List<CommentInfo> actualComments = result.get(file);
assertThat(Lists.transform(actualComments, infoToInput(file))).containsExactlyElementsIn(expectedComments);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ProjectLevelConfigIT method accessProjectSpecificConfig.
@Test
public void accessProjectSpecificConfig() throws Exception {
String configName = "test.config";
Config cfg = new Config();
cfg.setString("s1", null, "k1", "v1");
cfg.setString("s2", "ss", "k2", "v2");
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, "Create Project Level Config", configName, cfg.toText());
push.to(RefNames.REFS_CONFIG);
ProjectState state = projectCache.get(project);
assertThat(state.getConfig(configName).get().toText()).isEqualTo(cfg.toText());
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class TagsIT method lightweightTag.
@Test
public void lightweightTag() throws Exception {
grantTagPermissions();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/heads/master");
r.assertOkStatus();
TagInput input = new TagInput();
input.ref = "v1.0";
input.revision = r.getCommit().getName();
TagInfo result = tag(input.ref).create(input).get();
assertThat(result.ref).isEqualTo(R_TAGS + input.ref);
assertThat(result.revision).isEqualTo(input.revision);
assertThat(result.canDelete).isTrue();
input.ref = "refs/tags/v2.0";
result = tag(input.ref).create(input).get();
assertThat(result.ref).isEqualTo(input.ref);
assertThat(result.revision).isEqualTo(input.revision);
assertThat(result.canDelete).isTrue();
setApiUser(user);
result = tag(input.ref).get();
assertThat(result.canDelete).isFalse();
eventRecorder.assertRefUpdatedEvents(project.get(), result.ref, null, result.revision);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method createNewPatchSetOnInvisibleDraftPatchSet.
@Test
public void createNewPatchSetOnInvisibleDraftPatchSet() throws Exception {
// Clone separate repositories of the same project as admin and as user
TestRepository<InMemoryRepository> adminTestRepo = cloneProject(project, admin);
TestRepository<InMemoryRepository> userTestRepo = cloneProject(project, user);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Amend draft as admin
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/drafts/master", admin, adminTestRepo);
r2.assertOkStatus();
// Fetch change
GitUtil.fetch(userTestRepo, r1.getPatchSet().getRefName() + ":ps");
userTestRepo.reset("ps");
// Amend change as user
PushOneCommit.Result r3 = amendChange(r1.getChangeId(), "refs/for/master", user, userTestRepo);
r3.assertErrorStatus("cannot add patch set to " + r3.getChange().change().getChangeId() + ".");
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method pushCommitOfOtherUser.
@Test
public void pushCommitOfOtherUser() throws Exception {
// admin pushes commit of user
PushOneCommit push = pushFactory.create(db, user.getIdent(), testRepo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
assertThat(change.owner._accountId).isEqualTo(admin.id.get());
CommitInfo commit = change.revisions.get(change.currentRevision).commit;
assertThat(commit.author.email).isEqualTo(user.email);
assertThat(commit.committer.email).isEqualTo(user.email);
// check that the author/committer was added as reviewer
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(admin.fullName + " has uploaded this change for review");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, admin.email);
}
Aggregations