Search in sources :

Example 6 with Address

use of com.google.gerrit.server.mail.Address in project gerrit by GerritCodeReview.

the class Base64HeaderMessage method expectedMailMessage.

@Override
public MailMessage expectedMailMessage() {
    MailMessage.Builder expect = MailMessage.builder();
    expect.id("<001a114da7ae26e2eb053fe0c29c@google.com>").from(new Address("Jonathan Nieder (Gerrit)", "noreply-gerritcodereview-CtTy0igsBrnvL7dKoWEIEg@google.com")).addTo(new Address("ekempin", "ekempin@google.com")).textContent(textContent).subject("😛 test").dateReceived(new DateTime(2016, 10, 25, 9, 11, 35, 0, DateTimeZone.UTC));
    return expect.build();
}
Also used : MailMessage(com.google.gerrit.server.mail.receive.MailMessage) Address(com.google.gerrit.server.mail.Address) DateTime(org.joda.time.DateTime)

Example 7 with Address

use of com.google.gerrit.server.mail.Address in project gerrit by GerritCodeReview.

the class NonUTF8Message method expectedMailMessage.

@Override
public MailMessage expectedMailMessage() {
    MailMessage.Builder expect = MailMessage.builder();
    expect.id("<001a114da7ae26e2eb053fe0c29c@google.com>").from(new Address("Jonathan Nieder (Gerrit)", "noreply-gerritcodereview-CtTy0igsBrnvL7dKoWEIEg@google.com")).addTo(new Address("ekempin", "ekempin@google.com")).textContent(textContent).subject("😛 test").dateReceived(new DateTime(2016, 10, 25, 9, 11, 35, 0, DateTimeZone.UTC));
    return expect.build();
}
Also used : MailMessage(com.google.gerrit.server.mail.receive.MailMessage) Address(com.google.gerrit.server.mail.Address) DateTime(org.joda.time.DateTime)

Example 8 with Address

use of com.google.gerrit.server.mail.Address in project gerrit by GerritCodeReview.

the class SimpleTextMessage method expectedMailMessage.

@Override
public MailMessage expectedMailMessage() {
    MailMessage.Builder expect = MailMessage.builder();
    expect.id("<001a114da7ae26e2eb053fe0c29c@google.com>").from(new Address("Jonathan Nieder (Gerrit)", "noreply-gerritcodereview-CtTy0igsBrnvL7dKoWEIEg@google.com")).addTo(new Address("ekempin", "ekempin@google.com")).addCc(new Address("Dave Borowitz", "dborowitz@google.com")).addCc(new Address("Jonathan Nieder", "jrn@google.com")).addCc(new Address("Patrick Hiesel", "hiesel@google.com")).textContent(textContent).subject("Change in gerrit[master]: (Re)enable voting buttons for merged changes").dateReceived(new DateTime(2016, 10, 25, 9, 11, 35, 0, DateTimeZone.UTC)).addAdditionalHeader("Authentication-Results: mx.google.com; dkim=pass header.i=@google.com;").addAdditionalHeader("In-Reply-To: <gerrit.1477487889000.Iba501e00bee" + "77be3bd0ced72f88fd04ba0accaed@gerrit-review.googlesource.com>").addAdditionalHeader("References: <gerrit.1477487889000.Iba501e00bee" + "77be3bd0ced72f88fd04ba0accaed@gerrit-review.googlesource.com>");
    return expect.build();
}
Also used : MailMessage(com.google.gerrit.server.mail.receive.MailMessage) Address(com.google.gerrit.server.mail.Address) DateTime(org.joda.time.DateTime)

Example 9 with Address

use of com.google.gerrit.server.mail.Address in project gerrit by GerritCodeReview.

the class AbstractParserTest method newMailMessageBuilder.

/** Returns a MailMessage.Builder with all required fields populated. */
protected static MailMessage.Builder newMailMessageBuilder() {
    MailMessage.Builder b = MailMessage.builder();
    b.id("id");
    b.from(new Address("Foo Bar", "foo@bar.com"));
    b.dateReceived(new DateTime());
    b.subject("");
    return b;
}
Also used : Address(com.google.gerrit.server.mail.Address) DateTime(org.joda.time.DateTime)

Example 10 with Address

use of com.google.gerrit.server.mail.Address in project gerrit by GerritCodeReview.

the class MetadataParserTest method parseMetadataFromHeader.

@Test
public void parseMetadataFromHeader() {
    // This tests if the metadata parser is able to parse metadata from the
    // email headers of the message.
    MailMessage.Builder b = MailMessage.builder();
    b.id("");
    b.dateReceived(new DateTime());
    b.subject("");
    b.addAdditionalHeader(toHeaderWithDelimiter(MetadataName.CHANGE_ID) + "cid");
    b.addAdditionalHeader(toHeaderWithDelimiter(MetadataName.PATCH_SET) + "1");
    b.addAdditionalHeader(toHeaderWithDelimiter(MetadataName.MESSAGE_TYPE) + "comment");
    b.addAdditionalHeader(toHeaderWithDelimiter(MetadataName.TIMESTAMP) + "Tue, 25 Oct 2016 02:11:35 -0700");
    Address author = new Address("Diffy", "test@gerritcodereview.com");
    b.from(author);
    MailMetadata meta = MetadataParser.parse(b.build());
    assertThat(meta.author).isEqualTo(author.getEmail());
    assertThat(meta.changeId).isEqualTo("cid");
    assertThat(meta.patchSet).isEqualTo(1);
    assertThat(meta.messageType).isEqualTo("comment");
    assertThat(meta.timestamp.getTime()).isEqualTo(new DateTime(2016, 10, 25, 9, 11, 35, 0, DateTimeZone.UTC).getMillis());
}
Also used : Address(com.google.gerrit.server.mail.Address) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Address (com.google.gerrit.server.mail.Address)23 DateTime (org.joda.time.DateTime)11 MailMessage (com.google.gerrit.server.mail.receive.MailMessage)6 Account (com.google.gerrit.reviewdb.client.Account)5 Test (org.junit.Test)5 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)3 LinkedHashMap (java.util.LinkedHashMap)3 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)2 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)2 NotifyConfig (com.google.gerrit.server.git.NotifyConfig)2 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableTable (com.google.common.collect.ImmutableTable)1