use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class CommentsIT method getChangeSortedComments.
private List<CommentInfo> getChangeSortedComments(String changeId) throws Exception {
List<CommentInfo> comments = new ArrayList<>();
Map<String, List<CommentInfo>> commentsMap = getPublishedComments(changeId);
for (Entry<String, List<CommentInfo>> e : commentsMap.entrySet()) {
for (CommentInfo c : e.getValue()) {
// Set the comment's path field.
c.path = e.getKey();
comments.add(c);
}
}
comments.sort(Comparator.comparing(c -> c.id));
return comments;
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method resolveCommentsInheritsValueFromParentWhenUnspecified.
@Test
public void resolveCommentsInheritsValueFromParentWhenUnspecified() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
putDraft(user, id, 1, "comment", true);
putDraft(user, id, 1, "newComment", null);
Map<String, List<CommentInfo>> comments = gApi.changes().id(id.get()).current().drafts();
for (List<CommentInfo> cList : comments.values()) {
for (CommentInfo ci : cList) {
assertThat(ci.unresolved).isEqualTo(true);
}
}
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class MailProcessorIT method parseAndPersistChangeMessage.
@Test
public void parseAndPersistChangeMessage() throws Exception {
String changeId = createChangeWithReview();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
List<CommentInfo> comments = gApi.changes().id(changeId).current().commentsAsList();
String ts = MailUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(comments.get(0).updated.toInstant(), ZoneId.of("UTC")));
// Build Message
MailMessage.Builder b = messageBuilderWithDefaultFields();
String txt = newPlaintextBody(canonicalWebUrl.get() + "#/c/" + changeInfo._number + "/1", "Test Message", null, null, null);
b.textContent(txt + textFooterForChange(changeId, ts));
mailProcessor.process(b.build());
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeId).get().messages;
assertThat(messages).hasSize(3);
assertThat(Iterables.getLast(messages).message).isEqualTo("Patch Set 1:\n\nTest Message");
assertThat(Iterables.getLast(messages).tag).isEqualTo("mailMessageId=some id");
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class ChangeApiImpl method draftsRequest.
@Override
public DraftsRequest draftsRequest() {
return new DraftsRequest() {
@Override
public Map<String, List<CommentInfo>> get() throws RestApiException {
try {
ListChangeDrafts listDrafts = listDraftsProvider.get();
listDrafts.setContext(this.getContext());
listDrafts.setContextPadding(this.getContextPadding());
return listDrafts.apply(change).value();
} catch (Exception e) {
throw asRestApiException("Cannot get drafts", e);
}
}
@Override
public List<CommentInfo> getAsList() throws RestApiException {
try {
ListChangeDrafts listDrafts = listDraftsProvider.get();
listDrafts.setContext(this.getContext());
listDrafts.setContextPadding(this.getContextPadding());
return listDrafts.getComments(change);
} catch (Exception e) {
throw asRestApiException("Cannot get drafts", e);
}
}
};
}
use of com.google.gerrit.extensions.common.CommentInfo in project gerrit by GerritCodeReview.
the class ChangeApiImpl method commentsRequest.
@Override
public CommentsRequest commentsRequest() {
return new CommentsRequest() {
@Override
public Map<String, List<CommentInfo>> get() throws RestApiException {
try {
ListChangeComments listComments = listCommentsProvider.get();
listComments.setContext(this.getContext());
listComments.setContextPadding(this.getContextPadding());
return listComments.apply(change).value();
} catch (Exception e) {
throw asRestApiException("Cannot get comments", e);
}
}
@Override
public List<CommentInfo> getAsList() throws RestApiException {
try {
ListChangeComments listComments = listCommentsProvider.get();
listComments.setContext(this.getContext());
listComments.setContextPadding(this.getContextPadding());
return listComments.getComments(change);
} catch (Exception e) {
throw asRestApiException("Cannot get comments", e);
}
}
};
}
Aggregations