01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package mocks;
18:
19: import java.util.ArrayList;
20: import java.util.HashMap;
21: import java.util.Iterator;
22: import java.util.List;
23: import java.util.Map;
24:
25: import edu.iu.uis.eden.KEWServiceLocator;
26: import edu.iu.uis.eden.actionitem.ActionItem;
27: import edu.iu.uis.eden.doctype.DocumentType;
28: import edu.iu.uis.eden.exception.EdenUserNotFoundException;
29: import edu.iu.uis.eden.mail.EmailBody;
30: import edu.iu.uis.eden.mail.EmailSubject;
31: import edu.iu.uis.eden.mail.EmailTo;
32: import edu.iu.uis.eden.user.AuthenticationUserId;
33: import edu.iu.uis.eden.user.WorkflowUser;
34:
35: public class MockEmailNotificationServiceImpl implements
36: MockEmailNotificationService {
37:
38: private static Map immediateReminders = new HashMap();
39: public static boolean SEND_DAILY_REMINDER_CALLED = false;
40: public static boolean SEND_WEEKLY_REMINDER_CALLED = false;
41:
42: public void sendImmediateReminder(WorkflowUser user,
43: ActionItem actionItem) {
44: List actionItemsSentUser = (List) immediateReminders.get(user
45: .getWorkflowId());
46: if (actionItemsSentUser == null) {
47: actionItemsSentUser = new ArrayList();
48: immediateReminders.put(user.getWorkflowId(),
49: actionItemsSentUser);
50: }
51: actionItemsSentUser.add(actionItem);
52: }
53:
54: public String getApplicationEmailAddress() {
55: throw new UnsupportedOperationException(
56: "Not currently supported in test mode.");
57: }
58:
59: public String getDocumentTypeEmailAddress(DocumentType documentType) {
60: throw new UnsupportedOperationException(
61: "Not currently supported in test mode.");
62: }
63:
64: public void sendDailyReminder() {
65: SEND_DAILY_REMINDER_CALLED = true;
66: }
67:
68: public void sendWeeklyReminder() {
69: SEND_WEEKLY_REMINDER_CALLED = true;
70: }
71:
72: public void sendEmail(EmailTo to, EmailSubject subject,
73: EmailBody body) {
74: }
75:
76: public int emailsSent(String networkId, Long documentId,
77: String actionRequestCd) throws EdenUserNotFoundException {
78: WorkflowUser user = KEWServiceLocator.getUserService()
79: .getWorkflowUser(new AuthenticationUserId(networkId));
80: List actionItemsSentUser = (List) immediateReminders.get(user
81: .getWorkflowId());
82: if (actionItemsSentUser == null) {
83: return 0;
84: }
85: int emailsSent = 0;
86: for (Iterator iter = actionItemsSentUser.iterator(); iter
87: .hasNext();) {
88: ActionItem actionItem = (ActionItem) iter.next();
89: if (actionItem.getRouteHeaderId().equals(documentId)
90: && actionItem.getActionRequestCd().equals(
91: actionRequestCd)) {
92: emailsSent++;
93: }
94: }
95: return emailsSent;
96: }
97: }
|