use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class HashtagsIT method addAlreadyExistingHashtag.
@Test
public void addAlreadyExistingHashtag() throws Exception {
// Adding a hashtag that already exists on the change returns a sorted list
// of hashtags without duplicates.
PushOneCommit.Result r = createChange();
addHashtags(r, "tag2");
assertThatGet(r).containsExactly("tag2");
assertMessage(r, "Hashtag added: tag2");
ChangeMessageInfo last = getLastMessage(r);
addHashtags(r, "tag2");
assertThatGet(r).containsExactly("tag2");
assertNoNewMessageSince(r, last);
addHashtags(r, "tag1", "tag2");
assertThatGet(r).containsExactly("tag1", "tag2").inOrder();
assertMessage(r, "Hashtag added: tag1");
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class ListMailFilterIT method listFilterOff.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "OFF")
public void listFilterOff() 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 listFilterWhitelistFiltersNotListedUser.
@Test
@GerritConfig(name = "receiveemail.filter.mode", value = "WHITELIST")
@GerritConfig(name = "receiveemail.filter.patterns", values = { ".+@gerritcodereview\\.com", "a@b\\.com" })
public void listFilterWhitelistFiltersNotListedUser() throws Exception {
ChangeInfo changeInfo = createChangeAndReplyByEmail();
// Check that the comments from the email have NOT been persisted
Collection<ChangeMessageInfo> messages = gApi.changes().id(changeInfo.id).get().messages;
assertThat(messages).hasSize(2);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class MailMetadataIT method metadataOnNewComment.
@Test
public void metadataOnNewComment() throws Exception {
PushOneCommit.Result newChange = createChange();
gApi.changes().id(newChange.getChangeId()).addReviewer(user.getId().toString());
sender.clear();
// Review change
ReviewInput input = new ReviewInput();
input.message = "Test";
revision(newChange).review(input);
setApiUser(user);
Collection<ChangeMessageInfo> result = gApi.changes().id(newChange.getChangeId()).get().messages;
assertThat(result).isNotEmpty();
List<FakeEmailSender.Message> emails = sender.getMessages();
assertThat(emails).hasSize(1);
FakeEmailSender.Message message = emails.get(0);
String changeURL = "<" + canonicalWebUrl.get() + newChange.getChange().getId().get() + ">";
Map<String, Object> expectedHeaders = new HashMap<>();
expectedHeaders.put("Gerrit-PatchSet", "1");
expectedHeaders.put("Gerrit-Change-Id", newChange.getChangeId());
expectedHeaders.put("Gerrit-MessageType", "comment");
expectedHeaders.put("Gerrit-Commit", newChange.getCommit().getId().name());
expectedHeaders.put("Gerrit-ChangeURL", changeURL);
expectedHeaders.put("Gerrit-Comment-Date", Iterables.getLast(result).date);
assertHeaders(message.headers(), expectedHeaders);
// Remove metadata that is not present in email
expectedHeaders.remove("Gerrit-ChangeURL");
expectedHeaders.remove("Gerrit-Commit");
assertTextFooter(message.body(), expectedHeaders);
}
use of com.google.gerrit.extensions.common.ChangeMessageInfo in project gerrit by GerritCodeReview.
the class MailProcessorIT method parseAndPersistInlineComment.
@Test
public void parseAndPersistInlineComment() 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, "Some Inline Comment", null, 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(2).message).isEqualTo("Some Inline Comment");
assertThat(comments.get(2).tag).isEqualTo("mailMessageId=some id");
assertThat(comments.get(2).inReplyTo).isEqualTo(comments.get(1).id);
}
Aggregations