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  		
37  		// show both active and inactive, show history
38  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "B", "Y");
39  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size());
40  		// active="Y", show history
41  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "Y", "Y");
42  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size());
43  		// active="N", show history
44  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "N", "Y");
45  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
46  		// active = "Y", do not show history
47  		phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "N", "N");
48  		Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
49  	}
50  }