View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.kpme.tklm.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.kpme.core.IntegrationTest;
27  import org.kuali.kpme.core.calendar.Calendar;
28  import org.kuali.kpme.core.calendar.entry.CalendarEntry;
29  import org.kuali.kpme.core.util.TKUtils;
30  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
31  import org.kuali.kpme.tklm.time.flsa.FlsaWeek;
32  import org.kuali.kpme.tklm.time.timeblock.TimeBlock;
33  import org.kuali.kpme.tklm.utils.TkTestUtils;
34  
35  @IntegrationTest
36  public class TkTimeBlockAggregateTest extends TKLMIntegrationTestCase {
37  
38  
39  	@Test
40  	public void testGetFlsaWeeks() throws Exception {
41  		Calendar cal = new Calendar();
42  		cal.setFlsaBeginDay("mo");
43  		cal.setFlsaBeginTime(new Time((new DateTime(2012, 3, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).getMillis())));
44  
45  		CalendarEntry pcd = new CalendarEntry();
46  		pcd.setBeginPeriodFullDateTime(new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()));
47  		pcd.setEndPeriodFullDateTime(new DateTime(2010, 1, 6, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()));
48  
49  		List<TimeBlock> blocks = getSomeTimeBlocks();
50  		TkTimeBlockAggregate tba = new TkTimeBlockAggregate(blocks, pcd, cal);
51  		List<FlsaWeek> weeks = tba.getFlsaWeeks(DateTimeZone.UTC, 0, false);
52  	}
53  
54  
55  
56  
57  	private List<TimeBlock> getSomeTimeBlocks() {
58  		List<TimeBlock> blocks = new ArrayList<TimeBlock>();
59  
60  		TimeBlock block = TkTestUtils.createDummyTimeBlock(
61  				new DateTime(2010, 1, 1, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
62  				new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
63  				new BigDecimal(1),
64  				"REG");
65  		blocks.add(block);
66  		block = TkTestUtils.createDummyTimeBlock(
67  				new DateTime(2010, 1, 2, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
68  				new DateTime(2010, 1, 2, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
69  				new BigDecimal(1),
70  				"REG");
71  		blocks.add(block);
72  		block = TkTestUtils.createDummyTimeBlock(
73  				new DateTime(2010, 1, 5, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
74  				new DateTime(2010, 1, 5, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
75  				new BigDecimal(1),
76  				"REG");
77  		blocks.add(block);
78  
79  		return blocks;
80  	}
81  }