use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class MailProcessorIT method parseAndPersistFileComment.
@Test
public void parseAndPersistFileComment() 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", null, null, "Some Comment on File 1", null);
b.textContent(txt + textFooterForChange(changeId, ts));
mailProcessor.process(b.build());
// Assert messages
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeId).get().messages;
assertThat(messages).hasSize(3);
assertThat(Iterables.getLast(messages).message).isEqualTo("Patch Set 1:\n\n(1 comment)");
assertThat(Iterables.getLast(messages).tag).isEqualTo("mailMessageId=some id");
// Assert comment
comments = gApi.changes().id(changeId).current().commentsAsList();
assertThat(comments).hasSize(3);
assertThat(comments.get(0).message).isEqualTo("Some Comment on File 1");
assertThat(comments.get(0).inReplyTo).isNull();
assertThat(comments.get(0).tag).isEqualTo("mailMessageId=some id");
assertThat(comments.get(0).path).isEqualTo("gerrit-server/test.txt");
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterWhitelistDoesNotFilterListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "WHITELIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+ser@example\\.com", "a@b\\.com" })
public void listFilterWhitelistDoesNotFilterListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(3);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterBlacklistDoesNotFilterNotListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "BLACKLIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@gerritcodereview\\.com", "a@b\\.com" })
public void listFilterBlacklistDoesNotFilterNotListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(3);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class AbandonRestoreIT method assertChangeMessages.
private void assertChangeMessages(String changeId, List<String> expected) throws Exception {
ChangeInfo c = get(changeId);
Iterable<ChangeMessageInfo> messages = c.messages;
assertThat(messages).isNotNull();
assertThat(messages).hasSize(expected.size());
List<String> actual = new ArrayList<>();
for (ChangeMessageInfo info : messages) {
actual.add(info.message);
}
assertThat(actual).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class AbstractQueryChangesTest method byComment.
@Test
public void byComment() throws Exception {
TestRepository<Repo> repo = createProject("repo");
ChangeInserter ins = newChange(repo);
Change change = insert(repo, ins);
ReviewInput input = new ReviewInput();
input.message = "toplevel";
ReviewInput.CommentInput commentInput = new ReviewInput.CommentInput();
commentInput.line = 1;
commentInput.message = "inline";
input.comments = ImmutableMap.<String, List<ReviewInput.CommentInput>>of(Patch.COMMIT_MSG, ImmutableList.<ReviewInput.CommentInput>of(commentInput));
gApi.changes().id(change.getId().get()).current().review(input);
Map<String, List<CommentInfo>> comments = gApi.changes().id(change.getId().get()).current().comments();
assertThat(comments).hasSize(1);
CommentInfo comment = Iterables.getOnlyElement(comments.get(Patch.COMMIT_MSG));
assertThat(comment.message).isEqualTo(commentInput.message);
ChangeMessageInfo lastMsg = Iterables.getLast(gApi.changes().id(change.getId().get()).get().messages, null);
assertThat(lastMsg.message).isEqualTo("Patch Set 1:\n\n(1 comment)\n\n" + input.message);
assertQuery("comment:foo");
assertQuery("comment:toplevel", change);
assertQuery("comment:inline", change);
}
Aggregations