1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.principal;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.joda.time.LocalDate;
22 import org.junit.Assert;
23 import org.junit.Test;
24 import org.kuali.kpme.core.CoreUnitTestCase;
25 import org.kuali.kpme.core.IntegrationTest;
26 import org.kuali.kpme.core.api.principal.PrincipalHRAttributes;
27 import org.kuali.kpme.core.service.HrServiceLocator;
28 import org.kuali.kpme.core.util.TKUtils;
29
30 @IntegrationTest
31 public class PrincipalHRAttributeServiceTest extends CoreUnitTestCase {
32 @Test
33 public void testGetPrincipalHrAtributes() {
34 List<PrincipalHRAttributes> phraList;
35 LocalDate fromEffDate = TKUtils.formatDateString("");
36 LocalDate toEffDate = TKUtils.formatDateString("");
37 String leavePlan = "";
38
39
40 phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "B", "Y");
41 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size());
42
43 phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "Y", "Y");
44 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size());
45
46 phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "N", "Y");
47 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
48
49 phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "N", "N");
50 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
51 }
52
53 @Test
54 public void testSearchPrincipalHRAttributes() throws Exception {
55 List<PrincipalHRAttributes> allResults = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", null, null, null, null, "Y", "N");
56 Assert.assertEquals("Search returned the wrong number of results.", 18, allResults.size());
57
58 List<PrincipalHRAttributes> restrictedResults = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testuser6", null, null, null, null, "Y", "N");
59 Assert.assertEquals("Search returned the wrong number of results.", 0, restrictedResults.size());
60 }
61
62 }