Send email notifications and fire Gerrit event if comments are posted via email

Change-Id: I4121b8d8b13f9a675fc227a81f6543501b3084f6
This commit is contained in:
Patrick Hiesel
2017-02-07 08:41:32 +01:00
parent c76731bbef
commit 1fce31c863
3 changed files with 93 additions and 11 deletions

View File

@@ -208,6 +208,35 @@ public class MailProcessorIT extends AbstractDaemonTest {
gApi.accounts().id("user").setActive(true);
}
@Test
public void sendNotificationAfterPersistingComments() throws Exception {
String changeId = createChangeWithReview();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
List<CommentInfo> comments = gApi.changes().id(changeId).current().commentsAsList();
assertThat(comments).hasSize(2);
String ts =
MailUtil.rfcDateformatter.format(
ZonedDateTime.ofInstant(comments.get(0).updated.toInstant(), ZoneId.of("UTC")));
// Build Message
String txt =
newPlaintextBody(
canonicalWebUrl.get() + "#/c/" + changeInfo._number + "/1",
"Test Message",
null,
null,
null);
MailMessage.Builder b =
messageBuilderWithDefaultFields()
.from(user.emailAddress)
.textContent(txt + textFooterForChange(changeId, ts));
sender.clear();
mailProcessor.process(b.build());
assertNotifyTo(admin);
}
private static CommentInput newComment(String path, Side side, int line, String message) {
CommentInput c = new CommentInput();
c.path = path;