Search in sources :

Example 1 with MailjetService

use of teammates.logic.core.MailjetService in project teammates by TEAMMATES.

the class EmailSenderTest method testConvertToMailjet.

@Test
public void testConvertToMailjet() {
    EmailWrapper wrapper = getTypicalEmailWrapper();
    MailjetRequest request = new MailjetService().parseToEmail(wrapper);
    JSONObject email = new JSONObject(request.getBody());
    assertEquals(wrapper.getSenderEmail(), email.get(Email.FROMEMAIL));
    assertEquals(wrapper.getSenderName(), email.get(Email.FROMNAME));
    assertEquals(wrapper.getRecipient(), ((JSONArray) email.get(Email.RECIPIENTS)).getJSONObject(0).get("Email"));
    assertEquals(wrapper.getBcc(), ((JSONArray) email.get(Email.RECIPIENTS)).getJSONObject(1).get("Email"));
    assertEquals(wrapper.getReplyTo(), ((JSONObject) email.get(Email.HEADERS)).getString("Reply-To"));
    assertEquals(wrapper.getSubject(), email.get(Email.SUBJECT));
    assertEquals(wrapper.getContent(), email.get(Email.HTMLPART));
}
Also used : MailjetService(teammates.logic.core.MailjetService) JSONObject(org.json.JSONObject) MailjetRequest(com.mailjet.client.MailjetRequest) JSONArray(org.json.JSONArray) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

Aggregations

MailjetRequest (com.mailjet.client.MailjetRequest)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 Test (org.testng.annotations.Test)1 EmailWrapper (teammates.common.util.EmailWrapper)1 MailjetService (teammates.logic.core.MailjetService)1