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