1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.permission.service;
17
18 import org.joda.time.LocalDate;
19 import org.junit.After;
20 import org.junit.Assert;
21 import org.junit.Before;
22 import org.junit.Test;
23 import org.kuali.hr.KPMEWebTestCase;
24 import org.kuali.kpme.core.FunctionalTest;
25 import org.kuali.kpme.core.principal.PrincipalHRAttributes;
26 import org.kuali.kpme.core.service.HrServiceLocator;
27 import org.kuali.kpme.tklm.leave.block.LeaveBlock;
28 import org.kuali.kpme.tklm.leave.service.LmServiceLocator;
29 import org.kuali.rice.krad.service.KRADServiceLocator;
30
31 @FunctionalTest
32 public class LMPermissionServiceTest extends KPMEWebTestCase {
33
34 @Before
35 public void setUp() throws Exception{
36 super.setUp();
37
38
39 PrincipalHRAttributes phra = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes("2");
40 phra.setLeaveCalendar("BWS-LM");
41 phra.setLeaveCalObj(HrServiceLocator.getCalendarService().getCalendarByGroup("BWS-LM"));
42 KRADServiceLocator.getBusinessObjectService().save(phra);
43 }
44
45 @After
46 public void tearDown() throws Exception {
47 super.tearDown();
48
49 PrincipalHRAttributes phra = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes("2");
50 phra.setLeaveCalendar(null);
51 phra.setLeaveCalObj(null);
52 KRADServiceLocator.getBusinessObjectService().save(phra);
53 }
54
55 @Test
56
57
58 public void testCanDeleteLeaveBlockForSSTOUsageLB() {
59
60
61 LeaveBlock lb = LmServiceLocator.getLeaveBlockService().getLeaveBlock("6000");
62 lb.setLeaveDate(LocalDate.now().toDate());
63 boolean deleteFlag = LmServiceLocator.getLMPermissionService().canDeleteLeaveBlock("eric", lb);
64 Assert.assertTrue("Leave Block 6000 should be deletable", deleteFlag);
65
66
67 lb = LmServiceLocator.getLeaveBlockService().getLeaveBlock("6001");
68 lb.setLeaveDate(LocalDate.now().toDate());
69 deleteFlag = LmServiceLocator.getLMPermissionService().canDeleteLeaveBlock("eric", lb);
70 Assert.assertTrue("Leave Block 6001 should be deletable", deleteFlag);
71
72
73 lb = LmServiceLocator.getLeaveBlockService().getLeaveBlock("6002");
74 deleteFlag = LmServiceLocator.getLMPermissionService().canDeleteLeaveBlock("eric", lb);
75 Assert.assertFalse("Leave Block 6002 should NOT be deletable", deleteFlag);
76
77
78 lb = LmServiceLocator.getLeaveBlockService().getLeaveBlock("6003");
79 lb.setLeaveDate(LocalDate.now().toDate());
80 deleteFlag = LmServiceLocator.getLMPermissionService().canDeleteLeaveBlock("eric", lb);
81 Assert.assertFalse("Leave Block 6003 should NOT be deletable", deleteFlag);
82
83
84 }
85 }