use of com.google.gerrit.entities.EmailHeader.StringEmailHeader in project gerrit by GerritCodeReview.
the class MailSenderIT method headerString.
private String headerString(Map<String, EmailHeader> headers, String name) {
EmailHeader header = headers.get(name);
assertThat(header).isInstanceOf(StringEmailHeader.class);
return ((StringEmailHeader) header).getString();
}
use of com.google.gerrit.entities.EmailHeader.StringEmailHeader in project gerrit by GerritCodeReview.
the class MailProcessorIT method validateChangeMessage_rejected.
@Test
public void validateChangeMessage_rejected() throws Exception {
String changeId = createChangeWithReview();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
String ts = MailProcessingUtil.rfcDateformatter.format(ZonedDateTime.ofInstant(gApi.changes().id(changeId).get().updated.toInstant(), ZoneId.of("UTC")));
setupFailValidation(CommentForValidation.CommentType.CHANGE_MESSAGE, changeInfo.project, changeInfo._number);
MailMessage.Builder b = messageBuilderWithDefaultFields();
String txt = newPlaintextBody(getChangeUrl(changeInfo) + "/1", COMMENT_TEXT, null, null);
b.textContent(txt + textFooterForChange(changeInfo._number, ts));
List<CommentInfo> commentsBefore = testCommentHelper.getPublishedComments(changeId);
mailProcessor.process(b.build());
assertThat(testCommentHelper.getPublishedComments(changeId)).isEqualTo(commentsBefore);
assertNotifyTo(user);
Message message = sender.nextMessage();
assertThat(message.body()).contains("rejected one or more comments");
// ensure the message header contains a valid message id.
assertThat(((StringEmailHeader) message.headers().get("Message-ID")).getString()).containsMatch("<someid-REJECTION-HTML@" + new URL(canonicalWebUrl.get()).getHost() + ">");
}
use of com.google.gerrit.entities.EmailHeader.StringEmailHeader in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method assertMailNotReplyTo.
protected void assertMailNotReplyTo(Message message, String email) throws Exception {
assertThat(message.headers()).containsKey("Reply-To");
StringEmailHeader replyTo = (StringEmailHeader) message.headers().get("Reply-To");
assertThat(replyTo.getString()).doesNotContain(email);
}
use of com.google.gerrit.entities.EmailHeader.StringEmailHeader in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method assertMailReplyTo.
protected void assertMailReplyTo(Message message, String email) throws Exception {
assertThat(message.headers()).containsKey("Reply-To");
StringEmailHeader replyTo = (StringEmailHeader) message.headers().get("Reply-To");
assertThat(replyTo.getString()).contains(email);
}
use of com.google.gerrit.entities.EmailHeader.StringEmailHeader in project gerrit by GerritCodeReview.
the class OutgoingEmail method addMessageId.
// All message ids must start with < and end with >. Also, they must have @domain and no spaces.
private void addMessageId(OutgoingEmailValidationListener.Args va, String suffix) {
if (messageId != null) {
String message = "<" + messageId.id() + suffix + "@" + getGerritHost() + ">";
message = message.replaceAll("\\s", "");
va.headers.put(FieldName.MESSAGE_ID, new StringEmailHeader(message));
}
}
Aggregations