1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.tklm.leave.summary;
17
18 import java.math.BigDecimal;
19 import java.util.Date;
20 import java.util.List;
21
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.kuali.kpme.core.IntegrationTest;
25 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
26 import org.kuali.kpme.core.service.HrServiceLocator;
27 import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
28 import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
29
30 @IntegrationTest
31 public class LeaveSummaryServiceImplTest extends TKLMIntegrationTestCase {
32
33 @Test
34 public void testGetLeaveSummary() throws Exception {
35
36 CalendarEntry ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("56");
37
38 LeaveSummary ls = LmServiceLocator.getLeaveSummaryService().getLeaveSummary("testUser", ce);
39 Assert.assertTrue("There ytd dates String should be 'March 1 - March 14 2012', not " + ls.getYtdDatesString(), ls.getYtdDatesString().equals("March 1 - March 14 2012"));
40 Assert.assertTrue("There pending dates String should be 'March 15 - March 31 2012', not " + ls.getPendingDatesString(), ls.getPendingDatesString().equals("March 15 - March 31 2012"));
41
42 List<LeaveSummaryRow> rows = ls.getLeaveSummaryRows();
43 Assert.assertTrue("There should be 1 leave summary rows for emplyee 'testUser', not " + rows.size(), rows.size()== 1);
44 LeaveSummaryRow aRow = rows.get(0);
45 Assert.assertTrue("Accrual cateogry for Row should be 'testAC', not " + aRow.getAccrualCategory(), aRow.getAccrualCategory().equals("testAC"));
46 Assert.assertTrue("Carry over for Row should be '0', not " + aRow.getCarryOver(), aRow.getCarryOver().compareTo(BigDecimal.ZERO) == 0);
47 Assert.assertTrue("YTD accrualed balance for Row should be '8', not " + aRow.getYtdAccruedBalance(), aRow.getYtdAccruedBalance().compareTo(new BigDecimal(8)) == 0);
48 Assert.assertTrue("YTD approved usage for Row should be '-3', not " + aRow.getYtdApprovedUsage(), aRow.getYtdApprovedUsage().compareTo(new BigDecimal(-3)) == 0);
49 Assert.assertTrue("Leave Balance for Row should be '11', not " + aRow.getLeaveBalance(), aRow.getLeaveBalance().compareTo(new BigDecimal(11)) == 0);
50 Assert.assertTrue("Pending Leave Accrual for Row should be '10', not " + aRow.getPendingLeaveAccrual(), aRow.getPendingLeaveAccrual().compareTo(new BigDecimal(10)) == 0);
51 Assert.assertTrue("Pending Leave requests for Row should be '0', not " + aRow.getPendingLeaveRequests(), aRow.getPendingLeaveRequests().compareTo(new BigDecimal(0)) == 0);
52
53
54 Assert.assertTrue("Usage Limit for Row should be '200', not " + aRow.getUsageLimit(), aRow.getUsageLimit().compareTo(new BigDecimal(200)) == 0);
55 Assert.assertTrue("FMLA usage for Row should be '-3', not " + aRow.getFmlaUsage(), aRow.getFmlaUsage().compareTo(new BigDecimal(-3)) == 0);
56
57
58 ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("58");
59 ls = LmServiceLocator.getLeaveSummaryService().getLeaveSummary("testUser", ce);
60 Assert.assertTrue("There ytd dates String should be 'March 1 - March 14 2012', not " + ls.getYtdDatesString(), ls.getYtdDatesString().equals("March 1 - March 14 2012"));
61 Assert.assertTrue("There pending dates String should be 'April 15 - April 30 2012', not " + ls.getPendingDatesString(), ls.getPendingDatesString().equals("April 15 - April 30 2012"));
62
63 rows = ls.getLeaveSummaryRows();
64 Assert.assertTrue("There should be 1 leave summary rows for emplyee 'testUser', not " + rows.size(), rows.size()== 1);
65 aRow = rows.get(0);
66 Assert.assertTrue("Accrual cateogry for Row should be 'testAC', not " + aRow.getAccrualCategory(), aRow.getAccrualCategory().equals("testAC"));
67 Assert.assertTrue("Carry over for Row should be '0', not " + aRow.getCarryOver(), aRow.getCarryOver().compareTo(BigDecimal.ZERO)==0);
68 Assert.assertTrue("YTD accrual balance for Row should be '8', not " + aRow.getYtdAccruedBalance(), aRow.getYtdAccruedBalance().compareTo(new BigDecimal(8))==0);
69 Assert.assertTrue("YTD approved usage for Row should be '-13', not " + aRow.getYtdApprovedUsage(), aRow.getYtdApprovedUsage().compareTo(new BigDecimal(-13))==0);
70 Assert.assertTrue("Leave Balance for Row should be '21', not " + aRow.getLeaveBalance(), aRow.getLeaveBalance().compareTo(new BigDecimal(21))==0);
71 Assert.assertTrue("Pending Leave Accrual for Row should be '0', not " + aRow.getPendingLeaveAccrual(), aRow.getPendingLeaveAccrual().compareTo(BigDecimal.ZERO)==0);
72 Assert.assertTrue("Pending Leave requests for Row should be '0', not " + aRow.getPendingLeaveRequests(), aRow.getPendingLeaveRequests().compareTo(new BigDecimal(0))==0);
73
74
75 Assert.assertTrue("Usage Limit for Row should be '200', not " + aRow.getUsageLimit(), aRow.getUsageLimit().compareTo(new BigDecimal(200)) == 0);
76 Assert.assertTrue("FMLA usage for Row should be '-3', not " + aRow.getFmlaUsage(), aRow.getFmlaUsage().compareTo(new BigDecimal(-3)) == 0);
77
78
79 ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("59");
80 ls = LmServiceLocator.getLeaveSummaryService().getLeaveSummary("testUser", ce);
81 Assert.assertTrue("There ytd dates String should be 'March 1 - March 14 2012', not " + ls.getYtdDatesString(), ls.getYtdDatesString().equals("March 1 - March 14 2012"));
82 Assert.assertTrue("There pending dates String should be 'May 1 - May 14 2012', not " + ls.getPendingDatesString(), ls.getPendingDatesString().equals("May 1 - May 14 2012"));
83
84 rows = ls.getLeaveSummaryRows();
85 Assert.assertTrue("There should be 2 leave summary rows for employee 'testUser', not " + rows.size(), rows.size()== 2);
86 for(LeaveSummaryRow lsRow : rows ) {
87 if(lsRow.getAccrualCategory().equals("testAC")) {
88 Assert.assertTrue("Carry over for Row should be '0', not " + lsRow.getCarryOver(), lsRow.getCarryOver().compareTo(BigDecimal.ZERO) == 0);
89 Assert.assertTrue("YTD accrualed balance for Row should be '8', not " + lsRow.getYtdAccruedBalance(), lsRow.getYtdAccruedBalance().compareTo(new BigDecimal(8)) == 0);
90 Assert.assertTrue("YTD approved usage for Row should be '-13', not " + lsRow.getYtdApprovedUsage(), lsRow.getYtdApprovedUsage().compareTo(new BigDecimal(-13)) == 0);
91 Assert.assertTrue("Leave Balance for Row should be '21', not " + lsRow.getLeaveBalance(), lsRow.getLeaveBalance().compareTo(new BigDecimal(21)) == 0);
92 Assert.assertTrue("Pending Leave Accrual for Row should be '0', not " + lsRow.getPendingLeaveAccrual(), lsRow.getPendingLeaveAccrual().compareTo(BigDecimal.ZERO) == 0);
93 Assert.assertTrue("Pending Leave requests for Row should be '0', not " + lsRow.getPendingLeaveRequests(), lsRow.getPendingLeaveRequests().compareTo(new BigDecimal(0)) == 0);
94
95
96 Assert.assertTrue("Usage Limit for Row should be '200', not " + lsRow.getUsageLimit(), lsRow.getUsageLimit().compareTo(new BigDecimal(200)) == 0);
97 Assert.assertTrue("FMLA usage for Row should be '-3', not " + lsRow.getFmlaUsage(), lsRow.getFmlaUsage().compareTo(new BigDecimal(-3)) == 0);
98 } else if(lsRow.getAccrualCategory().equals("testAC1")) {
99 Assert.assertTrue("Carry over for Row should be '0', not " + lsRow.getCarryOver(), lsRow.getCarryOver().compareTo(BigDecimal.ZERO) == 0);
100 Assert.assertTrue("YTD accrualed balance for Row should be '0', not " + lsRow.getYtdAccruedBalance(), lsRow.getYtdAccruedBalance().compareTo(new BigDecimal(0)) == 0);
101 Assert.assertTrue("YTD approved usage for Row should be '-8', not " + lsRow.getYtdApprovedUsage(), lsRow.getYtdApprovedUsage().compareTo(new BigDecimal(-8)) == 0);
102 Assert.assertTrue("Leave Balance for Row should be '8', not " + lsRow.getLeaveBalance(), lsRow.getLeaveBalance().compareTo(new BigDecimal(8)) == 0);
103 Assert.assertTrue("Pending Leave Accrual for Row should be '0', not " + lsRow.getPendingLeaveAccrual(), lsRow.getPendingLeaveAccrual().compareTo(BigDecimal.ZERO) == 0);
104 Assert.assertTrue("Pending Leave requests for Row should be '0', not " + lsRow.getPendingLeaveRequests(), lsRow.getPendingLeaveRequests().compareTo(new BigDecimal(0)) == 0);
105
106
107 Assert.assertTrue("Usage Limit for Row should be '300', not " + lsRow.getUsageLimit(), lsRow.getUsageLimit().compareTo(new BigDecimal(300)) == 0);
108 Assert.assertTrue("FMLA usage for Row should be '0', not " + lsRow.getFmlaUsage(), lsRow.getFmlaUsage().compareTo(new BigDecimal(0)) == 0);
109 } else {
110 Assert.fail("Accrual category for Row should either be 'testAC' or 'testAC1', not " + lsRow.getAccrualCategory());
111 }
112 }
113
114
115
116 ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("53");
117 ls = LmServiceLocator.getLeaveSummaryService().getLeaveSummary("testUser", ce);
118 rows = ls.getLeaveSummaryRows();
119 Assert.assertTrue("There should be 1 leave summary rows for emplyee 'testUser', not " + rows.size(), rows.size()== 1);
120 }
121
122 @Test
123 public void testGetHeaderForSummary() throws Exception {
124 CalendarEntry ce = HrServiceLocator.getCalendarEntryService().getCalendarEntry("56");
125 List<Date> leaveSummaryDates = LmServiceLocator.getLeaveSummaryService().getLeaveSummaryDates(ce);
126
127 Assert.assertTrue("The number of leave summary dates should be 17, not " + leaveSummaryDates.size(), leaveSummaryDates.size()== 17);
128
129 }
130 }