001    /**
002     * Copyright 2004-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.util;
017    
018    import java.math.BigDecimal;
019    import java.sql.Time;
020    import java.util.ArrayList;
021    import java.util.List;
022    
023    import org.joda.time.DateTime;
024    import org.joda.time.DateTimeZone;
025    import org.junit.Test;
026    import org.kuali.hr.test.KPMETestCase;
027    import org.kuali.hr.time.calendar.Calendar;
028    import org.kuali.hr.time.calendar.CalendarEntries;
029    import org.kuali.hr.time.flsa.FlsaWeek;
030    import org.kuali.hr.time.service.base.TkServiceLocator;
031    import org.kuali.hr.time.test.TkTestUtils;
032    import org.kuali.hr.time.timeblock.TimeBlock;
033    
034    public class TkTimeBlockAggregateTest extends KPMETestCase {
035    
036    
037            @Test
038            public void testGetFlsaWeeks() throws Exception {
039                    Calendar cal = new Calendar();
040                    cal.setFlsaBeginDay("mo");
041                    cal.setFlsaBeginTime(new Time((new DateTime(2012, 3, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).getMillis())));
042    
043                    CalendarEntries pcd = new CalendarEntries();
044                    pcd.setBeginPeriodDateTime((new DateTime(2010, 1, 1, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).toDate()));
045                    pcd.setEndPeriodDateTime((new DateTime(2010, 1, 6, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone()).toDate()));
046    
047                    List<TimeBlock> blocks = getSomeTimeBlocks();
048                    TkTimeBlockAggregate tba = new TkTimeBlockAggregate(blocks, pcd, cal);
049                    List<FlsaWeek> weeks = tba.getFlsaWeeks(DateTimeZone.forID(TkServiceLocator.getTimezoneService().getUserTimezone()));
050            }
051    
052    
053    
054    
055            private List<TimeBlock> getSomeTimeBlocks() {
056                    List<TimeBlock> blocks = new ArrayList<TimeBlock>();
057    
058                    TimeBlock block = TkTestUtils.createDummyTimeBlock(
059                                    new DateTime(2010, 1, 1, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
060                                    new DateTime(2010, 1, 1, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
061                                    new BigDecimal(1),
062                                    "REG");
063                    blocks.add(block);
064                    block = TkTestUtils.createDummyTimeBlock(
065                                    new DateTime(2010, 1, 2, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
066                                    new DateTime(2010, 1, 2, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
067                                    new BigDecimal(1),
068                                    "REG");
069                    blocks.add(block);
070                    block = TkTestUtils.createDummyTimeBlock(
071                                    new DateTime(2010, 1, 5, 15, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
072                                    new DateTime(2010, 1, 5, 16, 0, 0, 0, TKUtils.getSystemDateTimeZone()),
073                                    new BigDecimal(1),
074                                    "REG");
075                    blocks.add(block);
076    
077                    return blocks;
078            }
079    }