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.api.mail.EmailContent;
24 import org.kuali.rice.kew.api.action.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.api.KewApiConstants;
30 import org.kuali.rice.kim.api.identity.Person;
31
32
33
34
35
36
37
38 public class MockStyleableEmailContentServiceImpl extends StyleableEmailContentServiceImpl implements MockStyleableEmailContentService {
39
40 private boolean wasAccessed = false;
41
42 @Override
43 public EmailContent generateImmediateReminder(Person user, ActionItem actionItem, DocumentType documentType) {
44 wasAccessed = true;
45 return super.generateImmediateReminder(user, actionItem, documentType);
46 }
47
48 @Override
49 public EmailContent generateDailyReminder(Person user, Collection<ActionItem> actionItems) {
50 wasAccessed = true;
51 return super.generateDailyReminder(user, actionItems);
52 }
53
54 @Override
55 public EmailContent generateWeeklyReminder(Person user, Collection<ActionItem> actionItems) {
56 wasAccessed = true;
57 return super.generateWeeklyReminder(user, actionItems);
58 }
59
60 @Override
61 public EmailContent generateFeedback(FeedbackForm form) {
62 wasAccessed = true;
63 return super.generateFeedback(form);
64 }
65
66
67
68
69
70
71 @Override
72 public DocumentRouteHeaderValue getRouteHeader(ActionItem actionItem) {
73 DocumentRouteHeaderValue routeHeader = null;
74 if (actionItem.getDocumentId() != null) {
75 routeHeader = super.getRouteHeader(actionItem);
76 }
77 if (routeHeader == null) {
78 routeHeader = new DocumentRouteHeaderValue();
79 routeHeader.setDocRouteStatus(KewApiConstants.ROUTE_HEADER_ENROUTE_CD);
80 routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
81 }
82 return routeHeader;
83 }
84
85 @Override
86 public Map<String,DocumentRouteHeaderValue> getRouteHeaders(Collection<ActionItem> actionItems) {
87 Map<String,DocumentRouteHeaderValue> routeHeaders = super.getRouteHeaders(actionItems);
88 DocumentRouteHeaderValue routeHeader = null;
89 for (ActionItem actionItem : actionItems) {
90 if (routeHeaders.get(actionItem.getDocumentId()) == null) {
91 routeHeader = new DocumentRouteHeaderValue();
92 routeHeader.setDocRouteStatus(KewApiConstants.ROUTE_HEADER_ENROUTE_CD);
93 routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
94 routeHeaders.put(actionItem.getDocumentId(), routeHeader);
95 }
96 }
97 return routeHeaders;
98 }
99
100
101
102
103 public boolean wasServiceAccessed() {
104 return this.wasAccessed;
105 }
106
107
108
109
110 public void resetServiceAccessed() {
111 this.wasAccessed = false;
112 }
113
114 }