View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.lm.leaveblock.service;
17  
18  import java.util.Calendar;
19  import java.util.Date;
20  import java.util.List;
21  
22  import junit.framework.Assert;
23  
24  import org.joda.time.DateTime;
25  import org.junit.After;
26  import org.junit.Before;
27  import org.junit.Test;
28  import org.kuali.hr.lm.LMConstants;
29  import org.kuali.hr.lm.leaveblock.LeaveBlockHistory;
30  import org.kuali.hr.test.KPMETestCase;
31  import org.kuali.hr.time.service.base.TkServiceLocator;
32  import org.kuali.hr.time.util.TKUtils;
33  
34  public class LeaveBlockHistoryServiceImplTest extends KPMETestCase {
35  
36  	private LeaveBlockHistoryService leaveBlockHistoryService;
37  
38  	@Before
39  	public void setUp() throws Exception {
40  		super.setUp();
41  		leaveBlockHistoryService = TkServiceLocator
42  				.getLeaveBlockHistoryService();
43  	}
44  
45  	@After
46  	public void tearDown() throws Exception {
47  		super.tearDown();
48  	}
49  	
50  	@Test
51  	public void testGetLeaveBlockHistoryByLmLeaveBlockId() {
52  		List<LeaveBlockHistory> leaveBlockHistories = leaveBlockHistoryService.getLeaveBlockHistoryByLmLeaveBlockId("1000");
53  		Assert.assertNotNull("Leave Block histories  not found ", leaveBlockHistories);
54  	}
55  	
56  	@Test
57  	public void testGetLeaveBlockHistories() {
58  		List<LeaveBlockHistory> leaveBlockHistories = leaveBlockHistoryService.getLeaveBlockHistories("admin", null);
59  		Assert.assertNotNull("Leave Block histories  not found ", leaveBlockHistories);
60  	}
61  	
62  	@Test
63  	public void testGetLeaveBlockHistoriesForLeaveDisplay() {
64  		Calendar currCal = Calendar.getInstance();
65  		currCal.set(2012, 0, 1);
66  		Date beginDate = TKUtils.getTimelessDate(currCal.getTime());
67  		currCal.set(2012, 11, 31);
68  		Date endDate = TKUtils.getTimelessDate(currCal.getTime());
69          List<LeaveBlockHistory> leaveBlockHistories= leaveBlockHistoryService.getLeaveBlockHistoriesForLeaveDisplay("admin", beginDate, endDate, Boolean.TRUE);
70          Assert.assertNotNull("Leave Block histories for leavedisplay  not found ", leaveBlockHistories);
71  	}
72  	@Test
73  	public void testGetLeaveBlockHistoriesWithStatusAndAction() {
74  		Date currentDate = new Date((new DateTime(2012, 3, 10, 0, 0, 0, 0, TKUtils.getSystemDateTimeZone())).getMillis());
75  		List<LeaveBlockHistory> leaveBlockHistories= leaveBlockHistoryService.getLeaveBlockHistories("admin", LMConstants.REQUEST_STATUS.DISAPPROVED, LMConstants.ACTION.DELETE, currentDate);
76  		Assert.assertNotNull("Leave Block histories for leavedisplay  not found ", leaveBlockHistories);
77  		Assert.assertTrue("There should be 1 leave block history found, not " + leaveBlockHistories.size() , leaveBlockHistories.size() == 1);
78  	}
79  	
80  
81  }