mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
E-mail changes initiated from console to registrar contacts
Also, fix misspelling of "recipient." ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237857289
This commit is contained in:
parent
b0ad8b6a9b
commit
430c01b597
10 changed files with 112 additions and 43 deletions
|
@ -51,19 +51,19 @@ public class SendEmailUtilsTest {
|
|||
when(emailService.createMessage()).thenReturn(message);
|
||||
}
|
||||
|
||||
private void setRecepients(ImmutableList<String> recepients) {
|
||||
private void setRecipients(ImmutableList<String> recipients) {
|
||||
sendEmailUtils =
|
||||
new SendEmailUtils(
|
||||
"outgoing@registry.example",
|
||||
"outgoing display name",
|
||||
recepients,
|
||||
recipients,
|
||||
emailService);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_sendToOneAddress() throws Exception {
|
||||
setRecepients(ImmutableList.of("johnny@fakesite.tld"));
|
||||
assertThat(sendEmailUtils.hasRecepients()).isTrue();
|
||||
setRecipients(ImmutableList.of("johnny@fakesite.tld"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
|
@ -78,8 +78,8 @@ public class SendEmailUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testSuccess_sendToMultipleAddresses() throws Exception {
|
||||
setRecepients(ImmutableList.of("foo@example.com", "bar@example.com"));
|
||||
assertThat(sendEmailUtils.hasRecepients()).isTrue();
|
||||
setRecipients(ImmutableList.of("foo@example.com", "bar@example.com"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
|
@ -93,8 +93,8 @@ public class SendEmailUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testSuccess_ignoresMalformedEmailAddress() throws Exception {
|
||||
setRecepients(ImmutableList.of("foo@example.com", "1iñvalidemail"));
|
||||
assertThat(sendEmailUtils.hasRecepients()).isTrue();
|
||||
setRecipients(ImmutableList.of("foo@example.com", "1iñvalidemail"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
|
@ -107,8 +107,8 @@ public class SendEmailUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_noAddresses() throws Exception {
|
||||
setRecepients(ImmutableList.of());
|
||||
assertThat(sendEmailUtils.hasRecepients()).isFalse();
|
||||
setRecipients(ImmutableList.of());
|
||||
assertThat(sendEmailUtils.hasRecipients()).isFalse();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
|
@ -119,8 +119,8 @@ public class SendEmailUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_onlyGivenMalformedAddress() throws Exception {
|
||||
setRecepients(ImmutableList.of("1iñvalidemail"));
|
||||
assertThat(sendEmailUtils.hasRecepients()).isTrue();
|
||||
setRecipients(ImmutableList.of("1iñvalidemail"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
|
@ -131,8 +131,8 @@ public class SendEmailUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testFailure_exceptionThrownDuringSend() throws Exception {
|
||||
setRecepients(ImmutableList.of("foo@example.com"));
|
||||
assertThat(sendEmailUtils.hasRecepients()).isTrue();
|
||||
setRecipients(ImmutableList.of("foo@example.com"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
doThrow(new MessagingException()).when(emailService).sendMessage(any(Message.class));
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
|
@ -145,6 +145,42 @@ public class SendEmailUtilsTest {
|
|||
.containsExactly(new InternetAddress("foo@example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdditionalRecipients() throws Exception {
|
||||
setRecipients(ImmutableList.of("foo@example.com"));
|
||||
assertThat(sendEmailUtils.hasRecipients()).isTrue();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
"It is a dark and scary place.",
|
||||
ImmutableList.of("bar@example.com", "baz@example.com")))
|
||||
.isTrue();
|
||||
verifyMessageSent();
|
||||
assertThat(message.getAllRecipients())
|
||||
.asList()
|
||||
.containsExactly(
|
||||
new InternetAddress("foo@example.com"),
|
||||
new InternetAddress("bar@example.com"),
|
||||
new InternetAddress("baz@example.com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyAdditionalRecipients() throws Exception {
|
||||
setRecipients(ImmutableList.of());
|
||||
assertThat(sendEmailUtils.hasRecipients()).isFalse();
|
||||
assertThat(
|
||||
sendEmailUtils.sendEmail(
|
||||
"Welcome to the Internet",
|
||||
"It is a dark and scary place.",
|
||||
ImmutableList.of("bar@example.com", "baz@example.com")))
|
||||
.isTrue();
|
||||
verifyMessageSent();
|
||||
assertThat(message.getAllRecipients())
|
||||
.asList()
|
||||
.containsExactly(
|
||||
new InternetAddress("bar@example.com"), new InternetAddress("baz@example.com"));
|
||||
}
|
||||
|
||||
private void verifyMessageSent() throws Exception {
|
||||
verify(emailService).sendMessage(message);
|
||||
assertThat(message.getSubject()).isEqualTo("Welcome to the Internet");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue