1 package org.kuali.ole.deliver.service;
2
3 import org.junit.Before;
4 import org.junit.Test;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.deliver.calendar.bo.*;
7 import org.kuali.ole.deliver.calendar.service.impl.OleCalendarServiceImpl;
8 import org.kuali.rice.krad.service.BusinessObjectService;
9 import org.mockito.Mock;
10 import org.mockito.Mockito;
11 import org.mockito.MockitoAnnotations;
12
13 import java.sql.Timestamp;
14 import java.text.SimpleDateFormat;
15 import java.util.*;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19
20
21
22
23 public class OleCalendarServiceImpl_UT {
24
25 private static String CIR_ID = "100";
26 private static String TIME_PERIOD = "10-D";
27 private static String FINE_AMOUNT = "10/H";
28 private static String CURR_DATE = "16-04-2015 16:14:00";
29 private static String DUE_DATE = "13-04-2015 00:00:00";
30 private static String CALENDAR_BEGIN_DATE = "17-03-2014 00:00:00";
31 private static String CALENDAR_END_DATE = null;
32 private static String DATE_FORMAT = "dd-MM-yyyy HH:mm:ss";
33 private static String CALENDAR_FLAG = "true";
34
35 @Mock
36 private BusinessObjectService businessObjectService;
37
38 @Mock
39 private ParameterValueResolver parameterValueResolver;
40
41 @Mock
42 private ParameterValueResolver mockParameterResolverInstance;
43
44
45 @Before
46 public void setUp() throws Exception {
47 MockitoAnnotations.initMocks(this);
48 }
49
50 @Test
51 public void calculateDueDateScenario1() {
52
53
54
55 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
56 HashMap cg = new HashMap();
57 cg.put(OLEConstants.CALENDER_ID, "100");
58
59 HashMap calendarGroup = new HashMap();
60 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
61
62 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays());
63 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
64
65 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
66 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
67 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
68 oleCalendarService.setBusinessObjectService(businessObjectService);
69 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
70 assertNotNull(timestamp);
71 String dateTimestamp=timestamp.toString();
72 assertEquals("2015-05-01 09:00:00.0", dateTimestamp);
73 }
74
75 @Test
76 public void calculateDueDateScenario2() {
77
78
79
80 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
81 HashMap cg = new HashMap();
82 cg.put(OLEConstants.CALENDER_ID, "100");
83
84 HashMap calendarGroup = new HashMap();
85 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
86
87 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithoutHolidays());
88 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
89
90 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
91 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
92 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
93 oleCalendarService.setBusinessObjectService(businessObjectService);
94 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
95 assertNotNull(timestamp);
96 String dateTimestamp=timestamp.toString();
97 assertEquals("2015-04-30 23:59:00.0",dateTimestamp);
98 }
99
100 @Test
101 public void calculateDueDateScenario3() {
102
103
104
105
106 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
107
108 HashMap cg = new HashMap();
109 cg.put(OLEConstants.CALENDER_ID, "100");
110
111 HashMap calendarGroup = new HashMap();
112 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
113
114 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays1());
115 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
116
117 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
118 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
119 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
120 oleCalendarService.setBusinessObjectService(businessObjectService);
121 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
122 assertNotNull(timestamp);
123 String dateTimestamp=timestamp.toString();
124 assertEquals("2015-05-04 23:59:00.0",dateTimestamp);
125 }
126
127 @Test
128 public void calculateDueDateScenario4() {
129
130
131
132
133 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
134 HashMap cg = new HashMap();
135 cg.put(OLEConstants.CALENDER_ID, "100");
136
137 HashMap calendarGroup = new HashMap();
138 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
139
140 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDays());
141 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
142
143 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
144 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
145 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
146 oleCalendarService.setBusinessObjectService(businessObjectService);
147 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
148 assertNotNull(timestamp);
149 String dateTimestamp=timestamp.toString();
150 assertEquals("2015-05-04 23:59:00.0",dateTimestamp);
151 }
152
153 @Test
154 public void calculateDueDateScenario5() {
155
156
157
158
159 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
160 HashMap cg = new HashMap();
161 cg.put(OLEConstants.CALENDER_ID, "100");
162
163 HashMap calendarGroup = new HashMap();
164 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
165
166 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDaysAndPeriods());
167 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
168
169 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
170 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
171 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
172 oleCalendarService.setBusinessObjectService(businessObjectService);
173 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
174 assertNotNull(timestamp);
175 String dateTimestamp=timestamp.toString();
176 assertEquals("2015-05-11 09:00:00.0",dateTimestamp);
177 }
178
179 @Test
180 public void calculateDueDateScenario6() {
181
182
183
184
185 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
186 HashMap cg = new HashMap();
187 cg.put(OLEConstants.CALENDER_ID, "100");
188
189 HashMap calendarGroup = new HashMap();
190 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
191
192 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue());
193 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
194
195 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
196 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
197 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
198 oleCalendarService.setBusinessObjectService(businessObjectService);
199 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
200 assertNotNull(timestamp);
201 String dateTimestamp=timestamp.toString();
202 assertEquals("2015-05-11 09:00:00.0",dateTimestamp);
203 }
204
205 @Test
206 public void calculateDueDateScenario7() {
207
208
209
210
211 CALENDAR_FLAG="false";
212
213 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
214 HashMap cg = new HashMap();
215 cg.put(OLEConstants.CALENDER_ID, "100");
216
217 HashMap calendarGroup = new HashMap();
218 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
219
220 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays());
221 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
222
223 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
224 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
225 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
226 oleCalendarService.setBusinessObjectService(businessObjectService);
227 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
228 assertNotNull(timestamp);
229 String dateTimestamp=timestamp.toString();
230 assertEquals("2015-05-01 09:00:00.0",dateTimestamp);
231 }
232
233 @Test
234 public void calculateDueDateScenario8() {
235
236
237
238
239 CALENDAR_FLAG="false";
240 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
241 HashMap cg = new HashMap();
242 cg.put(OLEConstants.CALENDER_ID, "100");
243
244 HashMap calendarGroup = new HashMap();
245 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
246
247 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithoutHolidays());
248 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
249
250 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
251 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
252 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
253 oleCalendarService.setBusinessObjectService(businessObjectService);
254 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
255 assertNotNull(timestamp);
256 String dateTimestamp=timestamp.toString();
257 assertEquals("2015-04-30 23:59:00.0",dateTimestamp);
258 }
259
260 @Test
261 public void calculateDueDateScenario9() {
262
263
264
265
266 CALENDAR_FLAG="false";
267 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
268 HashMap cg = new HashMap();
269 cg.put(OLEConstants.CALENDER_ID, "100");
270
271 HashMap calendarGroup = new HashMap();
272 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
273
274 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays1());
275 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
276
277 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
278 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
279 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
280 oleCalendarService.setBusinessObjectService(businessObjectService);
281 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
282 assertNotNull(timestamp);
283 String dateTimestamp=timestamp.toString();
284 assertEquals("2015-05-04 23:59:00.0",dateTimestamp);
285 }
286
287 @Test
288 public void calculateDueDateScenario10() {
289
290
291
292
293 CALENDAR_FLAG="false";
294 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
295 HashMap cg = new HashMap();
296 cg.put(OLEConstants.CALENDER_ID, "100");
297
298 HashMap calendarGroup = new HashMap();
299 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
300
301 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDays());
302 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
303
304 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
305 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
306 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
307 oleCalendarService.setBusinessObjectService(businessObjectService);
308 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
309 assertNotNull(timestamp);
310 String dateTimestamp=timestamp.toString();
311 assertEquals("2015-05-04 23:59:00.0",dateTimestamp);
312 }
313
314 @Test
315 public void calculateDueDateScenario11() {
316
317
318
319
320
321 CALENDAR_FLAG="false";
322 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
323
324 HashMap cg = new HashMap();
325 cg.put(OLEConstants.CALENDER_ID, "100");
326
327 HashMap calendarGroup = new HashMap();
328 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
329
330 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDaysAndPeriods());
331 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
332
333 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
334 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
335 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
336 oleCalendarService.setBusinessObjectService(businessObjectService);
337 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
338 assertNotNull(timestamp);
339 String dateTimestamp=timestamp.toString();
340 assertEquals("2015-05-11 09:00:00.0",dateTimestamp);
341 }
342
343 @Test
344 public void calculateDueDateScenario12() {
345
346
347
348
349
350 CALENDAR_FLAG="false";
351 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
352 HashMap cg = new HashMap();
353 cg.put(OLEConstants.CALENDER_ID, "100");
354
355 HashMap calendarGroup = new HashMap();
356 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
357
358 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue());
359 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
360
361 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
362 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
363 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
364 oleCalendarService.setBusinessObjectService(businessObjectService);
365 Timestamp timestamp = oleCalendarService.calculateDueDate(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
366 assertNotNull(timestamp);
367 String dateTimestamp=timestamp.toString();
368 assertEquals("2015-05-11 09:00:00.0",dateTimestamp);
369 }
370
371 @Test
372 public void calculateDueDateHrsScenario1() {
373
374
375
376 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
377
378 HashMap cg = new HashMap();
379 cg.put(OLEConstants.CALENDER_ID, "100");
380
381 HashMap calendarGroup = new HashMap();
382 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
383 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays());
384 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
385
386 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
387 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
388 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
389 oleCalendarService.setBusinessObjectService(businessObjectService);
390 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
391 assertNotNull(timestamp);
392 String dateTimestamp=timestamp.toString();
393 assertEquals("2015-04-28 10:14:00.0",dateTimestamp);
394
395 }
396 @Test
397 public void calculateDueDateHrsScenario2() {
398
399
400
401 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
402 HashMap cg = new HashMap();
403 cg.put(OLEConstants.CALENDER_ID, "100");
404
405 HashMap calendarGroup = new HashMap();
406 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
407 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithoutHolidays());
408 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
409
410 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
411 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
412 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
413 oleCalendarService.setBusinessObjectService(businessObjectService);
414 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
415 assertNotNull(timestamp);
416 String dateTimestamp=timestamp.toString();
417 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
418
419 }
420 @Test
421 public void calculateDueDateHrsScenario3() {
422
423
424
425 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
426 HashMap cg = new HashMap();
427 cg.put(OLEConstants.CALENDER_ID, "100");
428
429 HashMap calendarGroup = new HashMap();
430 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
431 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays1());
432 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
433
434 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
435 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
436 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
437 oleCalendarService.setBusinessObjectService(businessObjectService);
438 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
439 assertNotNull(timestamp);
440 String dateTimestamp=timestamp.toString();
441 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
442
443 }
444 @Test
445 public void calculateDueDateHrsScenario4() {
446
447
448
449
450 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
451 HashMap cg = new HashMap();
452 cg.put(OLEConstants.CALENDER_ID, "100");
453
454 HashMap calendarGroup = new HashMap();
455 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
456 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDaysAndPeriods());
457 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
458
459 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
460 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
461 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
462 oleCalendarService.setBusinessObjectService(businessObjectService);
463 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
464 assertNotNull(timestamp);
465 String dateTimestamp=timestamp.toString();
466 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
467
468 }
469 @Test
470 public void calculateDueDateHrsScenario5() {
471
472
473
474
475 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
476
477 HashMap cg = new HashMap();
478 cg.put(OLEConstants.CALENDER_ID, "100");
479
480 HashMap calendarGroup = new HashMap();
481 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
482 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue());
483 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
484
485 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
486 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
487 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
488 oleCalendarService.setBusinessObjectService(businessObjectService);
489 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
490 assertNotNull(timestamp);
491 String dateTimestamp=timestamp.toString();
492 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
493
494 }
495 @Test
496 public void calculateDueDateHrsScenario6() {
497
498
499
500
501 CALENDAR_FLAG="false";
502 TIME_PERIOD="10-H";
503 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
504 HashMap cg = new HashMap();
505 cg.put(OLEConstants.CALENDER_ID, "100");
506
507 HashMap calendarGroup = new HashMap();
508 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
509 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays());
510 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
511
512 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
513 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
514 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
515 oleCalendarService.setBusinessObjectService(businessObjectService);
516 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
517 assertNotNull(timestamp);
518 String dateTimestamp=timestamp.toString();
519 assertEquals("2015-04-28 10:14:00.0",dateTimestamp);
520
521 }
522 @Test
523 public void calculateDueDateHrsScenario7() {
524
525
526
527
528 CALENDAR_FLAG="false";
529 TIME_PERIOD="10-H";
530 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
531 HashMap cg = new HashMap();
532 cg.put(OLEConstants.CALENDER_ID, "100");
533
534 HashMap calendarGroup = new HashMap();
535 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
536 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithoutHolidays());
537 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
538
539 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
540 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
541 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
542 oleCalendarService.setBusinessObjectService(businessObjectService);
543 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
544 assertNotNull(timestamp);
545 String dateTimestamp=timestamp.toString();
546 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
547
548 }
549 @Test
550 public void calculateDueDateHrsScenario8() {
551
552
553
554
555 CALENDAR_FLAG="false";
556 TIME_PERIOD="10-H";
557 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
558
559 HashMap cg = new HashMap();
560 cg.put(OLEConstants.CALENDER_ID, "100");
561
562 HashMap calendarGroup = new HashMap();
563 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
564 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidays1());
565 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
566
567 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
568 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
569 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
570 oleCalendarService.setBusinessObjectService(businessObjectService);
571 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
572 assertNotNull(timestamp);
573 String dateTimestamp=timestamp.toString();
574 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
575
576 }
577 @Test
578 public void calculateDueDateHrsScenario9() {
579
580
581
582 TIME_PERIOD="10-H";
583 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
584 HashMap cg = new HashMap();
585 cg.put(OLEConstants.CALENDER_ID, "100");
586
587 HashMap calendarGroup = new HashMap();
588 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
589 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDays());
590 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
591
592 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
593 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
594 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
595 oleCalendarService.setBusinessObjectService(businessObjectService);
596 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
597 assertNotNull(timestamp);
598 String dateTimestamp=timestamp.toString();
599 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
600
601 }
602 @Test
603 public void calculateDueDateHrsScenario10() {
604
605
606
607
608
609 CALENDAR_FLAG="false";
610 TIME_PERIOD="10-H";
611 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
612 HashMap cg = new HashMap();
613 cg.put(OLEConstants.CALENDER_ID, "100");
614
615 HashMap calendarGroup = new HashMap();
616 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
617 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysExceptionDaysAndPeriods());
618 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
619
620 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
621 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
622 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
623 oleCalendarService.setBusinessObjectService(businessObjectService);
624 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
625 assertNotNull(timestamp);
626 String dateTimestamp=timestamp.toString();
627 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
628
629 }
630 @Test
631 public void calculateDueDateHrsScenario11() {
632
633
634
635
636
637 CALENDAR_FLAG="false";
638 TIME_PERIOD="10-H";
639 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
640 HashMap cg = new HashMap();
641 cg.put(OLEConstants.CALENDER_ID, "100");
642
643 HashMap calendarGroup = new HashMap();
644 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
645 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue());
646 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
647
648 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
649 .APPL_ID, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.CALENDER_FLAG)).thenReturn(CALENDAR_FLAG);
650 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
651 oleCalendarService.setBusinessObjectService(businessObjectService);
652 Timestamp timestamp = oleCalendarService.calculateDueDateHrs(CIR_ID, TIME_PERIOD, getTimeStamp(CURR_DATE));
653 assertNotNull(timestamp);
654 String dateTimestamp=timestamp.toString();
655 assertEquals("2015-04-17 02:15:00.0",dateTimestamp);
656
657 }
658
659 @Test
660 public void calculateFine() {
661
662
663 OleCalendarServiceImpl oleCalendarService = new OleCalendarServiceImpl();
664 Mockito.when(mockParameterResolverInstance.getParameter(OLEConstants
665 .APPL_ID_OLE, OLEConstants.DLVR_NMSPC, OLEConstants.DLVR_CMPNT, OLEConstants.FINE_FLAG)).thenReturn(CALENDAR_FLAG);
666 HashMap cg = new HashMap();
667 cg.put(OLEConstants.CALENDER_ID, "100");
668 HashMap calendarGroup = new HashMap();
669 calendarGroup.put(OLEConstants.CALENDER_ID, "100");
670 oleCalendarService.setParameterValueResolver(mockParameterResolverInstance);
671 oleCalendarService.setBusinessObjectService(businessObjectService);
672 Mockito.when(businessObjectService.findMatching(OleCalendar.class, cg)).thenReturn(getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue());
673 Mockito.when(businessObjectService.findMatching(OleCalendarGroup.class, calendarGroup)).thenReturn(getCalendarGroup());
674 Float fine = oleCalendarService.calculateFine(CIR_ID, getTimeStamp(DUE_DATE), getTimeStamp(CURR_DATE), FINE_AMOUNT);
675 assertNotNull(fine);
676 assertEquals(320.0f,fine,0.0f);
677
678 }
679
680 private List<OleCalendar> getOleCalendarsWithHolidays() {
681 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
682 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
683
684 OleCalendar oleCalendar = new OleCalendar();
685 oleCalendar.setCalendarId("100");
686 oleCalendar.setCalendarDescription("Calendar1");
687 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
688 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
689 oleCalendar.setCalendarGroupId("100");
690
691 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
692 oleCalendarWeek.setCalendarWeekId("100");
693 oleCalendarWeek.setCalendarId("100");
694 oleCalendarWeek.setOpenTime("09:00");
695 oleCalendarWeek.setCloseTime("11:00");
696 oleCalendarWeek.setStartDay("1");
697 oleCalendarWeek.setEndDay("5");
698 oleCalendarWeek.setOpenTimeSession("AM");
699 oleCalendarWeek.setCloseTimeSession("AM");
700 oleCalendarWeek.setEachDayWeek(true);
701 oleCalendarWeeks.add(oleCalendarWeek);
702
703 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
704 oleCalendars.add(oleCalendar);
705 return oleCalendars;
706 }
707
708 private List<OleCalendar> getOleCalendarsWithoutHolidays() {
709 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
710 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
711
712 OleCalendar oleCalendar = new OleCalendar();
713 oleCalendar.setCalendarId("100");
714 oleCalendar.setCalendarDescription("Calendar1");
715 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
716 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
717 oleCalendar.setCalendarGroupId("100");
718
719 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
720 oleCalendarWeek.setCalendarWeekId("100");
721 oleCalendarWeek.setCalendarId("100");
722 oleCalendarWeek.setOpenTime("09:00");
723 oleCalendarWeek.setCloseTime("11:00");
724 oleCalendarWeek.setStartDay("1");
725 oleCalendarWeek.setEndDay("5");
726 oleCalendarWeek.setOpenTimeSession("AM");
727 oleCalendarWeek.setCloseTimeSession("AM");
728 oleCalendarWeeks.add(oleCalendarWeek);
729
730 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
731 oleCalendars.add(oleCalendar);
732 return oleCalendars;
733 }
734
735 private List<OleCalendar> getOleCalendarsWithHolidays1() {
736 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
737 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
738
739 OleCalendar oleCalendar = new OleCalendar();
740 oleCalendar.setCalendarId("100");
741 oleCalendar.setCalendarDescription("Calendar1");
742 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
743 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
744 oleCalendar.setCalendarGroupId("100");
745
746 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
747 oleCalendarWeek.setCalendarWeekId("100");
748 oleCalendarWeek.setCalendarId("100");
749 oleCalendarWeek.setOpenTime("09:00");
750 oleCalendarWeek.setCloseTime("11:00");
751 oleCalendarWeek.setStartDay("1");
752 oleCalendarWeek.setEndDay("2");
753 oleCalendarWeek.setOpenTimeSession("AM");
754 oleCalendarWeek.setCloseTimeSession("AM");
755 oleCalendarWeeks.add(oleCalendarWeek);
756
757 OleCalendarWeek oleCalendarWeek1 = new OleCalendarWeek();
758 oleCalendarWeek1.setCalendarWeekId("100");
759 oleCalendarWeek1.setCalendarId("100");
760 oleCalendarWeek1.setOpenTime("09:00");
761 oleCalendarWeek1.setCloseTime("11:00");
762 oleCalendarWeek1.setStartDay("4");
763 oleCalendarWeek1.setEndDay("5");
764 oleCalendarWeek1.setOpenTimeSession("AM");
765 oleCalendarWeek1.setCloseTimeSession("AM");
766 oleCalendarWeeks.add(oleCalendarWeek1);
767
768 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
769 oleCalendars.add(oleCalendar);
770 return oleCalendars;
771 }
772
773 private List<OleCalendar> getOleCalendarsWithHolidaysExceptionDays() {
774 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
775 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
776 List<OleCalendarExceptionDate> oleCalendarExceptionDates = new ArrayList<>();
777
778 OleCalendar oleCalendar = new OleCalendar();
779 oleCalendar.setCalendarId("100");
780 oleCalendar.setCalendarDescription("Calendar1");
781 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
782 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
783 oleCalendar.setCalendarGroupId("100");
784
785 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
786 oleCalendarWeek.setCalendarWeekId("100");
787 oleCalendarWeek.setCalendarId("100");
788 oleCalendarWeek.setOpenTime("09:00");
789 oleCalendarWeek.setCloseTime("11:00");
790 oleCalendarWeek.setStartDay("1");
791 oleCalendarWeek.setEndDay("2");
792 oleCalendarWeek.setOpenTimeSession("AM");
793 oleCalendarWeek.setCloseTimeSession("AM");
794 oleCalendarWeeks.add(oleCalendarWeek);
795
796 OleCalendarWeek oleCalendarWeek1 = new OleCalendarWeek();
797 oleCalendarWeek1.setCalendarWeekId("100");
798 oleCalendarWeek1.setCalendarId("100");
799 oleCalendarWeek1.setOpenTime("09:00");
800 oleCalendarWeek1.setCloseTime("11:00");
801 oleCalendarWeek1.setStartDay("4");
802 oleCalendarWeek1.setEndDay("5");
803 oleCalendarWeek1.setOpenTimeSession("AM");
804 oleCalendarWeek1.setCloseTimeSession("AM");
805 oleCalendarWeeks.add(oleCalendarWeek1);
806
807 OleCalendarExceptionDate oleCalendarExceptionDate = new OleCalendarExceptionDate();
808 oleCalendarExceptionDate.setCalendarId("100");
809 oleCalendarExceptionDate.setExceptionDateDesc("Holiday");
810 oleCalendarExceptionDate.setDate(getDate("21-04-2015"));
811 oleCalendarExceptionDate.setExceptionType("Holiday");
812 oleCalendarExceptionDates.add(oleCalendarExceptionDate);
813 oleCalendar.setOleCalendarExceptionDateDeleteList(oleCalendarExceptionDates);
814 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
815 oleCalendars.add(oleCalendar);
816 return oleCalendars;
817 }
818
819 private List<OleCalendarGroup> getCalendarGroup(){
820 ArrayList<OleCalendarGroup> oleCalendarGroups = new ArrayList<OleCalendarGroup>();
821 OleCalendarGroup oleCalendarGroup = new OleCalendarGroup();
822 oleCalendarGroup.setActive(true);
823 oleCalendarGroup.setCalendarGroupId(CIR_ID);
824 oleCalendarGroup.setCalendarGroupCode("GRP_001");
825 oleCalendarGroup.setCalendarGroupName("Group 1");
826 oleCalendarGroups.add(oleCalendarGroup);
827 return oleCalendarGroups;
828 }
829
830 private List<OleCalendar> getOleCalendarsWithHolidaysExceptionDaysAndPeriods() {
831 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
832 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
833 List<OleCalendarExceptionDate> oleCalendarExceptionDates = new ArrayList<>();
834 List<OleCalendarExceptionPeriodWeek> oleCalendarExceptionPeriodWeeks = new ArrayList<>();
835 List<OleCalendarExceptionPeriod> oleCalendarExceptionPeriods = new ArrayList<>();
836
837 OleCalendar oleCalendar = new OleCalendar();
838 oleCalendar.setCalendarId("100");
839 oleCalendar.setCalendarDescription("Calendar1");
840 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
841 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
842 oleCalendar.setCalendarGroupId("100");
843
844 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
845 oleCalendarWeek.setCalendarWeekId("100");
846 oleCalendarWeek.setCalendarId("100");
847 oleCalendarWeek.setOpenTime("09:00");
848 oleCalendarWeek.setCloseTime("11:00");
849 oleCalendarWeek.setStartDay("1");
850 oleCalendarWeek.setEndDay("2");
851 oleCalendarWeek.setOpenTimeSession("AM");
852 oleCalendarWeek.setCloseTimeSession("AM");
853 oleCalendarWeeks.add(oleCalendarWeek);
854
855 OleCalendarWeek oleCalendarWeek1 = new OleCalendarWeek();
856 oleCalendarWeek1.setCalendarWeekId("100");
857 oleCalendarWeek1.setCalendarId("100");
858 oleCalendarWeek1.setOpenTime("09:00");
859 oleCalendarWeek1.setCloseTime("11:00");
860 oleCalendarWeek1.setStartDay("4");
861 oleCalendarWeek1.setEndDay("5");
862 oleCalendarWeek1.setOpenTimeSession("AM");
863 oleCalendarWeek1.setCloseTimeSession("AM");
864 oleCalendarWeeks.add(oleCalendarWeek1);
865
866 OleCalendarExceptionDate oleCalendarExceptionDate = new OleCalendarExceptionDate();
867 oleCalendarExceptionDate.setCalendarId("100");
868 oleCalendarExceptionDate.setExceptionDateDesc("Holiday");
869 oleCalendarExceptionDate.setDate(getDate("04-05-2015 00:00:00"));
870 oleCalendarExceptionDate.setExceptionType("Holiday");
871 oleCalendarExceptionDates.add(oleCalendarExceptionDate);
872
873
874 OleCalendarExceptionDate oleCalendarExceptionDate1 = new OleCalendarExceptionDate();
875 oleCalendarExceptionDate1.setCalendarId("100");
876 oleCalendarExceptionDate1.setExceptionDateDesc("Partial");
877 oleCalendarExceptionDate1.setDate(getDate("21-04-2015 00:00:00"));
878 oleCalendarExceptionDate1.setExceptionType("Partial");
879 oleCalendarExceptionDate1.setOpenTime("06:00");
880 oleCalendarExceptionDate1.setCloseTime("10:00");
881 oleCalendarExceptionDate1.setOpenTimeSession("AM");
882 oleCalendarExceptionDate1.setCloseTimeSession("AM");
883 oleCalendarExceptionDates.add(oleCalendarExceptionDate1);
884
885
886 OleCalendarExceptionPeriod oleCalendarExceptionPeriod1 = new OleCalendarExceptionPeriod();
887 oleCalendarExceptionPeriod1.setCalendarId("100");
888 oleCalendarExceptionPeriod1.setBeginDate(getTimeStamp("21-04-2015 00:00:00"));
889 oleCalendarExceptionPeriod1.setEndDate(getTimeStamp("24-04-2015 00:00:00"));
890 oleCalendarExceptionPeriod1.setCalendarExceptionPeriodDesc("Holiday");
891 oleCalendarExceptionPeriod1.setExceptionPeriodType("Holiday");
892
893 OleCalendarExceptionPeriod oleCalendarExceptionPeriod2 = new OleCalendarExceptionPeriod();
894 oleCalendarExceptionPeriod2.setCalendarId("100");
895 oleCalendarExceptionPeriod2.setBeginDate(getTimeStamp("25-04-2015 00:00:00"));
896 oleCalendarExceptionPeriod2.setEndDate(getTimeStamp("28-04-2015 00:00:00"));
897 oleCalendarExceptionPeriod2.setCalendarExceptionPeriodDesc("Partial");
898 oleCalendarExceptionPeriod2.setExceptionPeriodType("Partial");
899
900 OleCalendarExceptionPeriodWeek oleCalendarExceptionPeriodWeek = new OleCalendarExceptionPeriodWeek();
901 oleCalendarExceptionPeriodWeek.setOpenTime("06:00");
902 oleCalendarExceptionPeriodWeek.setCloseTime("10:00");
903 oleCalendarExceptionPeriodWeek.setOpenTimeSession("AM");
904 oleCalendarExceptionPeriodWeek.setCloseTimeSession("AM");
905 oleCalendarExceptionPeriodWeek.setStartDay("4");
906 oleCalendarExceptionPeriodWeek.setEndDay("5");
907
908
909 oleCalendarExceptionPeriodWeeks.add(oleCalendarExceptionPeriodWeek);
910 oleCalendarExceptionPeriod2.setOleCalendarExceptionPeriodWeekList(oleCalendarExceptionPeriodWeeks);
911 oleCalendarExceptionPeriods.add(oleCalendarExceptionPeriod1);
912 oleCalendarExceptionPeriods.add(oleCalendarExceptionPeriod2);
913 oleCalendar.setOleCalendarExceptionPeriodList(oleCalendarExceptionPeriods);
914 oleCalendar.setOleCalendarExceptionDateDeleteList(oleCalendarExceptionDates);
915 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
916 oleCalendars.add(oleCalendar);
917
918 return oleCalendars;
919 }
920
921
922 private List<OleCalendar> getOleCalendarsWithHolidaysEachExceptionDaysAndPeriodsTrue() {
923 List<OleCalendar> oleCalendars = new ArrayList<OleCalendar>();
924 List<OleCalendarWeek> oleCalendarWeeks = new ArrayList<>();
925 List<OleCalendarExceptionDate> oleCalendarExceptionDates = new ArrayList<>();
926 List<OleCalendarExceptionPeriodWeek> oleCalendarExceptionPeriodWeeks = new ArrayList<>();
927 List<OleCalendarExceptionPeriod> oleCalendarExceptionPeriods = new ArrayList<>();
928
929 OleCalendar oleCalendar = new OleCalendar();
930 oleCalendar.setCalendarId("100");
931 oleCalendar.setCalendarDescription("Calendar1");
932 oleCalendar.setBeginDate(getTimeStamp(CALENDAR_BEGIN_DATE));
933 oleCalendar.setEndDate(getTimeStamp(CALENDAR_END_DATE));
934 oleCalendar.setCalendarGroupId("100");
935
936 OleCalendarWeek oleCalendarWeek = new OleCalendarWeek();
937 oleCalendarWeek.setCalendarWeekId("100");
938 oleCalendarWeek.setCalendarId("100");
939 oleCalendarWeek.setOpenTime("09:00");
940 oleCalendarWeek.setCloseTime("11:00");
941 oleCalendarWeek.setStartDay("1");
942 oleCalendarWeek.setEndDay("2");
943 oleCalendarWeek.setOpenTimeSession("AM");
944 oleCalendarWeek.setCloseTimeSession("AM");
945 oleCalendarWeeks.add(oleCalendarWeek);
946
947 OleCalendarWeek oleCalendarWeek1 = new OleCalendarWeek();
948 oleCalendarWeek1.setCalendarWeekId("100");
949 oleCalendarWeek1.setCalendarId("100");
950 oleCalendarWeek1.setOpenTime("09:00");
951 oleCalendarWeek1.setCloseTime("11:00");
952 oleCalendarWeek1.setStartDay("4");
953 oleCalendarWeek1.setEndDay("5");
954 oleCalendarWeek1.setOpenTimeSession("AM");
955 oleCalendarWeek1.setCloseTimeSession("AM");
956 oleCalendarWeeks.add(oleCalendarWeek1);
957
958 OleCalendarExceptionDate oleCalendarExceptionDate = new OleCalendarExceptionDate();
959 oleCalendarExceptionDate.setCalendarId("100");
960 oleCalendarExceptionDate.setExceptionDateDesc("Holiday");
961 oleCalendarExceptionDate.setDate(getDate("04-05-2015 00:00:00"));
962 oleCalendarExceptionDate.setExceptionType("Holiday");
963 oleCalendarExceptionDates.add(oleCalendarExceptionDate);
964
965
966 OleCalendarExceptionDate oleCalendarExceptionDate1 = new OleCalendarExceptionDate();
967 oleCalendarExceptionDate1.setCalendarId("100");
968 oleCalendarExceptionDate1.setExceptionDateDesc("Partial");
969 oleCalendarExceptionDate1.setDate(getDate("21-04-2015 00:00:00"));
970 oleCalendarExceptionDate1.setExceptionType("Partial");
971 oleCalendarExceptionDate1.setOpenTime("06:00");
972 oleCalendarExceptionDate1.setCloseTime("10:00");
973 oleCalendarExceptionDate1.setOpenTimeSession("AM");
974 oleCalendarExceptionDate1.setCloseTimeSession("AM");
975 oleCalendarExceptionDates.add(oleCalendarExceptionDate1);
976
977
978 OleCalendarExceptionPeriod oleCalendarExceptionPeriod1 = new OleCalendarExceptionPeriod();
979 oleCalendarExceptionPeriod1.setCalendarId("100");
980 oleCalendarExceptionPeriod1.setBeginDate(getTimeStamp("21-04-2015 00:00:00"));
981 oleCalendarExceptionPeriod1.setEndDate(getTimeStamp("24-04-2015 00:00:00"));
982 oleCalendarExceptionPeriod1.setCalendarExceptionPeriodDesc("Holiday");
983 oleCalendarExceptionPeriod1.setExceptionPeriodType("Holiday");
984
985 OleCalendarExceptionPeriod oleCalendarExceptionPeriod2 = new OleCalendarExceptionPeriod();
986 oleCalendarExceptionPeriod2.setCalendarId("100");
987 oleCalendarExceptionPeriod2.setBeginDate(getTimeStamp("25-04-2015 00:00:00"));
988 oleCalendarExceptionPeriod2.setEndDate(getTimeStamp("28-04-2015 00:00:00"));
989 oleCalendarExceptionPeriod2.setCalendarExceptionPeriodDesc("Partial");
990 oleCalendarExceptionPeriod2.setExceptionPeriodType("Partial");
991
992 OleCalendarExceptionPeriodWeek oleCalendarExceptionPeriodWeek = new OleCalendarExceptionPeriodWeek();
993 oleCalendarExceptionPeriodWeek.setOpenTime("06:00");
994 oleCalendarExceptionPeriodWeek.setCloseTime("10:00");
995 oleCalendarExceptionPeriodWeek.setOpenTimeSession("AM");
996 oleCalendarExceptionPeriodWeek.setCloseTimeSession("AM");
997 oleCalendarExceptionPeriodWeek.setStartDay("4");
998 oleCalendarExceptionPeriodWeek.setEndDay("5");
999 oleCalendarExceptionPeriodWeek.setEachDayOfExceptionWeek(true);
1000
1001
1002 oleCalendarExceptionPeriodWeeks.add(oleCalendarExceptionPeriodWeek);
1003 oleCalendarExceptionPeriod2.setOleCalendarExceptionPeriodWeekList(oleCalendarExceptionPeriodWeeks);
1004 oleCalendarExceptionPeriods.add(oleCalendarExceptionPeriod1);
1005 oleCalendarExceptionPeriods.add(oleCalendarExceptionPeriod2);
1006 oleCalendar.setOleCalendarExceptionPeriodList(oleCalendarExceptionPeriods);
1007 oleCalendar.setOleCalendarExceptionDateDeleteList(oleCalendarExceptionDates);
1008 oleCalendar.setOleCalendarWeekList(oleCalendarWeeks);
1009 oleCalendars.add(oleCalendar);
1010
1011 return oleCalendars;
1012 }
1013
1014 private Date getDate(String dateString) {
1015 Date date = null;
1016 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
1017 try {
1018 date = simpleDateFormat.parse(dateString);
1019 } catch (Exception e) {
1020 e.printStackTrace();
1021 }
1022 return date;
1023 }
1024
1025 private Timestamp getTimeStamp(String dateString) {
1026 if (dateString == null) {
1027 return null;
1028 }
1029 Date date = getDate(dateString);
1030 if (date != null) {
1031 return new Timestamp(date.getTime());
1032 } else {
1033 return new Timestamp(System.currentTimeMillis());
1034 }
1035 }
1036 }