use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class CommentsIT method queryChangesWithCommentCount.
@Test
public void queryChangesWithCommentCount() throws Exception {
// PS1 has three comments in three different threads, PS2 has one comment in one thread.
PushOneCommit.Result result = createChange("change 1", FILE_NAME, "content 1");
String changeId1 = result.getChangeId();
CommentsUtil.addComment(gApi, result, "comment 1", false, true, null);
CommentsUtil.addComment(gApi, result, "comment 2", false, null, null);
CommentsUtil.addComment(gApi, result, "comment 3", false, false, null);
PushOneCommit.Result result2 = amendChange(changeId1);
CommentsUtil.addComment(gApi, result2, "comment4", false, true, null);
// Change2 has two comments in one thread, the first is unresolved and the second is resolved.
result = createChange("change 2", FILE_NAME, "content 2");
String changeId2 = result.getChangeId();
CommentsUtil.addComment(gApi, result, "comment 1", false, true, null);
Map<String, List<CommentInfo>> comments = getPublishedComments(changeId2, result.getCommit().name());
assertThat(comments).hasSize(1);
assertThat(comments.get(FILE_NAME)).hasSize(1);
CommentsUtil.addComment(gApi, result, "comment 2", false, false, comments.get(FILE_NAME).get(0).id);
// Change3 has two comments in one thread, the first is resolved, the second is unresolved.
result = createChange("change 3", FILE_NAME, "content 3");
String changeId3 = result.getChangeId();
CommentsUtil.addComment(gApi, result, "comment 1", false, false, null);
comments = getPublishedComments(result.getChangeId(), result.getCommit().name());
assertThat(comments).hasSize(1);
assertThat(comments.get(FILE_NAME)).hasSize(1);
CommentsUtil.addComment(gApi, result, "comment 2", false, true, comments.get(FILE_NAME).get(0).id);
try (AutoCloseable ignored = disableNoteDb()) {
ChangeInfo changeInfo1 = Iterables.getOnlyElement(query(changeId1));
ChangeInfo changeInfo2 = Iterables.getOnlyElement(query(changeId2));
ChangeInfo changeInfo3 = Iterables.getOnlyElement(query(changeId3));
assertThat(changeInfo1.unresolvedCommentCount).isEqualTo(2);
assertThat(changeInfo1.totalCommentCount).isEqualTo(4);
assertThat(changeInfo2.unresolvedCommentCount).isEqualTo(0);
assertThat(changeInfo2.totalCommentCount).isEqualTo(2);
assertThat(changeInfo3.unresolvedCommentCount).isEqualTo(1);
assertThat(changeInfo3.totalCommentCount).isEqualTo(2);
}
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revertChangeWithLongSubject.
@Test
public void revertChangeWithLongSubject() throws Exception {
String changeTitle = "This change has a very long title and therefore it will be cut to 50 characters when the" + " revert change will revert this change";
String result = createChange(changeTitle, "a.txt", "message").getChangeId();
gApi.changes().id(result).current().review(ReviewInput.approve());
gApi.changes().id(result).current().submit();
RevertInput revertInput = new RevertInput();
ChangeInfo revertChange = gApi.changes().id(result).revert(revertInput).get();
assertThat(revertChange.subject).isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 59)));
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", changeTitle.substring(0, 59), gApi.changes().id(result).get().currentRevision, revertChange.changeId));
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revertNotifications.
@Test
public void revertNotifications() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).addReviewer(user.email());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
sender.clear();
ChangeInfo revertChange = gApi.changes().id(r.getChangeId()).revert().get();
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(2);
assertThat(sender.getMessages(revertChange.changeId, "newchange")).hasSize(1);
assertThat(sender.getMessages(r.getChangeId(), "revert")).hasSize(1);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revertChangeWithWip.
@Test
public void revertChangeWithWip() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
RevertInput in = createWipRevertInput();
ChangeInfo revertChange = gApi.changes().id(r.getChangeId()).revert(in).get();
assertThat(revertChange.workInProgress).isTrue();
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revert.
@Test
public void revert() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
ChangeInfo revertChange = gApi.changes().id(r.getChangeId()).revert().get();
// expected messages on source change:
// 1. Uploaded patch set 1.
// 2. Patch Set 1: Code-Review+2
// 3. Change has been successfully merged by Administrator
// 4. Patch Set 1: Reverted
List<ChangeMessageInfo> sourceMessages = new ArrayList<>(gApi.changes().id(r.getChangeId()).get().messages);
assertThat(sourceMessages).hasSize(4);
String expectedMessage = String.format("Created a revert of this change as %s", revertChange.changeId);
assertThat(sourceMessages.get(3).message).isEqualTo(expectedMessage);
assertThat(revertChange.messages).hasSize(1);
assertThat(revertChange.messages.iterator().next().message).isEqualTo("Uploaded patch set 1.");
assertThat(revertChange.revertOf).isEqualTo(gApi.changes().id(r.getChangeId()).get()._number);
}
Aggregations