1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.service.impl;
17
18 import java.util.List;
19 import java.util.Map;
20
21 import org.junit.Test;
22 import org.kuali.rice.kcb.bo.MessageDelivery;
23 import org.kuali.rice.kcb.service.GlobalKCBServiceLocator;
24 import org.kuali.rice.kcb.service.MessageDeliveryService;
25 import org.kuali.rice.kcb.test.KCBTestCase;
26 import org.kuali.rice.kcb.test.service.MockEmailService;
27 import org.kuali.rice.test.BaselineTestCase.BaselineMode;
28 import org.kuali.rice.test.BaselineTestCase.Mode;
29 import org.kuali.rice.test.data.UnitTestData;
30 import org.kuali.rice.test.data.UnitTestSql;
31
32
33
34
35
36 @BaselineMode(Mode.ROLLBACK)
37 public class EmailServiceTest extends KCBTestCase {
38 public static final String VALID_EMAIL = "abcd@efghi.jkl";
39 public static final String VALID_FORMAT_VALUE = "text";
40
41 @Test
42 @UnitTestData(sqlStatements = {
43 @UnitTestSql("insert into KREN_MSG_T (MSG_ID, DELIV_TYP, CRTE_DTTM, TTL, CHNl, PRODCR, CNTNT, CNTNT_TYP, URL, RECIP_ID, VER_NBR) values (1, 'fyi', {d '2009-01-01'}, 'a title', 'channel1', 'a producer', 'some content', 'a content type', 'url', 'user1', 0)"),
44 @UnitTestSql("insert into KREN_MSG_DELIV_T (MSG_DELIV_ID, MSG_ID, TYP_NM, SYS_ID, STAT_CD, LOCKD_DTTM, VER_NBR) values (1, 1, 'email', 'fake system id', 'fakestatus', NULL, 0)")
45 })
46 public void testSendNotificationEmail() throws Exception {
47 MessageDeliveryService mds = GlobalKCBServiceLocator.getInstance().getMessageDeliveryService();
48 MockEmailService emailService = (MockEmailService) GlobalKCBServiceLocator.getInstance().getEmailService();
49 emailService.getMailBoxes().clear();
50
51 MessageDelivery nmd = mds.getMessageDelivery(Long.valueOf(1));
52 Long emailMessageId = emailService.sendEmail(nmd, VALID_EMAIL, VALID_FORMAT_VALUE);
53
54 assertEquals(1, emailService.getMailBoxes().size());
55 List<Map<String, String>> mailbox = emailService.getMailBoxes().get(VALID_EMAIL);
56 assertNotNull(mailbox);
57 assertEquals(1, mailbox.size());
58 }
59 }