1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.leave.block;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import junit.framework.Assert;
22
23 import org.joda.time.LocalDate;
24 import org.junit.Test;
25 import org.kuali.kpme.core.IntegrationTest;
26 import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
27 import org.kuali.kpme.core.calendar.entry.CalendarEntryBo;
28 import org.kuali.kpme.core.service.HrServiceLocator;
29 import org.kuali.kpme.core.util.TKUtils;
30 import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
31 import org.kuali.kpme.tklm.api.leave.block.LeaveBlock;
32 import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
33
34 @IntegrationTest
35 public class LeaveBlockAggregateTest extends TKLMIntegrationTestCase {
36 private String TEST_USER = "admin";
37
38 @Test
39 public void testGetLeaveBlockAggregate(){
40
41 LocalDate beginDate = new LocalDate(2012, 3, 1);
42 LocalDate endDate = beginDate.plusDays(14);
43 CalendarEntry ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("55");
44 List<LeaveBlock> leaveBlocks = new ArrayList<LeaveBlock>();
45 leaveBlocks.addAll(LmServiceLocator.getLeaveBlockService().getLeaveBlocks(TEST_USER, beginDate, endDate));
46
47
48 LeaveBlockAggregate lbAgg = new LeaveBlockAggregate(leaveBlocks, ce, TKUtils.getFullWeekDaySpanForCalendarEntry(ce));
49 Assert.assertNotNull("LeaveBlockAggregate should not be null.", lbAgg);
50 Assert.assertTrue("LeaveBlockAggregate should have 21 days, not " + lbAgg.getDayLeaveBlockList().size(), lbAgg.getDayLeaveBlockList().size() == 21);
51 Assert.assertTrue("There should be 1 leave block on 03/01.", lbAgg.getDayLeaveBlockList().get(4).size() == 1);
52 Assert.assertTrue("There should be 1 leave block on 03/02.", lbAgg.getDayLeaveBlockList().get(5).size() == 1);
53
54
55 lbAgg = new LeaveBlockAggregate(leaveBlocks, ce);
56 Assert.assertNotNull("LeaveBlockAggregate should not be null.", lbAgg);
57 Assert.assertTrue("LeaveBlockAggregate should have 14 days, not " + lbAgg.getDayLeaveBlockList().size(), lbAgg.getDayLeaveBlockList().size() == 14);
58 Assert.assertTrue("There should be 1 leave block on 03/01.", lbAgg.getDayLeaveBlockList().get(0).size() == 1);
59 Assert.assertTrue("There should be 1 leave block on 03/02.", lbAgg.getDayLeaveBlockList().get(1).size() == 1);
60 }
61 }