001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.principal.service; 017 018 import java.sql.Date; 019 import java.util.ArrayList; 020 import java.util.List; 021 022 import junit.framework.Assert; 023 024 import org.junit.Test; 025 import org.kuali.hr.test.KPMETestCase; 026 import org.kuali.hr.time.principal.PrincipalHRAttributes; 027 import org.kuali.hr.time.service.base.TkServiceLocator; 028 import org.kuali.hr.time.util.TKUtils; 029 030 public class PrincipalHRAttributeServiceTest extends KPMETestCase { 031 @Test 032 public void testGetPrincipalHrAtributes() { 033 List<PrincipalHRAttributes> phraList = new ArrayList<PrincipalHRAttributes>(); 034 Date fromEffDate = TKUtils.formatDateString(""); 035 Date toEffDate = TKUtils.formatDateString(""); 036 037 // show both active and inactive, show history 038 phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "B", "Y"); 039 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size()); 040 // active="Y", show history 041 phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "Y", "Y"); 042 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size()); 043 // active="N", show history 044 phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "N", "Y"); 045 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size()); 046 // active = "Y", do not show history 047 phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", fromEffDate, toEffDate, "N", "N"); 048 Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size()); 049 } 050 }