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