package org.codenergic.theskeleton.core.mail;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;

import org.codenergic.theskeleton.core.mail.EmailService;
import org.codenergic.theskeleton.core.mail.impl.EmailServiceImpl;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

public class EmailServiceTest {
	private EmailService emailService;
	@Mock
	private JavaMailSender mailSender;
	@Value("${spring.mail.username}")
	private String fromEmail;
	private ArgumentCaptor<SimpleMailMessage> simpleMailMessageCaptor;
	
	@Before
	public void init() {
		MockitoAnnotations.initMocks(this);
		this.emailService = new EmailServiceImpl(mailSender);
		this.simpleMailMessageCaptor = ArgumentCaptor.forClass(SimpleMailMessage.class);
	}
	
	@Test
	public void testSendSimpleMessage() {
		String subject = "Test Email";
		String body = "Testing Email";
		String to = "vickrif@gmail.com";
		
		emailService.sendSimpleMessage(to, subject, body);
		verify(mailSender).send(simpleMailMessageCaptor.capture());
		assertThat(to).isEqualTo(simpleMailMessageCaptor.getValue().getTo()[0]);
		assertThat(subject).isEqualTo(simpleMailMessageCaptor.getValue().getSubject());
		assertThat(body).isEqualTo(simpleMailMessageCaptor.getValue().getText());
	}
}

@@ -265,16 +265,85 @@
 ceImpl;%0A
+import org.codenergic.theskeleton.core.mail.impl.MailContentBuilder;%0A
 import o
@@ -760,16 +760,71 @@
 Sender;%0A
+%09@Mock%0A%09private MailContentBuilder mailContentBuilder;%0A
 %09@Value(
@@ -1069,16 +1069,36 @@
 ilSender
+, mailContentBuilder
 );%0A%09%09thi

remove one of constructor