View Javadoc
1   /**
2    * Copyright 2004-2014 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.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  		// show both active and inactive, show history
40  		phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "B", "Y");
41  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size());
42  		// active="Y", show history
43  		phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "Y", "Y");
44  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size());
45  		// active="N", show history
46  		phraList = HrServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("admin", "testUser", leavePlan, fromEffDate, toEffDate, "N", "Y");
47  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
48  		// active = "Y", do not show history
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  }