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            String leavePlan = "";
037                    
038                    // show both active and inactive, show history
039                    phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "B", "Y");
040                    Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 3, phraList.size());
041                    // active="Y", show history
042                    phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "Y", "Y");
043                    Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 2, phraList.size());
044                    // active="N", show history
045                    phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "N", "Y");
046                    Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
047                    // active = "Y", do not show history
048                    phraList = TkServiceLocator.getPrincipalHRAttributeService().getPrincipalHrAtributes("testUser", leavePlan, fromEffDate, toEffDate, "N", "N");
049                    Assert.assertEquals("Incorrect number of PrincipalHRAttributes", 1, phraList.size());
050            }
051    }