1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package mocks;
17
18 import java.sql.Timestamp;
19 import java.util.Collection;
20 import java.util.Date;
21 import java.util.Map;
22
23 import org.kuali.rice.core.mail.EmailContent;
24 import org.kuali.rice.kew.actionitem.ActionItem;
25 import org.kuali.rice.kew.doctype.bo.DocumentType;
26 import org.kuali.rice.kew.feedback.web.FeedbackForm;
27 import org.kuali.rice.kew.mail.service.impl.StyleableEmailContentServiceImpl;
28 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
29 import org.kuali.rice.kew.util.KEWConstants;
30 import org.kuali.rice.kim.bo.Person;
31
32
33
34
35
36
37
38
39 public class MockStyleableEmailContentServiceImpl extends StyleableEmailContentServiceImpl implements MockStyleableEmailContentService {
40
41 private boolean wasAccessed = false;
42
43 @Override
44 public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) {
45 wasAccessed = true;
46 return super.generateImmediateReminder(user, actionItem, documentType);
47 }
48
49 @Override
50 public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) {
51 wasAccessed = true;
52 return super.generateDailyReminder(user, actionItems);
53 }
54
55 @Override
56 public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) {
57 wasAccessed = true;
58 return super.generateWeeklyReminder(user, actionItems);
59 }
60
61 @Override
62 public EmailContent generateFeedback(FeedbackForm form) {
63 wasAccessed = true;
64 return super.generateFeedback(form);
65 }
66
67
68
69
70
71
72 @Override
73 public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) {
74 DocumentRouteHeaderValue routeHeader = null;
75 if (actionItem.getDocumentId() != null) {
76 routeHeader = super.getRouteHeader(actionItem);
77 }
78 if (routeHeader == null) {
79 routeHeader = new DocumentRouteHeaderValue();
80 routeHeader.setDocRouteStatus(KEWConstants.ROUTE_HEADER_ENROUTE_CD);
81 routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
82 }
83 return routeHeader;
84 }
85
86 @Override
87 public Map<String,DocumentRouteHeaderValue> getRouteHeaders(Collection<ActionItem> actionItems) {
88 Map<String,DocumentRouteHeaderValue> routeHeaders = super.getRouteHeaders(actionItems);
89 DocumentRouteHeaderValue routeHeader = null;
90 for (ActionItem actionItem : actionItems) {
91 if (routeHeaders.get(actionItem.getDocumentId()) == null) {
92 routeHeader = new DocumentRouteHeaderValue();
93 routeHeader.setDocRouteStatus(KEWConstants.ROUTE_HEADER_ENROUTE_CD);
94 routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
95 routeHeaders.put(actionItem.getDocumentId(), routeHeader);
96 }
97 }
98 return routeHeaders;
99 }
100
101
102
103
104 public boolean wasServiceAccessed() {
105 return this.wasAccessed;
106 }
107
108
109
110
111 public void resetServiceAccessed() {
112 this.wasAccessed = false;
113 }
114
115 }