package org.itevents.service.sendmail;

import com.sendgrid.SendGrid;
import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.inject.Inject;

/**
 * Created by max on 30.07.15.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:applicationContext.xml" })
public class SendGridMailServiceTest {

    String userMail ="it-events@ex.ua";
    String htmlLetter ="<html><head><title>TEST MAIL</title></head><body><h1>It's test mail to you "
            +userMail+"</h1><br><img src=\"http://phd.chnebu.ch/images/Java.png\"></body></html>";

    @Inject
    SendGridMailService mailService;

    public SendGrid.Email createMail() {
        SendGrid.Email sendGridMail = mailService.createMail(htmlLetter, userMail);
        assertNotNull(sendGridMail);
        assertNotNull(sendGridMail.getFrom());

        return sendGridMail;
    }

    @Test
    public void testSend() {
        boolean status = mailService.send(createMail());
        assertTrue(status);
    }

}

@@ -512,24 +512,32 @@
 Test %7B%0A%0A    
+private 
 String userM
@@ -535,20 +535,28 @@
 ing user
-M
+Em
 ail
+Address
  =%22it-ev
@@ -572,16 +572,24 @@
 a%22;%0A    
+private 
 String h
@@ -690,24 +690,34 @@
        +
+ 
 user
-M
+Em
 ail
+Address 
 +%22%3C/h1%3E%3C
@@ -955,20 +955,28 @@
 er, user
-M
+Em
 ail
+Address
 );%0A     
@@ -1146,22 +1146,26 @@
 boolean 
-status
+isMailSent
  = mailS
@@ -1214,14 +1214,18 @@
 rue(
-status
+isMailSent
 );%0A 

refactor SendGridMailServiceTest