View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.principal.service;
17  
18  import java.sql.Date;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import junit.framework.Assert;
23  
24  import org.junit.Test;
25  import org.kuali.hr.test.KPMETestCase;
26  import org.kuali.hr.time.principal.PrincipalHRAttributes;
27  import org.kuali.hr.time.service.base.TkServiceLocator;
28  import org.kuali.hr.time.util.TKUtils;
29  
30  public class PrincipalHRAttributeServiceTest extends KPMETestCase {
31  	@Test
32  	public void testGetPrincipalHrAtributes() {
33  		List<PrincipalHRAttributes> phraList = new ArrayList<PrincipalHRAttributes>();
34  		Date fromEffDate = TKUtils.formatDateString("");
35  		Date toEffDate = TKUtils.formatDateString("");
36          String leavePlan = "";
37  		
38  		// show both active and inactive, show history
39  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "B", "Y");
40  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size());
41  		// active="Y", show history
42  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "Y", "Y");
43  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size());
44  		// active="N", show history
45  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "N", "Y");
46  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
47  		// active = "Y", do not show history
48  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "N", "N");
49  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
50  	}
51  }