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.leave.accrual;
17  
18  import java.math.BigDecimal;
19  import java.util.List;
20  
21  import org.joda.time.DateTime;
22  import org.joda.time.LocalDate;
23  import org.junit.Assert;
24  import org.junit.Test;
25  import org.kuali.kpme.core.IntegrationTest;
26  import org.kuali.kpme.core.util.HrConstants;
27  import org.kuali.kpme.core.util.TKUtils;
28  import org.kuali.kpme.tklm.TKLMIntegrationTestCase;
29  import org.kuali.kpme.tklm.common.LMConstants;
30  import org.kuali.kpme.tklm.leave.block.LeaveBlock;
31  import org.kuali.kpme.tklm.leave.block.LeaveBlockHistory;
32  import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
33  
34  @IntegrationTest
35  public class AccrualServiceTest extends TKLMIntegrationTestCase {
36  	 DateTime START_DATE = new DateTime(2012, 2, 20, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
37  	 DateTime END_DATE = new DateTime(2012, 5, 3, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
38  	
39  	@Test
40  	/*the employee has job A starts from 03/01/2012, ends on 04/01/2012 with standard hours of 40, so fte is 1.0
41  	 * job B starts on 04/01/2012, no end to it with standard hours of 20, fte is 0.5
42  	 * on 04/10/2012, there's a system scheduled time off of 8 hrs with a systemScheduledTimeOffDate of 04/12/2012
43  	 * on 04/11/2012, there's a system scheduled time off of 8 hrs without a systemScheduledTimeOffDate, so no usage leave block will be created for this ssto
44  	 */
45  	public void testRunAccrualForStatusChange() {
46  		 String principal_id = "testUser";
47  		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), END_DATE.toLocalDate());
48  		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
49  		 
50  		 // first time to run accrual from 02/20/2012 to 05/03/2012
51  		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, END_DATE, false, "admin");
52  		 verifyLeaveBlocksForStatusChange();
53  		 
54  		 List<LeaveBlockHistory> historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories(principal_id, null);
55  		 Assert.assertTrue("There should be 6 leave block history for emplyee " + principal_id + ", not " + historyList.size(), historyList.size()== 6);
56  		 LeaveBlockHistory lbh = historyList.get(0);
57  		 Assert.assertTrue("Leave Block Type of leave block history should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lbh.getLeaveBlockType()
58  					, lbh.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
59  		 
60  		 // second time to run accrual from 02/20/2012 to 05/03/2012, should get the same results as first run
61  		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, END_DATE, false, "admin");
62  		 verifyLeaveBlocksForStatusChange();
63  		 
64  		 historyList = LmServiceLocator.getLeaveBlockHistoryService().getLeaveBlockHistories(principal_id, null);
65  		 Assert.assertTrue("There should be 16 leave block history for employee " + principal_id + ", not " + historyList.size(), historyList.size()== 16);
66  	}
67  	private void verifyLeaveBlocksForStatusChange() {
68  		String principal_id = "testUser";
69  		List<LeaveBlock> leaveBlockList;
70  		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), END_DATE.toLocalDate());
71  		Assert.assertFalse("No leave blocks created by runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
72  		Assert.assertTrue("There should be 6 leave blocks for emplyee 'testUser', not " + leaveBlockList.size(), leaveBlockList.size()== 6);
73  		 
74  		// there should be one leave block of 16 hours on 03/31/2012
75  		DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
76  		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
77  		Assert.assertTrue("There should be 1 leave block for date 03/31/2012.", leaveBlockList.size()==1);
78  		LeaveBlock lb = leaveBlockList.get(0);
79  		Assert.assertTrue("Hours of the leave block for date 03/31/2012 should be 16, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(16)));
80  		Assert.assertNull("lm_sys_schd_timeoff_id should be null for regular accrual leave block", lb.getScheduleTimeOffId());
81  		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
82  				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
83  		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
84  				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
85  		
86  		// employee changed status on 04/01, fte is changed from 1 to 0.5
87  		// there should be an empty leave block for status change on 04/01/2012
88  		intervalDate = new DateTime(2012, 4, 01, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
89  		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
90  		Assert.assertTrue("There should be 1 leave block for date 04/01/2012.", leaveBlockList.size()==1);
91  		lb = leaveBlockList.get(0);
92  		Assert.assertTrue("Hours of the leave block for date 04/01/2012 should be 0, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(BigDecimal.ZERO));
93  		Assert.assertTrue("Leave Code of the leave block for date 04/01/2012 should be " + LMConstants.STATUS_CHANGE_EARN_CODE + ", not " + lb.getEarnCode()
94  				, lb.getEarnCode().equals(LMConstants.STATUS_CHANGE_EARN_CODE));
95  		Assert.assertNull("accrual_category should be null for empty status change leave block", lb.getAccrualCategory()); 
96  		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
97  				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
98  		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
99  				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
100 		
101 		// there should be one holiday leave blocks of 4 hours on 04/10/2012, this is the accrualed leave block for the ssto
102 		intervalDate = new DateTime(2012, 4, 10, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
103 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
104 		Assert.assertTrue("There should be 1 leave block for date 04/10/2012.", leaveBlockList.size()==1);
105 		lb = leaveBlockList.get(0);
106 		Assert.assertNotNull("lm_sys_schd_timeoff_id should NOT be null for holiday accrual leave block", lb.getScheduleTimeOffId());
107 		Assert.assertTrue("lm_sys_schd_timeoff_id should be 5000, not " + lb.getScheduleTimeOffId(), lb.getScheduleTimeOffId().equals("5000"));
108 		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
109 				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
110 		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
111 				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
112 		Assert.assertTrue("Hours of the leave block for date 04/10/2012 should be 4, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(4)));
113 		
114 		// there should be one usage leave blocks of 4 hours on 04/12/2012
115 		intervalDate = new DateTime(2012, 4, 12, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
116 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
117 		Assert.assertTrue("There should be 1 leave block for date 04/12/2012.", leaveBlockList.size()==1);
118 		lb = leaveBlockList.get(0);
119 		Assert.assertNotNull("lm_sys_schd_timeoff_id should NOT be null for holiday accrual leave block", lb.getScheduleTimeOffId());
120 		Assert.assertTrue("lm_sys_schd_timeoff_id should be 5000, not " + lb.getScheduleTimeOffId(), lb.getScheduleTimeOffId().equals("5000"));
121 		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
122 				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
123 		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
124 				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
125 		Assert.assertTrue("Hours of the leave block for date 04/12/2012 should be -4, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(-4)));		
126 		Assert.assertNotNull("System Scheduled Timeoff usage leave block's Job number should not be null", lb.getJobNumber());
127 		Assert.assertTrue("System Scheduled Timeoff usage leave block should have Job number 4, not " + lb.getJobNumber(), lb.getJobNumber().equals(4L));
128 		Assert.assertNotNull("System Scheduled Timeoff usage leave block's work area should not be null", lb.getWorkArea());
129 		Assert.assertTrue("System Scheduled Timeoff usage leave block should have work area 1001, not " + lb.getWorkArea(), lb.getWorkArea().equals(1001L));
130 		Assert.assertNotNull("System Scheduled Timeoff usage leave block's task should not be null", lb.getTask());
131 		Assert.assertTrue("System Scheduled Timeoff usage leave block should have task 0, not " + lb.getTask(), lb.getTask().equals(0L));
132 		
133 		// there should be one accrualed leave blocks of 4 hours on 04/11/2012
134 		intervalDate = new DateTime(2012, 4, 11, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
135 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
136 		Assert.assertTrue("There should be 1 leave block for date 04/11/2012.", leaveBlockList.size()==1);
137 		lb = leaveBlockList.get(0);
138 		Assert.assertNotNull("lm_sys_schd_timeoff_id should NOT be null for holiday accrual leave block", lb.getScheduleTimeOffId());
139 		Assert.assertTrue("lm_sys_schd_timeoff_id should be 5005, not " + lb.getScheduleTimeOffId(), lb.getScheduleTimeOffId().equals("5005"));
140 		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
141 				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
142 		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
143 				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
144 		Assert.assertTrue("Hours of the leave block for date 04/11/2012 should be 4, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(4)));	
145 		
146 		// the disabled system scheduled time off on 04/20/2012 should not generate accruals
147 		intervalDate = new DateTime(2012, 4, 20, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
148 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
149 		Assert.assertTrue("There should be 0 leave block for date 04/20/2012.", leaveBlockList.isEmpty());
150 		
151 		// there should be 1 leave blocks on 04/30/2012, regular accrual of 8 hours
152 		intervalDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
153 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
154 		Assert.assertTrue("There should be 1 leave block for date 04/30/2012.", leaveBlockList.size()==1);
155 		lb = leaveBlockList.get(0);
156 		Assert.assertTrue("Hours of the regular accrual leave block for date 04/30/2012 should be 8, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(8)));
157 		Assert.assertNull("lm_sys_schd_timeoff_id should be null for regular accrual leave block", lb.getScheduleTimeOffId());
158 		Assert.assertTrue("Leave Block Type of leave block should be " + LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE + ", not " + lb.getLeaveBlockType()
159 				, lb.getLeaveBlockType().equals(LMConstants.LEAVE_BLOCK_TYPE.ACCRUAL_SERVICE));
160 		Assert.assertTrue("Requst status of leave block should be " + HrConstants.REQUEST_STATUS.APPROVED + ", not " + lb.getRequestStatus()
161 				, lb.getRequestStatus().equals(HrConstants.REQUEST_STATUS.APPROVED));
162 	}
163 	
164 	@Test
165 	/* testUser's leavePlan "testLP" has planning month of 12
166 	 * after calculateFutureAccrualUsingPlanningMonth, try to get leaveBlock for 18 months in the future
167 	 * should still get 12 or 13 leave blocks depends on the date the test is running. 
168 	 * The accrual service also goes back 1 year for accrual runs.
169 	 */
170 	public void testCalculateFutureAccrualUsingPlanningMonth() {
171 		String principal_id = "testUser";
172 		// the planning month of this leave plan is set to 12
173 		LocalDate currentDate = LocalDate.now();		
174 		LmServiceLocator.getLeaveAccrualService().calculateFutureAccrualUsingPlanningMonth(principal_id, LocalDate.now(), "admin");		
175 		int futureSize = 12;
176 		int allSize = 17;
177 		if(currentDate.getDayOfMonth() == currentDate.dayOfMonth().getMaximumValue()) {
178 			futureSize ++;
179 			allSize ++;
180 		}
181 		
182 		LocalDate startDate = currentDate.minusMonths(5);
183 		LocalDate endDate = currentDate.plusMonths(18);
184 		
185 		// lookup future leave blocks up to 18 months in the future
186 		List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, currentDate, endDate);
187 		
188 		Assert.assertFalse("No leave blocks created by calculateF?utureAccrualUsingPlanningMonth for princiapl id " + principal_id, leaveBlockList.isEmpty());
189 		Assert.assertTrue("There should be " + futureSize + " leave blocks for employee 'testUser', not " + leaveBlockList.size(), leaveBlockList.size()== futureSize);
190 		
191 		// lookup leave blocks including past and future
192 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, startDate, endDate);
193 		Assert.assertTrue("There should be  " + allSize + " leave blocks for employee 'testUser', not " + leaveBlockList.size(), leaveBlockList.size()== allSize);
194 	}
195 	
196 	@Test
197 	/*
198 	  *testUser2 has two accrual category rules, rule 1 goes from 0 month to 5 with accrual rate of 16
199 	  *rule 2 goes from 5 to 900 with accrual rate of 24
200 	  *run accrual for testUser2 for 15 months
201 	 */
202 	public void testRunAccrualForRuleChanges() {
203 		 String principal_id = "testUser2";
204 		 LocalDate endDate = START_DATE.toLocalDate().plusMonths(15);
205 		 
206 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
207 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
208 		
209 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
210 		 
211 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
212 		 Assert.assertTrue("There should be 14 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 14);
213 		 
214 		 // July of 2012 is the 5th month of this user's employment, the accrual rate should be 16
215 		 DateTime intervalDate = new DateTime(2012, 7, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
216 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
217 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date 07/31/2012.", leaveBlockList.size()==1);
218 		 LeaveBlock lb = leaveBlockList.get(0);
219 		 Assert.assertTrue("Hours of the leave block on date 07/31/2012 for employee " + principal_id + " should be 16, not " + lb.getLeaveAmount().toString()
220 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
221 		 
222 		 // August of 2012 is the 6th month of this user's employment, the accrual rate should be 24 from now on
223 		 intervalDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
224 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
225 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date 08/31/2012.", leaveBlockList.size()==1);
226 		 lb = leaveBlockList.get(0);
227 		 Assert.assertTrue("Hours of the leave block for date 08/31/2012 for employee " + principal_id + " should be 24, not " + lb.getLeaveAmount().toString()
228 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
229 		 
230 	}
231 	@Test
232 	/* testUser3's leavePlan has 2 accrual categories with different accrual intervals
233 	 * testAC3 has accrual interval semi-monthly
234 	 * testAC4 has accrual interval monthly
235 	 */
236 	public void testRunAccrualWithDifferentAccrualIntervals() {
237 		 String principal_id = "testUser3";
238 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), END_DATE.toLocalDate());
239 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
240 		 
241 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, END_DATE, false, "admin");
242 		 leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), END_DATE.toLocalDate());
243 		 Assert.assertTrue("There should be 6 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 6);
244 		 
245 		 DateTime semiMonthlyDate = new DateTime(2012, 3, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
246 		 DateTime monthlyDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
247 		 this.verifyLeaveBlocksWithDifferentAccrualIntervals(semiMonthlyDate, monthlyDate);
248 
249 		 semiMonthlyDate = new DateTime(2012, 4, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
250 		 monthlyDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
251 		 this.verifyLeaveBlocksWithDifferentAccrualIntervals(semiMonthlyDate, monthlyDate);
252 		 
253 	}
254 	public void verifyLeaveBlocksWithDifferentAccrualIntervals(DateTime semiMonthlyDate, DateTime monthlyDate) {
255 		 String principal_id = "testUser3";
256 		 List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, semiMonthlyDate.toLocalDate());
257 		 Assert.assertTrue("There should be 1 leave block for date " + semiMonthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
258 		 LeaveBlock lb = leaveBlockList.get(0);
259 		 Assert.assertTrue("Hours of the leave block on date " + semiMonthlyDate.toString() + " should be 8, not " + lb.getLeaveAmount().toString(), lb.getLeaveAmount().equals(new BigDecimal(8)));
260 		 Assert.assertTrue("Leave code of the leave block on date " + semiMonthlyDate.toString() + " should be EC1, not " + lb.getEarnCode(), lb.getEarnCode().equals("EC1"));
261 		 Assert.assertTrue("accrual_category of the leave block on date " + semiMonthlyDate.toString() + " should be testAC3, not " + lb.getAccrualCategory(), lb.getAccrualCategory().equals("testAC3"));
262 		
263 		
264 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
265 		 Assert.assertTrue("There should be 2 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==2);
266 		 for(LeaveBlock aLeaveBlock : leaveBlockList) {
267 			 if(aLeaveBlock.getAccrualCategory().equals("testAC3")) {
268 				 Assert.assertTrue("Leave code of the leave block with accrualCategory testAC3 on date " + monthlyDate.toString() + " should be EC1, not " + aLeaveBlock.getEarnCode()
269 						 , aLeaveBlock.getEarnCode().equals("EC1")); 
270 				 Assert.assertTrue("Hours of the leave block with accrualCategory testAC4 on date " + monthlyDate.toString() + " should be 8, not " + aLeaveBlock.getLeaveAmount().toString()
271 						 , aLeaveBlock.getLeaveAmount().equals(new BigDecimal(8)));
272 			 } else if(aLeaveBlock.getAccrualCategory().equals("testAC4")) {
273 				 Assert.assertTrue("Leave code of the leave block with accrualCategory testAC4 on date " + monthlyDate.toString() + " should be EC2, not " + aLeaveBlock.getEarnCode()
274 						 , aLeaveBlock.getEarnCode().equals("EC2")); 
275 				 Assert.assertTrue("Hours of the leave block with accrualCategory testAC4 on date " + monthlyDate.toString() + " should be 24, not " + aLeaveBlock.getLeaveAmount().toString()
276 						 , aLeaveBlock.getLeaveAmount().equals(new BigDecimal(24)));
277 			 } else {
278 				 Assert.fail("Leave block on date " + monthlyDate.toString() + " should not have accrual_category " + aLeaveBlock.getAccrualCategory());
279 			 }
280 		 }
281 	}
282 	
283 	@Test
284 	/* testUser4 has PrincipalHRAttributes that's associated with 2 accrual categories, one is testAC5, the other is testAC6
285 	 * testAC5 has minimum accrual of 0.5, proration = true
286 	 * testAC6 has minimum accrual of 0
287 	 * testUser4 has records of principalHRAttributes, the employment is from 03/18/2012 to 08/08/2012
288 	 * There should not be accrual for testAC5 in March and August of 2012 since minimum percentage is not reached
289 	 */
290 	public void testMinNotReachedProrationTrueFirstLastPeriod() {
291 		 String principal_id = "testUser4";
292 		 DateTime end = new DateTime(2012, 9, 25, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
293 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
294 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
295 		 
296 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, end, false, "admin");
297 		 leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
298 		 Assert.assertTrue("There should be 10 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 10);
299 		 
300 		 DateTime monthlyDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
301 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
302 		 Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
303 		 LeaveBlock lb = leaveBlockList.get(0);
304 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have accrual_category testAC6, not " + lb.getAccrualCategory()
305 				 , lb.getAccrualCategory().equals("testAC6"));
306 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 7 hours, not " + lb.getLeaveAmount()
307 				 , lb.getLeaveAmount().equals(new BigDecimal(7)));
308 		
309 		 monthlyDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
310 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
311 		 Assert.assertTrue("There should be 2 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==2);
312 		 
313 // should the accrual of the last days show up on the end day or the interval day of the last pay period?????
314 		 monthlyDate = new DateTime(2012, 8, 8, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
315 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
316 		 Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
317 		 lb = leaveBlockList.get(0);
318 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have accrual_category testAC6, not " + lb.getAccrualCategory()
319 				 , lb.getAccrualCategory().equals("testAC6"));
320 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 4 hours, not " + lb.getLeaveAmount()
321 				 , lb.getLeaveAmount().equals(new BigDecimal(4)));
322 		 
323 		 monthlyDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
324 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
325 		 Assert.assertTrue("There should NOT be any leave blocks for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==0);
326 	}
327 	@Test
328 	/* testUser9 has PrincipalHRAttributes that's associated with accrual categories "testAC12"
329 	 * testAC12 has minimum accrual of 0.5, proration = true, fte of the ac rule is 8
330 	 * testUser9 has records of principalHRAttributes, the employment is from 03/10/2012 to 08/20/2012
331 	 * There should be partial fte accrued for testAC12 in March and August of 2012 since minimum percentage is reached
332 	 */
333 	public void testMinReachedProrationTrueFirstLastPeriod() {
334 		String principal_id = "testUser9";
335 		DateTime end = new DateTime(2012, 9, 25, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
336 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
337 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
338 		 
339 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, end, false, "admin");
340 		 leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
341 		 Assert.assertTrue("There should be 6 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 6);
342 		 
343 		 DateTime monthlyDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
344 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
345 		 Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
346 		 LeaveBlock lb = leaveBlockList.get(0);
347 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 5 hours, not " + lb.getLeaveAmount()
348 				 , lb.getLeaveAmount().equals(new BigDecimal(5)));
349 		
350 		 monthlyDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
351 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
352 		 Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
353 		 lb = leaveBlockList.get(0);
354 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 8 hours, not " + lb.getLeaveAmount()
355 				 , lb.getLeaveAmount().equals(new BigDecimal(8)));
356 		 
357 		 monthlyDate = new DateTime(2012, 8, 20, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
358 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
359 		 Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
360 		 lb = leaveBlockList.get(0);
361 		 Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 5 hours, not " + lb.getLeaveAmount()
362 				 , lb.getLeaveAmount().equals(new BigDecimal(5)));
363 		 
364 		 monthlyDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
365 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
366 		 Assert.assertTrue("There should NOT be any leave blocks for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==0);
367 	}
368 	@Test
369 	/* testUser10 has PrincipalHRAttributes that's associated with accrual categories "testAC13"
370 	 * testAC13 has minimum accrual of 0.5, proration = false
371 	 * testUser10 has records of principalHRAttributes, the employment is from 03/10/2012 to 08/20/2012
372 	 * There should be whole fte accrued for testAC13 in March and August of 2012 since minimum percentage is reached
373 	 */
374 	public void testMinReachedProrationFalseFirstLastPeriod() {
375 		String principal_id = "testUser10";
376 		DateTime end = new DateTime(2012, 9, 25, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
377 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
378 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
379 			 
380 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, end, false, "admin");
381 		leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
382 		Assert.assertTrue("There should be 6 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 6);
383 			 
384 		DateTime monthlyDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
385 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
386 		Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
387 		LeaveBlock lb = leaveBlockList.get(0);
388 		Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 8 hours, not " + lb.getLeaveAmount()
389 			 , lb.getLeaveAmount().equals(new BigDecimal(8)));
390 		
391 		monthlyDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
392 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
393 		Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
394 		lb = leaveBlockList.get(0);
395 		Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 8 hours, not " + lb.getLeaveAmount()
396 			 , lb.getLeaveAmount().equals(new BigDecimal(8)));
397 		
398 		monthlyDate = new DateTime(2012, 8, 20, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
399 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
400 		Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
401 		lb = leaveBlockList.get(0);
402 		Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 8 hours, not " + lb.getLeaveAmount()
403 				, lb.getLeaveAmount().equals(new BigDecimal(8)));
404 			 
405 		monthlyDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
406 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
407 		Assert.assertTrue("There should NOT be any leave blocks for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==0);		
408 	}
409 	
410 	@Test
411 	/* testUser11 has PrincipalHRAttributes that's associated with accrual categories "testAC14"
412 	 * testAC14 has minimum accrual of 0.5, proration = false
413 	 * testUser11 has records of principalHRAttributes, the employment is from 03/20/2012 to 08/10/2012
414 	 * There should NOT be accrual leave blocks for testAC14 in March and August of 2012 since minimum percentage is NOT reached
415 	 */
416 	public void testMinNotReachedProrationFalseFirstLastPeriod() {
417 		String principal_id = "testUser11";
418 		DateTime end = new DateTime(2012, 9, 25, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone());
419 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
420 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
421 			 
422 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, end, false, "admin");
423 		leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), end.toLocalDate());
424 		Assert.assertTrue("There should be 4 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 4);
425 			 
426 		DateTime monthlyDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
427 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
428 		Assert.assertTrue("There should be 0 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.isEmpty());
429 		
430 		monthlyDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
431 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
432 		Assert.assertTrue("There should be 1 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
433 		LeaveBlock lb = leaveBlockList.get(0);
434 		Assert.assertTrue("Leave block on date " + monthlyDate.toString() + " should have 8 hours, not " + lb.getLeaveAmount()
435 			 , lb.getLeaveAmount().equals(new BigDecimal(8)));
436 		
437 		monthlyDate = new DateTime(2012, 8, 20, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
438 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
439 		Assert.assertTrue("There should be 0 leave block for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.isEmpty());
440 					 
441 		monthlyDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
442 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, monthlyDate.toLocalDate());
443 		Assert.assertTrue("There should NOT be any leave blocks for date " + monthlyDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==0);		
444 	}
445 	@Test
446 	/* testUser5's service date is 2012-03-10
447 	 * testUser5 has two accrual category rules, rule 1 goes from 0 month to 12 with accrual rate of 16
448 	 * rule 2 goes from 12 to 900 with accrual rate of 24
449 	 * accrual category associated with the two rules has Proration=false, and minimum percentage of 0.5
450 	 * run accrual for testUser5 for 18 months
451 	 */
452 	public void testMinReachedProrationFalseAndRuleChange() {
453 		 String principal_id = "testUser5";
454 		 LocalDate endDate = START_DATE.toLocalDate().plusMonths(18);
455 		 
456 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
457 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
458 		
459 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
460 		 
461 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
462 		 Assert.assertTrue("There should be 17 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 17);
463 		 
464 		 // 03/31/2012 is the first accrual interval date, service starts on 2012-03-10, so minimum percentage is reached for that month
465 		 // since proration is false, the whole accrual rate is created for the first pay period
466 		 DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
467 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
468 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
469 		 LeaveBlock lb = leaveBlockList.get(0);
470 		 Assert.assertTrue("Leave block on date " + intervalDate.toString() + " should have 16 hours, not " + lb.getLeaveAmount()
471 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
472 		 
473 		 // 02/28/2013 is the 12th month of this user's employment, the accrual rate should be 16
474 		 intervalDate = new DateTime(2013, 2, 28, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
475 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
476 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date 02/28/2013.", leaveBlockList.size()==1);
477 		 lb = leaveBlockList.get(0);
478 		 Assert.assertTrue("Hours of the leave block on date " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
479 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
480 		 
481 		 // 03/31/2013 is the 13th month of this user's employment, since the minimum percentage of days is meet for
482 		 // that month (03/10 - 03/31) and proration = false, the accrual rate should be 24 from now on
483 		 intervalDate = new DateTime(2013, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
484 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
485 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
486 		 lb = leaveBlockList.get(0);
487 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
488 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
489 	}
490 	@Test
491 	/* testUser12's service date is 2012-03-20
492 	 * testUser12 has two accrual category rules, rule 1 goes from 6 month to 12 with accrual rate of 16
493 	 * rule 2 goes from 6 to 900 with accrual rate of 24
494 	 * accrual category "testAC15" is associated with the two rules. testAC15 has Proration=false, and minimum percentage of 0.5
495 	 * run accrual for testUser12 for 12 months
496 	 * for 2012-09-30, the accrual should still be 16 since the minimum is NOT reached for the rule 2
497 	 */
498 	public void testMinNotReachedProrationFalseAndRuleChange() {
499 		String principal_id = "testUser12";
500 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(18);
501 		 
502 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
503 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
504 
505         LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
506 		 
507 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
508 		 Assert.assertTrue("There should be 17 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 17);
509 		 // 08/31/2013 
510 		 DateTime intervalDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
511 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
512 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
513 		 LeaveBlock lb = leaveBlockList.get(0);
514 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
515 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));		
516 		 
517 		 // 09/30/2012 is the 6th month of this user's employment, since minimum percentage is not reached, the accrual rate should be 16
518 		 intervalDate = new DateTime(2012, 9, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
519 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
520 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
521 		 lb = leaveBlockList.get(0);
522 		 Assert.assertTrue("Leave block on date " + intervalDate.toString() + " should have 16 hours, not " + lb.getLeaveAmount()
523 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
524 		 
525 		 // 10/31/2013 
526 		 intervalDate = new DateTime(2012, 10, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
527 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
528 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
529 		 lb = leaveBlockList.get(0);
530 		 Assert.assertTrue("Hours of the leave block on date " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
531 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
532 	}
533 	@Test
534 	/* testUser13's service date is 2012-03-10
535 	 * testUser13 has two accrual category rules, rule 1 goes from 0 month to 6 with accrual rate of 16
536 	 * rule 2 goes from 6 to 900 with accrual rate of 24
537 	 * accrual category "testAC16" is associated with the two rules. testAC16 has Proration=true, and minimum percentage of 0.5
538 	 * run accrual for testUser13 for 12 months
539 	 * for 2012-09-30, the accrual should be based on actual work days for those two rules, ie 22 because the minimum is reached for rule 2
540 	 */
541 	public void testMinReachedProrationTrueAndRuleChange() {
542 		String principal_id = "testUser13";
543 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(18);
544 		 
545 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
546 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
547 		
548 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
549 		 
550 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
551 		Assert.assertTrue("There should be 17 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 17);
552 		// 08/31/2013 
553 		DateTime intervalDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
554 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
555 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
556 		LeaveBlock lb = leaveBlockList.get(0);
557 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
558 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));		
559 		 
560 		// 09/30/2012 is the 6th month of this user's employment, since minimum percentage is reached, the accrual rate is 16 for 6 work days
561 		// and 24 hrs for 14 work days, so the final accrual hrs is 22
562 		intervalDate = new DateTime(2012, 9, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
563 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
564 		Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
565 		lb = leaveBlockList.get(0);
566 		Assert.assertTrue("Leave block on date " + intervalDate.toString() + " should have 22 hours, not " + lb.getLeaveAmount()
567 			 , lb.getLeaveAmount().equals(new BigDecimal(22)));
568 		 
569 		// 10/31/2013 
570 		intervalDate = new DateTime(2012, 10, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
571 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
572 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
573 		lb = leaveBlockList.get(0);
574 		Assert.assertTrue("Hours of the leave block on date " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
575 			 , lb.getLeaveAmount().equals(new BigDecimal(24)));		
576 	}
577 	@Test
578 	/* testUser14's service date is 2012-03-20
579 	 * testUser14 has two accrual category rules, rule 1 goes from 0 month to 6 with accrual rate of 16
580 	 * rule 2 goes from 6 to 900 with accrual rate of 24
581 	 * accrual category "testAC17" is associated with the two rules. testAC17 has Proration=true, and minimum percentage of 0.5
582 	 * run accrual for testUser14 for 12 months
583 	 * for 2012-09-30, the accrual should be 16 since the minimum is NOT reached for the rule 2
584 	 */
585 	public void testMinNotReachedProrationTrueAndRuleChange() {
586 		String principal_id = "testUser14";
587 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(18);
588 		 
589 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
590 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
591 		
592 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
593 		// only 16 leave blocks since the first interval 03/31/2012 does not have accruals due to minimum not reached
594 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
595 		Assert.assertTrue("There should be 16 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 16);
596 		
597 		// 03/31/2013 
598 		DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
599 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
600 		Assert.assertTrue("There should be 0 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.isEmpty());
601 			
602 		// 08/31/2013 
603 		intervalDate = new DateTime(2012, 8, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
604 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
605 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
606 		LeaveBlock lb = leaveBlockList.get(0);
607 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
608 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));		
609 		 
610 		// 09/30/2012 is the 6th month of this user's employment, since minimum percentage is NOT reached, the accrual rate should be 16
611 		intervalDate = new DateTime(2012, 9, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
612 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
613 		Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
614 		lb = leaveBlockList.get(0);
615 		Assert.assertTrue("Leave block on date " + intervalDate.toString() + " should have 16 hours, not " + lb.getLeaveAmount()
616 			 , lb.getLeaveAmount().equals(new BigDecimal(16)));
617 		 
618 		// 10/31/2013 
619 		intervalDate = new DateTime(2012, 10, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
620 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
621 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
622 		lb = leaveBlockList.get(0);
623 		Assert.assertTrue("Hours of the leave block on date " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
624 			 , lb.getLeaveAmount().equals(new BigDecimal(24)));			
625 	}
626 	@Test
627 	/* testUser6's service date is 2012-03-25
628 	 * testUser6 has two accrual category rules, rule 1 goes from 0 to 6 month with accrual rate of 16
629 	 * rule 2 goes from 6 month to 900 with accrual rate of 24
630 	 * accrual category testAC8 associated with the two rules has Proration=false, and minimum percentage of 0.5 and earn interval=semi_monthly
631 	 * run accrual for testUser5 for 10 months
632 	 */
633 	public void testMinNOTReachedProrationFalseAndRuleChange() {
634 		 String principal_id = "testUser6";
635 		 LocalDate endDate = START_DATE.toLocalDate().plusMonths(10);
636 		 
637 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
638 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
639 		
640 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
641 		 
642 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
643 		 Assert.assertTrue("There should be 17 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 17);
644 		 
645 		 // 03/31/2012 is the first accrual interval date, since minimum percentage is not reached (03/25-03/31) and proration=false
646 		 // there should not be leave blocks
647 		 DateTime intervalDate =new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
648 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
649 		 Assert.assertTrue("There should be 0 leave block for date " + intervalDate.toString(), leaveBlockList.isEmpty());
650 		 
651 		 // 04/15/2012 should have the first leave block for testUser6 and the accrual hours should be the full 16 
652 		 intervalDate = new DateTime(2012, 4, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
653 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
654 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString() + " for emplyee " + principal_id, leaveBlockList.size()==1);
655 		 LeaveBlock lb = leaveBlockList.get(0);
656 		 Assert.assertTrue("Leave block on date " + intervalDate.toString() + " should have 16 hours, not " + lb.getLeaveAmount()
657 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
658 		 
659 		 // accrual rate for 09/15/2012 should still be 16
660 		 intervalDate = new DateTime(2012, 9, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
661 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
662 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
663 		 lb = leaveBlockList.get(0);
664 		 Assert.assertTrue("Hours of the leave block on date " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
665 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
666 		 
667 		 // 09/30/2013 is the first pay interval of rule 2, since the minimum percentage is not reached (09/25-09/30)
668 		 // the accrual rate should still be 16
669 		 intervalDate = new DateTime(2012, 9, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
670 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
671 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
672 		 lb = leaveBlockList.get(0);
673 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
674 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
675 		 
676 		 // 10/15/2013, should use new rate of 24
677 		 intervalDate = new DateTime(2012, 10, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
678 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
679 		 Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
680 		 lb = leaveBlockList.get(0);
681 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
682 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
683 	}
684 	
685 	@Test
686 	/* testUser7's service date is 2012-03-10
687 	 * testUser7 has two leave blocks scheduled on 04/26/2012 for 2 hours and 05/08/2012 for 5 hours, they both are NOT eligible for accrual
688 	 * testUser7 has one leave block scheduled on 05/22/1012 of 8 hours, it's eligible for accrual
689 	 * testUser7 has one leave block scheduled on 06/12/1012 of 15 hours, it's NOT eligible for accrual
690 	 * testUser7 has one accrual category rule of 32 hours of accrual rate, two jobs are eligible for leave with total of 40 standard hours
691 	 * run accrual for testUser7 for 5 months
692 	 */
693 	public void testNotEligibleForAccrualAdjustment() {
694 		String principal_id = "testUser7";
695 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(5);
696 		 
697 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
698 		 Assert.assertTrue("There should be 4 leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.size() == 4);
699 		
700 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
701 		 
702 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
703 		 Assert.assertTrue("There should be 10 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 10);
704 		 
705 		 // 03/31/2012, 
706 		 DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
707 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
708 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 1);
709 		 LeaveBlock lb = leaveBlockList.get(0);
710 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 22, not " + lb.getLeaveAmount().toString()
711 				 , lb.getLeaveAmount().equals(new BigDecimal(22)));
712 		 
713 		 // 04/30/2012, 
714 		 intervalDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
715 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
716 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 1);
717 		 lb = leaveBlockList.get(0);
718 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 32, not " + lb.getLeaveAmount().toString()
719 				 , lb.getLeaveAmount().equals(new BigDecimal(32)));
720 		 
721 		 //05/31/2012
722 		 intervalDate = new DateTime(2012, 5, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
723 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
724 		 Assert.assertTrue("There should be 2 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 2);
725 		 for(LeaveBlock aLeaveBlock : leaveBlockList) {
726 			 if(aLeaveBlock.getLeaveAmount().equals(new BigDecimal(-1))) {
727 				 Assert.assertTrue("Accrual category of the leave block for date  " + intervalDate.toString() + " should be 'testAC9' , not " + aLeaveBlock.getAccrualCategory()
728 						 , aLeaveBlock.getAccrualCategory().equals("testAC9")); 
729 			 } else if(aLeaveBlock.getLeaveAmount().equals(new BigDecimal(32))) {
730 				 Assert.assertTrue("Accrual category of the leave block for date  " + intervalDate.toString() + " should be 'testAC9' , not " + aLeaveBlock.getAccrualCategory()
731 						 , aLeaveBlock.getAccrualCategory().equals("testAC9")); 
732 			 } else {
733 				 Assert.fail("Hours of the leave block for date  " + intervalDate.toString() + " should be either 32 or -1, not " + aLeaveBlock.getLeaveAmount().toString());
734 			 }
735 		 }
736 		 
737 		 //06/30/2012
738 		 // we added top limit to accrual adjustment, so the 06/12/1012 of 15 hours is counted as leave of 8 hours
739 		 intervalDate = new DateTime(2012, 6, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
740 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
741 		 Assert.assertTrue("There should be 2 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 2);
742 		 for(LeaveBlock aLeaveBlock : leaveBlockList) {
743 			 if(aLeaveBlock.getLeaveAmount().equals(new BigDecimal(-2))) {
744 				 Assert.assertTrue("Accrual category of the leave block for date  " + intervalDate.toString() + " should be 'testAC9' , not " + aLeaveBlock.getAccrualCategory()
745 						 , aLeaveBlock.getAccrualCategory().equals("testAC9")); 
746 			 } else if(aLeaveBlock.getLeaveAmount().equals(new BigDecimal(32))) {
747 				 Assert.assertTrue("Accrual category of the leave block for date  " + intervalDate.toString() + " should be 'testAC9' , not " + aLeaveBlock.getAccrualCategory()
748 						 , aLeaveBlock.getAccrualCategory().equals("testAC9")); 
749 			 } else {
750 				 Assert.fail("Hours of the leave block for date  " + intervalDate.toString() + " should be either 32 or -2, not " + aLeaveBlock.getLeaveAmount().toString());
751 			 }
752 		 }
753 	}
754 	
755 	@Test
756 	/* testUser8's service date is 2012-03-10
757 	 * testUser8 has one accrual category, two entries of the same accrual category. 
758 	 * The first entry has effectiveDate = 2012-03-01. The rule associated with it has 16 as the accrual rate
759 	 * the second entry has effectiveDate = 2012-5-01. The rule associated with it has 32 as the accrual rate
760 	 * run accrual for testUser8 for 6 months
761 	 */
762 	public void testAccrualCategoryChanges() {
763 		String principal_id = "testUser8";
764 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(6);
765 		 
766 		 List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
767 		 Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
768 		
769 		 LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
770 		 
771 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
772 		 Assert.assertTrue("There should be 5 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 5);		 
773 		 
774 		 // 03/31/2012, 
775 		 DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
776 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
777 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 1);
778 		 LeaveBlock lb = leaveBlockList.get(0);
779 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 11, not " + lb.getLeaveAmount().toString()
780 				 , lb.getLeaveAmount().equals(new BigDecimal(11)));
781 		 
782 		 // 04/30/2012, 
783 		 intervalDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
784 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
785 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 1);
786 		 lb = leaveBlockList.get(0);
787 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 16, not " + lb.getLeaveAmount().toString()
788 				 , lb.getLeaveAmount().equals(new BigDecimal(16)));
789 		 
790 		 //05/31/2012
791 		 intervalDate = new DateTime(2012, 5, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
792 		 leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
793 		 Assert.assertTrue("There should be 1 leave block for date " + intervalDate.toString(), leaveBlockList.size() == 1);
794 		 lb = leaveBlockList.get(0);
795 		 Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 32, not " + lb.getLeaveAmount().toString()
796 				 , lb.getLeaveAmount().equals(new BigDecimal(32)));
797 		 
798 	}
799 	
800 	@Test
801 	/*	testUser15's service Date is 2012-03-10
802 	 * 	testUser15 has one accrual category, the effectiveDate of the AC is 2012-03-01
803 	 *  The rule associated with the AC has 24 as the accrual rate
804 	 *  There's Leave Calendar document for calendar entry 2012-04-01 -- 2012-05-01
805 	 *  run accrual for testUser15 for 6 months
806 	 */
807 	public void testLeaveBlocksWithLeaveCalendarDocId() {
808 		String principal_id = "testUser15";
809 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(6);
810 		 
811 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
812 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
813 		
814 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
815 		
816 		// 04/30/2012 
817 		DateTime intervalDate = new DateTime(2012, 4, 30, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
818 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
819 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
820 		LeaveBlock lb = leaveBlockList.get(0);
821 		Assert.assertTrue("DocumentId of the leave block for date  " + intervalDate.toString() + " should be 5000, not " + lb.getDocumentId()
822 				 , lb.getDocumentId().equals("5000"));		
823 		 
824 	}
825 	
826 	@Test
827 	/*	testUser16's service Date is 2012-03-26 which is a Monday
828 	 * 	testUser16 has one accrual category "testAC19" with effectiveDate of 2012-03-01
829 	 *  testAC19 has proration = false, minimum percentage = 0
830 	 *  testAC19 has "pay calendar" as the earn interval, so the accrual interval will be based on the pay calendar entries of testUser16
831 	 *  testUser16 has "BI-WE" as the pay calendar, it's bi-weekly with start day as Sunday
832 	 *  The rule associated with the AC has 24 as the accrual rate
833 	 *  run accrual for testUser16 for 6 months
834 	 */
835 	public void testPayCalAsEarnInterval() {
836 		String principal_id = "testUser16";
837 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(6);
838 		 
839 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
840 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
841 		
842 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
843 		
844 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
845 		Assert.assertTrue("There should be 11 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 11);	
846 		
847 		// 03/31/2012, testAC19 has proration= false, minimum percentage = 0, so whole FTE of 24 hours is given to the first interval
848 		DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
849 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
850 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
851 		LeaveBlock lb = leaveBlockList.get(0);		
852 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
853 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
854 		
855 		// 04/28/2012
856 		intervalDate = new DateTime(2012, 4, 28, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
857 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
858 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
859 		lb = leaveBlockList.get(0);		
860 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
861 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
862 		// 05/12/2012
863 		intervalDate = new DateTime(2012, 5, 12, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
864 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
865 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
866 		// 08/04/2012
867 		intervalDate = new DateTime(2012, 8, 4, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
868 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
869 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
870 		// 08/18/2012
871 		intervalDate = new DateTime(2012, 8, 18, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
872 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
873 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
874 	}
875 	
876 	@Test
877 	/*	testUser17's service Date is 2012-03-26 which is a Monday
878 	 * 	testUser17 has one accrual category "testAC20" with effectiveDate of 2012-03-01
879 	 *  testAC20 has proration = true, minimum percentage = 0.5
880 	 *  testAC20 has "pay calendar" as the earn interval, so the accrual interval will be based on the pay calendar entries of testUser17
881 	 *  testUser17 has "BI-WE" as the pay calendar, it's bi-weekly with start day as Sunday
882 	 *  The rule associated with the AC has 24 as the accrual rate
883 	 *  run accrual for testUser17 for 6 months
884 	 */
885 	public void testPayCalAsEarnIntervalProrationFalseMinReached() {
886 		String principal_id = "testUser17";
887 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(6);
888 		 
889 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
890 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
891 		
892 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
893 		
894 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
895 		Assert.assertTrue("There should be 11 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 11);	
896 		
897 		// 03/31/2012, testAC20 has proration= true, minimum percentage = 0.5, so only 12 hours is given to the first interval
898 		DateTime intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
899 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
900 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
901 		LeaveBlock lb = leaveBlockList.get(0);		
902 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 12, not " + lb.getLeaveAmount().toString()
903 				 , lb.getLeaveAmount().equals(new BigDecimal(12)));
904 		
905 		// 04/28/2012
906 		intervalDate = new DateTime(2012, 4, 28, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
907 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
908 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
909 		lb = leaveBlockList.get(0);		
910 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
911 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
912 		// 05/12/2012
913 		intervalDate = new DateTime(2012, 5, 12, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
914 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
915 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
916 		// 08/04/2012
917 		intervalDate = new DateTime(2012, 8, 4, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
918 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
919 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
920 		// 08/18/2012
921 		intervalDate = new DateTime(2012, 8, 18, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
922 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
923 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
924 	}
925 
926 	@Test
927 	/*	testUser18's service Date is 2012-03-20 which is a Tuesday
928 	 * 	testUser18 has one accrual category "testAC21" with effectiveDate of 2012-03-01
929 	 *  testAC21 has proration = false, minimum percentage = 0
930 	 *  testAC21 has "weekly" as the earn interval
931 	 *  The rule associated with the AC has 24 as the accrual rate
932 	 *  run accrual for testUser18 for 6 months
933 	 */
934 	public void testWeeklyAsEarnInterval() {
935 		String principal_id = "testUser18";
936 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(6);
937 		 
938 		List<LeaveBlock> leaveBlockList = (List<LeaveBlock>) LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
939 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
940 		
941 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
942 		
943 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
944 		Assert.assertTrue("There should be 22 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 22);	
945 		
946 		// 03/24/2012
947 		DateTime intervalDate = new DateTime(2012, 3, 24, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
948 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
949 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
950 		LeaveBlock lb = leaveBlockList.get(0);		
951 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
952 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));		
953 		// 03/31/2012
954 		intervalDate = new DateTime(2012, 3, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
955 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
956 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
957 		lb = leaveBlockList.get(0);		
958 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
959 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
960 		// 08/11/2012
961 		intervalDate = new DateTime(2012, 8, 11, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
962 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
963 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
964 		lb = leaveBlockList.get(0);		
965 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
966 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
967 		// 08/18/2012
968 		intervalDate = new DateTime(2012, 8, 18, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
969 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
970 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
971 		lb = leaveBlockList.get(0);		
972 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 24, not " + lb.getLeaveAmount().toString()
973 				 , lb.getLeaveAmount().equals(new BigDecimal(24)));
974 	}
975 	@Test
976 	/*	testUser19's service Date is 2012-03-20
977 	 * 	testUser19 has one accrual category "testAC22" with effectiveDate of 2012-03-01
978 	 *  testAC22 has "yearly" as the earn interval
979 	 *  The rule associated with the AC has 100 hours as the accrual rate
980 	 *  run accrual for testUser19 for 18 months
981 	 */
982 	public void testYearlyAsEarnInterval() {
983 		String principal_id = "testUser19";
984 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(18);
985 		 
986 		List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
987 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
988 		
989 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
990 		
991 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
992 		Assert.assertTrue("There should be 1 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 1);
993 		
994 		// 12/31/2013
995 		DateTime intervalDate = new DateTime(2012, 12, 31, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
996 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
997 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
998 		LeaveBlock lb = leaveBlockList.get(0);		
999 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 100, not " + lb.getLeaveAmount().toString()
1000 				 , lb.getLeaveAmount().equals(new BigDecimal(100)));		
1001 	}
1002 	@Test
1003 	/*	testUser20's service Date is 2012-03-20
1004 	 * 	testUser20 has one accrual category "testAC23" with effectiveDate of 2012-03-01
1005 	 *  testAC23 has "daily" as the earn interval
1006 	 *  The rule associated with the AC has 2 as the accrual rate
1007 	 *  run accrual for testUser20 for 3 months
1008 	 */
1009 	public void testDailyAsEarnInterval() {
1010 		String principal_id = "testUser20";
1011 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(3);
1012 		 
1013 		List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
1014 		Assert.assertTrue("There are leave blocks before runAccrual for princiapl id " + principal_id, leaveBlockList.isEmpty());
1015 		
1016 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
1017 		
1018 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
1019 		Assert.assertTrue("There should be 44 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 44);
1020 		
1021 		// 03/20/2012
1022 		DateTime intervalDate = new DateTime(2012, 3, 20, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
1023 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
1024 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
1025 		LeaveBlock lb = leaveBlockList.get(0);		
1026 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 2, not " + lb.getLeaveAmount().toString()
1027 				 , lb.getLeaveAmount().equals(new BigDecimal(2)));	
1028 		
1029 		// 05/28/2012
1030 		intervalDate = new DateTime(2012, 5, 18, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
1031 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
1032 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
1033 		lb = leaveBlockList.get(0);		
1034 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 2, not " + lb.getLeaveAmount().toString()
1035 				 , lb.getLeaveAmount().equals(new BigDecimal(2)));
1036 	}
1037 
1038 	@Test
1039 	/*	testUser21's service Date is 2012-03-20
1040 	 * 	testUser21 has one accrual category "testAC24" with effectiveDate of 2012-03-01
1041 	 *  testAC24 has "monthly" as the earn interval
1042 	 *  There's a accrual ssto leave block on 04/10/2012 for testUser21,no usage lb, so that's a banked ssto accrual
1043 	 *  run accrual for testUser21 for 3 months, the accrual service should not delete the existing leaveblock
1044 	 *  and should not generate new ssto accrual/usage lbs on 04/10/2012
1045 	 *  There's a balance transferred leave block on 04/15/2012, sstoId is not empty, 
1046 	 *  accrual service should not generate ssto accrual leave blocks on 04/15/2012 
1047 	 */
1048 	public void testSSTOBankedOrTransferred() {
1049 		String principal_id = "testUser21";
1050 		LocalDate endDate = START_DATE.toLocalDate().plusMonths(3);
1051 		 
1052 		List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
1053 		Assert.assertTrue("There should be 1 leave blocks for princiapl id before runAccrual" + principal_id, leaveBlockList.size() == 2);
1054 		
1055 		LmServiceLocator.getLeaveAccrualService().runAccrual(principal_id, START_DATE, endDate.toDateTimeAtStartOfDay(), false, "admin");
1056 		
1057 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principal_id, START_DATE.toLocalDate(), endDate);
1058 		Assert.assertTrue("There should be 4 leave blocks for emplyee " + principal_id + ", not " + leaveBlockList.size(), leaveBlockList.size()== 4);
1059 		
1060 		// 04/10/2012
1061 		DateTime intervalDate = new DateTime(2012, 4, 10, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
1062 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
1063 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
1064 		LeaveBlock lb = leaveBlockList.get(0);		
1065 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 8, not " + lb.getLeaveAmount().toString()
1066 				 , lb.getLeaveAmount().equals(new BigDecimal(8)));	
1067 		Assert.assertTrue("LeaveBlockId of the leave block for date  " + intervalDate.toString() + " should be 5004, not " + lb.getLmLeaveBlockId()
1068 				 , lb.getLmLeaveBlockId().equals("5004"));	
1069 		
1070 		// 04/15/2012
1071 		intervalDate = new DateTime(2012, 4, 15, 5, 0, 0, 0, TKUtils.getSystemDateTimeZone());
1072 		leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForDate(principal_id, intervalDate.toLocalDate());
1073 		Assert.assertTrue("There should be 1 leave block for employee " + principal_id + " for date " + intervalDate.toString(), leaveBlockList.size()==1);
1074 		lb = leaveBlockList.get(0);		
1075 		Assert.assertTrue("Hours of the leave block for date  " + intervalDate.toString() + " should be 4, not " + lb.getLeaveAmount().toString()
1076 				 , lb.getLeaveAmount().equals(new BigDecimal(4)));	
1077 		Assert.assertTrue("LeaveBlockId of the leave block for date  " + intervalDate.toString() + " should be 5005, not " + lb.getLmLeaveBlockId()
1078 				 , lb.getLmLeaveBlockId().equals("5005"));
1079 	}
1080 
1081 }