package com.arcbees.gwtpwebsite.server.email;
import javax.inject.Inject;
import org.jukito.JukitoRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import com.arcbees.appengine.mail.Email;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;
@RunWith(JukitoRunner.class)
public class EmailSenderImplTest {
private static final String CONFIRMATION_NUMBER = "confirmation number";
@Inject
EmailSenderImpl emailSender;
@Test
public void sendOrderEmail_anyConfirmationNumber_emailSentIsWellFormed(
com.arcbees.appengine.mail.EmailSender sender) {
//given
ArgumentCaptor<Email> captor = ArgumentCaptor.forClass(Email.class);
//when
emailSender.sendOrderEmail(CONFIRMATION_NUMBER);
//then
verify(sender).send(captor.capture());
Email email = captor.getValue();
assertEquals("queenbee@arcbees.com", email.getTo());
assertEquals("zom.bee@arcbees.com", email.getFromAddress());
assertEquals("GWTP Website", email.getFromPersonal());
assertEquals("Support Order Received", email.getSubject());
assertThat(email.getBody(), containsString(CONFIRMATION_NUMBER));
}
}