1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.workschedule.service;
17
18 import java.sql.Date;
19 import java.util.List;
20
21 import org.joda.time.DateTime;
22 import org.joda.time.DateTimeZone;
23 import org.junit.Assert;
24 import org.junit.Ignore;
25 import org.junit.Test;
26 import org.kuali.hr.test.KPMETestCase;
27 import org.kuali.hr.time.service.base.TkServiceLocator;
28 import org.kuali.hr.time.util.TKUtils;
29 import org.kuali.hr.time.util.TkConstants;
30 import org.kuali.hr.time.workschedule.WorkSchedule;
31 import org.kuali.hr.time.workschedule.WorkScheduleEntry;
32
33 public class WorkScheduleServiceTest extends KPMETestCase {
34
35 @Test
36 @Ignore
37 public void testGetWorkSchedules() throws Exception {
38 WorkScheduleService wss = TkServiceLocator.getWorkScheduleService();
39 String dept = null;
40 String principalId = null;
41 Long workScheduleId = null;
42 Long workArea = null;
43 Date asOfDate = new Date((new DateTime(2010, 1, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
44 List<WorkSchedule> schedules = null;
45
46
47 workScheduleId = 1L;
48 dept = "TEST-DEPT";
49 principalId = "admin";
50 workArea = 1234L;
51
52 Assert.assertNotNull("Null return list", schedules);
53 Assert.assertEquals("Wrong number of elements returned.", 1, schedules.size());
54 Assert.assertEquals("Wrong ID returned", workScheduleId, (schedules.get(0)).getHrWorkScheduleId());
55
56 workScheduleId = 2L;
57 dept = "TEST-DEPT";
58 principalId = "admin";
59 workArea = -999L;
60
61 Assert.assertNotNull("Null return list", schedules);
62 Assert.assertEquals("Wrong number of elements returned.", 1, schedules.size());
63 Assert.assertEquals("Wrong ID returned", workScheduleId, (schedules.get(0)).getHrWorkScheduleId());
64
65
66 workScheduleId = 3L;
67 dept = "NOTFOUND";
68 principalId = "admin";
69 workArea = 1234L;
70
71 Assert.assertNotNull("Null return list", schedules);
72 Assert.assertEquals("Wrong number of elements returned.", 1, schedules.size());
73 Assert.assertEquals("Wrong ID returned", workScheduleId, (schedules.get(0)).getHrWorkScheduleId());
74 }
75
76 @Test
77 public void testWorkScheduleFlattening() throws Exception{
78 WorkSchedule workSchedule = new WorkSchedule();
79 Date asOfDate = new Date((new DateTime(2010, 1, 1, 12, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
80 workSchedule.setEffectiveDate(asOfDate);
81 WorkScheduleEntry wse = new WorkScheduleEntry();
82 for(int i = 0 ;i<TkConstants.LENGTH_OF_WORK_SCHEDULE;i++){
83 workSchedule.getWorkScheduleEntries().add(wse);
84 }
85 Date beginPeriodDate = new Date((new DateTime(2010, 1, 3, 1, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
86 Date endPeriodDate = new Date((new DateTime(2010, 1, 15, 1, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
87
88 List<WorkScheduleEntry> lstWorkSchedEntries = TkServiceLocator.getWorkScheduleService().getWorkSchedEntries(
89 workSchedule, beginPeriodDate, endPeriodDate);
90
91 Assert.assertTrue("verify work sched entries is correct", lstWorkSchedEntries!= null);
92 }
93 }