Make Address an AutoValue
Address is a data-holder for an RFC email address. Making it an AutoValue signifies to callers that it's immutable, hence thread-safe. Change-Id: I9deb50145d10feb93eca540701944cea6428f9d1
This commit is contained in:
@@ -1277,7 +1277,7 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected void assertNotifyTo(String expectedEmail, String expectedFullname) {
|
||||
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
||||
Address expectedAddress = Address.create(expectedFullname, expectedEmail);
|
||||
assertThat(sender.getMessages()).hasSize(1);
|
||||
Message m = sender.getMessages().get(0);
|
||||
assertThat(m.rcpt()).containsExactly(expectedAddress);
|
||||
@@ -1291,7 +1291,7 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected void assertNotifyCc(String expectedEmail, String expectedFullname) {
|
||||
Address expectedAddress = new Address(expectedFullname, expectedEmail);
|
||||
Address expectedAddress = Address.create(expectedFullname, expectedEmail);
|
||||
assertNotifyCc(expectedAddress);
|
||||
}
|
||||
|
||||
@@ -1315,7 +1315,7 @@ public abstract class AbstractDaemonTest {
|
||||
protected void assertNotifyBcc(String expectedEmail, String expectedFullName) {
|
||||
assertThat(sender.getMessages()).hasSize(1);
|
||||
Message m = sender.getMessages().get(0);
|
||||
assertThat(m.rcpt()).containsExactly(new Address(expectedFullName, expectedEmail));
|
||||
assertThat(m.rcpt()).containsExactly(Address.create(expectedFullName, expectedEmail));
|
||||
assertThat(m.headers().get("To").isEmpty()).isTrue();
|
||||
assertThat(m.headers().get("Cc").isEmpty()).isTrue();
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
recipients.put(
|
||||
BCC,
|
||||
message.rcpt().stream()
|
||||
.map(Address::getEmail)
|
||||
.map(Address::email)
|
||||
.filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e))
|
||||
.collect(toList()));
|
||||
this.users = users;
|
||||
@@ -174,7 +174,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
}
|
||||
Truth.assertThat(header).isInstanceOf(AddressList.class);
|
||||
AddressList addrList = (AddressList) header;
|
||||
return addrList.getAddressList().stream().map(Address::getEmail).collect(toList());
|
||||
return addrList.getAddressList().stream().map(Address::email).collect(toList());
|
||||
}
|
||||
|
||||
public FakeEmailSenderSubject to(String... emails) {
|
||||
|
@@ -92,6 +92,6 @@ public abstract class TestAccount {
|
||||
// emailAddress().
|
||||
// * Address#equals only considers email, not name, whereas TestAccount#equals should include
|
||||
// name.
|
||||
return new Address(fullName(), email());
|
||||
return Address.create(fullName(), email());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user