1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.test.service.impl;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.apache.log4j.Logger;
24 import org.kuali.rice.kcb.service.impl.EmailServiceImpl;
25 import org.kuali.rice.kcb.test.service.MockEmailService;
26
27
28
29
30
31 public class MockEmailServiceImpl extends EmailServiceImpl implements MockEmailService {
32 private static final Logger LOG = Logger.getLogger(MockEmailServiceImpl.class);
33
34 public final Map<String, List<Map<String, String>>> MAILBOXES = new HashMap<String, List<Map<String, String>>>();
35
36
37
38
39 public Map<String, List<Map<String, String>>> getMailBoxes() {
40 return MAILBOXES;
41 }
42
43
44
45
46 @Override
47 protected void sendEmail(String message, String subject, String from, String sendTo, String format) {
48 LOG.info("Storing mail for user: " + sendTo + ": " + subject);
49 Map<String, String> mail = new HashMap<String, String>();
50 mail.put("message", message);
51 mail.put("subject", subject);
52 mail.put("from", from);
53 mail.put("sendTo", sendTo);
54 mail.put("format", format);
55
56 synchronized (MAILBOXES) {
57 List<Map<String, String>> mailbox = MAILBOXES.get(sendTo);
58 if (mailbox == null) {
59 mailbox = new ArrayList<Map<String, String>>();
60 MAILBOXES.put(sendTo, mailbox);
61 }
62 mailbox.add(mail);
63 }
64 }
65 }