1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.permissions;
17
18 import org.junit.After;
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.kuali.hr.lm.leaveblock.LeaveBlock;
23 import org.kuali.hr.test.KPMETestCase;
24 import org.kuali.hr.time.principal.PrincipalHRAttributes;
25 import org.kuali.hr.time.service.base.TkServiceLocator;
26 import org.kuali.hr.time.util.TKUser;
27 import org.kuali.hr.time.util.TKUtils;
28 import org.kuali.rice.kim.api.identity.Person;
29 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
30 import org.kuali.rice.krad.service.KRADServiceLocator;
31
32 public class TkPermissionServiceTest extends KPMETestCase {
33
34 @Before
35 public void setUp() throws Exception{
36 super.setUp();
37
38 Person testUser = KimApiServiceLocator.getPersonService().getPerson("eric");
39 TKUser.setTargetPerson(testUser);
40 PrincipalHRAttributes phra = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes("2");
41 phra.setLeaveCalendar("BWS-LM");
42 phra.setLeaveCalObj(TkServiceLocator.getCalendarService().getCalendarByGroup("BWS-LM"));
43 KRADServiceLocator.getBusinessObjectService().save(phra);
44 }
45
46 @After
47 public void tearDown() throws Exception {
48 super.tearDown();
49 Person testUser = KimApiServiceLocator.getPersonService().getPerson("admin");
50 TKUser.setTargetPerson(testUser);
51 PrincipalHRAttributes phra = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHRAttributes("2");
52 phra.setLeaveCalendar(null);
53 phra.setLeaveCalObj(null);
54 KRADServiceLocator.getBusinessObjectService().save(phra);
55 }
56
57 @Test
58
59
60 public void testCanDeleteLeaveBlockForSSTOUsageLB() {
61
62
63 LeaveBlock lb = TkServiceLocator.getLeaveBlockService().getLeaveBlock("6000");
64 lb.setLeaveDate(TKUtils.getCurrentDate());
65 boolean deleteFlag = TkServiceLocator.getPermissionsService().canDeleteLeaveBlock(lb);
66 Assert.assertTrue("Leave Block 6000 should be deletable", deleteFlag);
67
68
69 lb = TkServiceLocator.getLeaveBlockService().getLeaveBlock("6001");
70 lb.setLeaveDate(TKUtils.getCurrentDate());
71 deleteFlag = TkServiceLocator.getPermissionsService().canDeleteLeaveBlock(lb);
72 Assert.assertTrue("Leave Block 6001 should be deletable", deleteFlag);
73
74
75 lb = TkServiceLocator.getLeaveBlockService().getLeaveBlock("6002");
76 deleteFlag = TkServiceLocator.getPermissionsService().canDeleteLeaveBlock(lb);
77 Assert.assertFalse("Leave Block 6002 should NOT be deletable", deleteFlag);
78
79
80 lb = TkServiceLocator.getLeaveBlockService().getLeaveBlock("6003");
81 lb.setLeaveDate(TKUtils.getCurrentDate());
82 deleteFlag = TkServiceLocator.getPermissionsService().canDeleteLeaveBlock(lb);
83 Assert.assertFalse("Leave Block 6003 should NOT be deletable", deleteFlag);
84
85
86 }
87 }