1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.mail.service.impl;
17
18 import static org.junit.Assert.assertEquals;
19 import mocks.MockEmailNotificationService;
20
21 import org.joda.time.DateTime;
22 import org.junit.After;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.kuali.rice.kew.api.KewApiServiceLocator;
26 import org.kuali.rice.kew.api.action.ActionItem;
27 import org.kuali.rice.kew.api.mail.ImmediateEmailReminderQueue;
28 import org.kuali.rice.kew.service.KEWServiceLocator;
29 import org.kuali.rice.kew.test.KEWTestCase;
30 import org.kuali.rice.kew.api.KewApiConstants;
31
32
33
34
35
36
37
38 public class ImmediateEmailReminderQueueImplTest extends KEWTestCase {
39
40 private ImmediateEmailReminderQueue immediateEmailReminderQueue;
41
42
43 @Before
44 public void setUp() throws Exception {
45 super.setUp();
46
47 immediateEmailReminderQueue = KewApiServiceLocator.getImmediateEmailReminderQueue();
48 }
49
50 @After
51 public void tearDown() throws Exception {
52 super.tearDown();
53 }
54
55 @Test
56 public void test() {
57 ActionItem actionItem = ActionItem.Builder.create("124", KewApiConstants.ACTION_REQUEST_APPROVE_REQ, "123", new DateTime(), "Test", "http://www.test.com", "Test", "125", "user1").build();
58 immediateEmailReminderQueue.sendReminder(actionItem, Boolean.FALSE);
59
60 assertEquals("user1 should have 1 email", 1, getMockEmailService().immediateReminderEmailsSent("user1", "124", KewApiConstants.ACTION_REQUEST_APPROVE_REQ));
61 assertEquals("user2 should have no emails", 0, getMockEmailService().immediateReminderEmailsSent("user2", "124", KewApiConstants.ACTION_REQUEST_APPROVE_REQ));
62
63 getMockEmailService().resetReminderCounts();
64
65 immediateEmailReminderQueue.sendReminder(actionItem, Boolean.TRUE);
66 assertEquals("user1 should have no emails", 0, getMockEmailService().immediateReminderEmailsSent("user1", "124", KewApiConstants.ACTION_REQUEST_APPROVE_REQ));
67
68 getMockEmailService().resetReminderCounts();
69
70
71 immediateEmailReminderQueue.sendReminder(actionItem, null);
72 assertEquals("user1 should have 1 email", 1, getMockEmailService().immediateReminderEmailsSent("user1", "124", KewApiConstants.ACTION_REQUEST_APPROVE_REQ));
73
74 getMockEmailService().resetReminderCounts();
75
76
77 actionItem = ActionItem.Builder.create("124", KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, "123", new DateTime(), "Test", "http://www.test.com", "Test", "125", "user1").build();
78 immediateEmailReminderQueue.sendReminder(actionItem, Boolean.TRUE);
79 assertEquals("user1 should have 1 emails", 1, getMockEmailService().immediateReminderEmailsSent("user1", "124", KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ));
80
81
82
83 }
84
85
86 private MockEmailNotificationService getMockEmailService() {
87 return (MockEmailNotificationService)KEWServiceLocator.getActionListEmailService();
88 }
89 }