View Javadoc
1   /**
2    * Copyright 2004-2014 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 org.joda.time.DateTime;
19  import org.joda.time.DateTimeZone;
20  import org.junit.Test;
21  import org.kuali.kpme.core.IntegrationTest;
22  import org.kuali.kpme.core.api.calendar.Calendar;
23  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
24  import org.kuali.kpme.core.calendar.CalendarBo;
25  import org.kuali.kpme.core.util.TKUtils;
26  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
27  import org.kuali.kpme.tklm.api.time.timeblock.TimeBlock;
28  import org.kuali.kpme.tklm.time.flsa.FlsaWeek;
29  import org.kuali.kpme.tklm.time.timeblock.TimeBlockBo;
30  import org.kuali.kpme.tklm.utils.TkTestUtils;
31  
32  import java.math.BigDecimal;
33  import java.sql.Time;
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  @IntegrationTest
38  public class TkTimeBlockAggregateTest extends TKLMIntegrationTestCase {
39  
40  
41  	@Test
42  	public void testGetFlsaWeeks() throws Exception {
43  		Calendar.Builder cal = Calendar.Builder.create();
44  		cal.setFlsaBeginDay("mo");
45  		cal.setFlsaBeginLocalTime((new DateTime(2012, 3, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).toLocalTime()));
46  
47  		CalendarEntry.Builder pcd =  CalendarEntry.Builder.create();
48  		pcd.setBeginPeriodFullDateTime(new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()));
49  		pcd.setEndPeriodFullDateTime(new DateTime(2010, 1, 6, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()));
50  
51  		List<TimeBlock> blocks = getSomeTimeBlocks();
52  		TkTimeBlockAggregate tba = new TkTimeBlockAggregate(blocks, pcd.build(), cal.build());
53  		List<FlsaWeek> weeks = tba.getFlsaWeeks(DateTimeZone.UTC, 0, false);
54  	}
55  
56  
57  
58  
59  	private List<TimeBlock> getSomeTimeBlocks() {
60  		List<TimeBlock> blocks = new ArrayList<TimeBlock>();
61  
62  		TimeBlockBo block = TkTestUtils.createDummyTimeBlock(
63  				new DateTime(2010, 1, 1, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
64  				new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
65  				new BigDecimal(1),
66  				"REG");
67  		blocks.add(TimeBlockBo.to(block));
68  		block = TkTestUtils.createDummyTimeBlock(
69  				new DateTime(2010, 1, 2, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
70  				new DateTime(2010, 1, 2, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
71  				new BigDecimal(1),
72  				"REG");
73          blocks.add(TimeBlockBo.to(block));
74  		block = TkTestUtils.createDummyTimeBlock(
75  				new DateTime(2010, 1, 5, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
76  				new DateTime(2010, 1, 5, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
77  				new BigDecimal(1),
78  				"REG");
79          blocks.add(TimeBlockBo.to(block));
80  
81  		return blocks;
82  	}
83  }