1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.mail;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20
21 import org.apache.log4j.Logger;
22 import org.junit.Test;
23 import org.kuali.rice.core.api.mail.EmailContent;
24 import org.kuali.rice.kew.actionitem.ActionItem;
25 import org.kuali.rice.kew.actionitem.ActionItemActionListExtension;
26 import org.kuali.rice.kew.actionlist.ActionListFilter;
27 import org.kuali.rice.kew.api.WorkflowDocument;
28 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
29 import org.kuali.rice.kew.mail.service.EmailContentService;
30 import org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl;
31 import org.kuali.rice.kew.rule.RuleTestUtils;
32 import org.kuali.rice.kew.service.KEWServiceLocator;
33 import org.kuali.rice.kew.test.KEWTestCase;
34 import org.kuali.rice.kim.api.identity.Person;
35 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
36
37
38
39
40
41
42
43 public class EmailContentServiceTest extends KEWTestCase {
44
45 private static final Logger LOG = Logger.getLogger(EmailContentServiceTest.class);
46
47
48
49
50 @Override
51 public void setUp() throws Exception {
52 super.setUp();
53 loadXmlFile("EmailContentServiceTestConfig.xml");
54 }
55
56
57
58
59
60
61 @Test
62 public void testGroup() throws Exception {
63 String ewestfalPrincipalId = getPrincipalIdForName("ewestfal");
64
65
66 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
67 doc.route("");
68
69 ActionListFilter actionListFilter = new ActionListFilter();
70 actionListFilter.setDocumentType(doc.getDocumentTypeName());
71 Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(ewestfalPrincipalId, actionListFilter);
72
73 EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
74
75 Person person = KimApiServiceLocator.getPersonService().getPerson(ewestfalPrincipalId);
76
77 EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
78 }
79
80
81
82
83
84
85 @Test
86 public void testUserDelegator() throws Exception {
87
88 RuleTestUtils.createDelegationToUser("EmailTestUserDocType", "WorkflowDocumentTemplate", "user1");
89
90 String user1PrincipalId = getPrincipalIdForName("user1");
91
92
93 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestUserDocType");
94 doc.route("");
95
96 ActionListFilter actionListFilter = new ActionListFilter();
97 actionListFilter.setDocumentType(doc.getDocumentTypeName());
98 Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);
99
100 EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
101
102 Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
103 EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
104 }
105
106
107
108
109
110
111 @Test
112 public void testGroupDelegator() throws Exception {
113
114 RuleTestUtils.createDelegationToGroup("EmailTestWorkgroupDocType", "WorkflowDocumentTemplate", "EmailTestDelegateWorkgroup");
115
116 String user1PrincipalId = getPrincipalIdForName("user1");
117
118
119 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "EmailTestWorkgroupDocType");
120 doc.route("");
121
122 ActionListFilter actionListFilter = new ActionListFilter();
123 actionListFilter.setDocumentType(doc.getDocumentTypeName());
124 Collection<ActionItemActionListExtension> actionItems = KEWServiceLocator.getActionListService().getActionList(user1PrincipalId, actionListFilter);
125
126 EmailContentService emailContentService = KEWServiceLocator.getEmailContentService();
127
128 Person person = KimApiServiceLocator.getPersonService().getPerson(user1PrincipalId);
129 EmailContent emailContent = emailContentService.generateDailyReminder(person, ActionItem.to(new ArrayList<ActionItem>(actionItems)));
130 }
131 }