1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.test.util;
17
18 import org.kuali.rice.core.api.membership.MemberType;
19 import org.kuali.rice.ken.bo.Notification;
20 import org.kuali.rice.ken.bo.NotificationChannel;
21 import org.kuali.rice.ken.bo.NotificationChannelReviewer;
22 import org.kuali.rice.ken.bo.NotificationContentType;
23 import org.kuali.rice.ken.bo.NotificationPriority;
24 import org.kuali.rice.ken.bo.NotificationProducer;
25 import org.kuali.rice.ken.bo.NotificationRecipient;
26 import org.kuali.rice.ken.bo.NotificationSender;
27 import org.kuali.rice.kim.api.KimConstants.KimGroupMemberTypes;
28
29 import java.sql.Timestamp;
30 import java.util.List;
31
32
33
34
35
36 public final class MockObjectsUtil {
37
38 private MockObjectsUtil() {
39 throw new UnsupportedOperationException("do not call");
40 }
41
42
43
44
45
46
47
48
49 public static final NotificationChannel buildTestNotificationChannel(String name, String description, boolean subscribable) {
50 NotificationChannel channel = new NotificationChannel();
51 channel.setName(name);
52 channel.setDescription(description);
53 channel.setSubscribable(subscribable);
54 return channel;
55 }
56
57
58
59
60
61 public static final NotificationChannel getTestChannel1() {
62 return buildTestNotificationChannel("Test Channel 1", "Test Channel 1 - description", true);
63 }
64
65
66
67
68
69 public static final NotificationChannel getTestChannel2() {
70 return buildTestNotificationChannel("Test Channel 2", "Test Channel 2 - description", false);
71 }
72
73
74
75
76
77
78
79
80 public static final NotificationProducer buildTestNotificationProducer(String name, String description, String contactInfo) {
81 NotificationProducer producer = new NotificationProducer();
82 producer.setName(name);
83 producer.setDescription(description);
84 producer.setContactInfo(contactInfo);
85 return producer;
86 }
87
88
89
90
91
92
93
94 public static final NotificationChannelReviewer buildTestNotificationChannelReviewer(MemberType reviewerType, String reviewerId) {
95 NotificationChannelReviewer reviewer = new NotificationChannelReviewer();
96 reviewer.setReviewerType(reviewerType.getCode());
97 reviewer.setReviewerId(reviewerId);
98 return reviewer;
99 }
100
101
102
103
104
105 public static final NotificationProducer getTestProducer1() {
106 return buildTestNotificationProducer("Produer 1", "Producer 1 - description", "Producer 1 - contact info");
107 }
108
109
110
111
112
113
114
115
116
117 public static final NotificationContentType buildTestNotificationContentType(String name, String description, String namespace, String xsd, String xsl) {
118 NotificationContentType contentType = new NotificationContentType();
119 contentType.setName(name);
120 contentType.setDescription(description);
121 contentType.setNamespace(namespace);
122 contentType.setXsd(xsd);
123 contentType.setXsl(xsl);
124 return contentType;
125 }
126
127
128
129
130
131 public static final NotificationContentType getTestContentType1() {
132 return buildTestNotificationContentType("Content Type 1", "Content Type 1 - description", "Content Type 1 - namespace", "Simple.xsd", "Simple.xsl");
133 }
134
135
136
137
138
139
140
141
142 public static final NotificationPriority buildTestNotificationPriority(String name, String description, Integer order) {
143 NotificationPriority priority = new NotificationPriority();
144 priority.setName(name);
145 priority.setDescription(description);
146 priority.setOrder(order);
147 return priority;
148 }
149
150
151
152
153
154 public static final NotificationPriority getTestPriority1() {
155 return buildTestNotificationPriority("Priority 1", "Priority 1 - description", new Integer(1));
156 }
157
158
159
160
161
162
163
164 public static final NotificationRecipient buildTestNotificationRecipient(String recipientId, MemberType recipientType) {
165 NotificationRecipient recipient = new NotificationRecipient();
166 recipient.setRecipientId(recipientId);
167 recipient.setRecipientType(recipientType.getCode());
168 return recipient;
169 }
170
171
172
173
174
175 public static final NotificationRecipient getTestRecipient1() {
176 return buildTestNotificationRecipient("ag266", KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE);
177 }
178
179
180
181
182
183 public static final NotificationRecipient getTestRecipient2() {
184 return buildTestNotificationRecipient("Notification Team", KimGroupMemberTypes.GROUP_MEMBER_TYPE);
185 }
186
187
188
189
190
191
192
193 public static final Notification buildTestNotification(String deliveryType, Timestamp sendDateTime, Timestamp autoRemoveDateTime, NotificationContentType contentType,
194 String content, NotificationPriority priority, NotificationProducer producer, NotificationChannel channel, List<NotificationRecipient> recipients,
195 List<NotificationSender> senders) {
196 Notification notification = new Notification();
197 notification.setCreationDateTime(new Timestamp(System.currentTimeMillis()));
198 notification.setDeliveryType(deliveryType);
199 notification.setSendDateTime(sendDateTime);
200 notification.setAutoRemoveDateTime(autoRemoveDateTime);
201 notification.setContentType(contentType);
202 notification.setContent(content);
203 notification.setPriority(priority);
204 notification.setProducer(producer);
205 notification.setChannel(channel);
206 notification.setRecipients(recipients);
207 notification.setSenders(senders);
208
209 return notification;
210 }
211
212
213
214
215
216
217
218 public static final NotificationSender buildTestNotificationSender(String userId) {
219 NotificationSender sender = new NotificationSender();
220 sender.setSenderName(userId);
221 return sender;
222 }
223
224
225
226
227
228 public static final NotificationSender getTestSender1() {
229 return buildTestNotificationSender("Joe Schmoe");
230 }
231
232
233
234
235
236 public static final NotificationSender getTestSender2() {
237 return buildTestNotificationSender("John Doe");
238 }
239 }