| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package mocks; |
| 17 |
|
|
| 18 |
|
import org.apache.log4j.Logger; |
| 19 |
|
import org.kuali.rice.core.mail.Mailer; |
| 20 |
|
import org.kuali.rice.kew.actionitem.ActionItem; |
| 21 |
|
import org.kuali.rice.kew.mail.service.EmailContentService; |
| 22 |
|
import org.kuali.rice.kim.bo.Person; |
| 23 |
|
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
| 24 |
|
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 25 |
|
|
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.Collection; |
| 28 |
|
import java.util.HashMap; |
| 29 |
|
import java.util.Iterator; |
| 30 |
|
import java.util.List; |
| 31 |
|
import java.util.Map; |
| 32 |
|
|
| 33 |
|
|
|
|
|
| 0% |
Uncovered Elements: 70 (70) |
Complexity: 24 |
Complexity Density: 0.6 |
|
| 34 |
|
public class MockEmailNotificationServiceImpl implements MockEmailNotificationService { |
| 35 |
|
private static final Logger LOG = Logger.getLogger(MockEmailNotificationServiceImpl.class); |
| 36 |
|
|
| 37 |
|
private static Map<String,List> immediateReminders = new HashMap<String,List>(); |
| 38 |
|
private static Map<String,Integer> aggregateReminderCount = new HashMap<String,Integer>(); |
| 39 |
|
public static boolean SEND_DAILY_REMINDER_CALLED = false; |
| 40 |
|
public static boolean SEND_WEEKLY_REMINDER_CALLED = false; |
| 41 |
|
|
| 42 |
|
private EmailContentService contentService; |
| 43 |
|
private String deploymentEnvironment; |
| 44 |
|
|
| 45 |
|
private Mailer mailer; |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 50 |
0
|
public void resetReminderCounts() {... |
| 51 |
0
|
aggregateReminderCount.clear(); |
| 52 |
0
|
immediateReminders.clear(); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 59 |
0
|
@Override... |
| 60 |
|
public void sendImmediateReminder(Person user, ActionItem actionItem) { |
| 61 |
|
|
| 62 |
0
|
List actionItemsSentUser = (List)immediateReminders.get(user.getPrincipalId()); |
| 63 |
0
|
if (actionItemsSentUser == null) { |
| 64 |
0
|
actionItemsSentUser = new ArrayList(); |
| 65 |
0
|
immediateReminders.put(user.getPrincipalId(), actionItemsSentUser); |
| 66 |
|
} |
| 67 |
0
|
actionItemsSentUser.add(actionItem); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 74 |
0
|
protected boolean sendActionListEmailNotification() {... |
| 75 |
|
|
| 76 |
0
|
return true; |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 79 |
0
|
@Override... |
| 80 |
|
public void sendDailyReminder() { |
| 81 |
0
|
resetStyleService(); |
| 82 |
|
|
| 83 |
0
|
SEND_DAILY_REMINDER_CALLED = true; |
| 84 |
|
} |
| 85 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 86 |
0
|
@Override... |
| 87 |
|
public void sendWeeklyReminder() { |
| 88 |
0
|
resetStyleService(); |
| 89 |
|
|
| 90 |
0
|
SEND_WEEKLY_REMINDER_CALLED = true; |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 93 |
0
|
@Override... |
| 94 |
|
public void scheduleBatchEmailReminders() throws Exception { |
| 95 |
|
|
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 99 |
0
|
protected void sendPeriodicReminder(Person user, Collection<ActionItem> actionItems, String emailSetting) {... |
| 100 |
|
|
| 101 |
0
|
if (!aggregateReminderCount.containsKey(emailSetting)) { |
| 102 |
0
|
aggregateReminderCount.put(emailSetting, actionItems.size()); |
| 103 |
|
} else { |
| 104 |
0
|
aggregateReminderCount.put(emailSetting, aggregateReminderCount.get(emailSetting) + actionItems.size()); |
| 105 |
|
} |
| 106 |
|
} |
| 107 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 108 |
0
|
public Integer getTotalPeriodicRemindersSent(String emailReminderConstant) {... |
| 109 |
0
|
Integer returnVal = aggregateReminderCount.get(emailReminderConstant); |
| 110 |
0
|
if (returnVal == null) { |
| 111 |
0
|
returnVal = Integer.valueOf(0); |
| 112 |
|
} |
| 113 |
0
|
return returnVal; |
| 114 |
|
} |
| 115 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 116 |
0
|
public Integer getTotalPeriodicRemindersSent() {... |
| 117 |
0
|
int total = 0; |
| 118 |
0
|
for (Map.Entry<String, Integer> mapEntry : aggregateReminderCount.entrySet()) { |
| 119 |
0
|
Integer value = mapEntry.getValue(); |
| 120 |
0
|
total += (value == null) ? 0 : value.intValue(); |
| 121 |
|
} |
| 122 |
0
|
return Integer.valueOf(total); |
| 123 |
|
} |
| 124 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 125 |
0
|
public boolean wasStyleServiceAccessed() {... |
| 126 |
0
|
return getEmailContentGenerator().wasServiceAccessed(); |
| 127 |
|
} |
| 128 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
0
|
private void resetStyleService() {... |
| 130 |
0
|
getEmailContentGenerator().resetServiceAccessed(); |
| 131 |
|
} |
| 132 |
|
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
| 133 |
0
|
public int immediateReminderEmailsSent(String networkId, Long documentId, String actionRequestCd) {... |
| 134 |
0
|
KimPrincipal principal = KIMServiceLocator.getIdentityManagementService().getPrincipalByPrincipalName(networkId); |
| 135 |
0
|
List actionItemsSentUser = immediateReminders.get(principal.getPrincipalId()); |
| 136 |
0
|
if (actionItemsSentUser == null) { |
| 137 |
0
|
return 0; |
| 138 |
|
} |
| 139 |
0
|
int emailsSent = 0; |
| 140 |
0
|
for (Iterator iter = actionItemsSentUser.iterator(); iter.hasNext();) { |
| 141 |
0
|
ActionItem actionItem = (ActionItem) iter.next(); |
| 142 |
0
|
if (actionItem.getRouteHeaderId().equals(documentId) && actionItem.getActionRequestCd().equals(actionRequestCd)) { |
| 143 |
0
|
emailsSent++; |
| 144 |
|
} |
| 145 |
|
} |
| 146 |
0
|
return emailsSent; |
| 147 |
|
} |
| 148 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 149 |
0
|
public void setEmailContentGenerator(EmailContentService contentService) {... |
| 150 |
0
|
this.contentService = contentService; |
| 151 |
|
} |
| 152 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 153 |
0
|
protected MockStyleableEmailContentService getEmailContentGenerator() {... |
| 154 |
0
|
return (MockStyleableEmailContentService) contentService; |
| 155 |
|
} |
| 156 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 157 |
0
|
public void setMailer(Mailer mailer){... |
| 158 |
0
|
this.mailer = mailer; |
| 159 |
|
} |
| 160 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 161 |
0
|
public void setDeploymentEnvironment(String deploymentEnvironment) {... |
| 162 |
0
|
this.deploymentEnvironment = deploymentEnvironment; |
| 163 |
|
} |
| 164 |
|
} |