1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.util;
17
18 import java.math.BigDecimal;
19 import java.sql.Time;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import org.joda.time.DateTime;
24 import org.joda.time.DateTimeZone;
25 import org.junit.Test;
26 import org.kuali.hr.test.KPMETestCase;
27 import org.kuali.hr.time.calendar.Calendar;
28 import org.kuali.hr.time.calendar.CalendarEntries;
29 import org.kuali.hr.time.flsa.FlsaWeek;
30 import org.kuali.hr.time.service.base.TkServiceLocator;
31 import org.kuali.hr.time.test.TkTestUtils;
32 import org.kuali.hr.time.timeblock.TimeBlock;
33
34 public class TkTimeBlockAggregateTest extends KPMETestCase {
35
36
37 @Test
38 public void testGetFlsaWeeks() throws Exception {
39 Calendar cal = new Calendar();
40 cal.setFlsaBeginDay("mo");
41 cal.setFlsaBeginTime(new Time((new DateTime(2012, 3, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).getMillis())));
42
43 CalendarEntries pcd = new CalendarEntries();
44 pcd.setBeginPeriodDateTime((new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).toDate()));
45 pcd.setEndPeriodDateTime((new DateTime(2010, 1, 6, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).toDate()));
46
47 List<TimeBlock> blocks = getSomeTimeBlocks();
48 TkTimeBlockAggregate tba = new TkTimeBlockAggregate(blocks, pcd, cal);
49 List<FlsaWeek> weeks = tba.getFlsaWeeks(DateTimeZone.forID(TkServiceLocator.getTimezoneService().getUserTimezone()));
50 }
51
52
53
54
55 private List<TimeBlock> getSomeTimeBlocks() {
56 List<TimeBlock> blocks = new ArrayList<TimeBlock>();
57
58 TimeBlock block = TkTestUtils.createDummyTimeBlock(
59 new DateTime(2010, 1, 1, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
60 new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
61 new BigDecimal(1),
62 "REG");
63 blocks.add(block);
64 block = TkTestUtils.createDummyTimeBlock(
65 new DateTime(2010, 1, 2, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
66 new DateTime(2010, 1, 2, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
67 new BigDecimal(1),
68 "REG");
69 blocks.add(block);
70 block = TkTestUtils.createDummyTimeBlock(
71 new DateTime(2010, 1, 5, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
72 new DateTime(2010, 1, 5, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
73 new BigDecimal(1),
74 "REG");
75 blocks.add(block);
76
77 return blocks;
78 }
79 }