1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 }