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.earngroup.service;
017    
018    import java.sql.Date;
019    
020    import org.apache.commons.lang.StringUtils;
021    import org.junit.Assert;
022    import org.junit.Test;
023    import org.kuali.hr.test.KPMETestCase;
024    import org.kuali.hr.time.earngroup.EarnGroup;
025    import org.kuali.hr.time.service.base.TkServiceLocator;
026    import org.kuali.hr.time.test.HtmlUnitUtil;
027    import org.kuali.hr.time.test.TkTestConstants;
028    
029    import com.gargoylesoftware.htmlunit.html.HtmlPage;
030    
031    public class EarnGroupServiceTest extends KPMETestCase{
032            @Test
033            public void testEarnGroupFetch() throws Exception{
034                    EarnGroup earnGroup = TkServiceLocator.getEarnGroupService().getEarnGroup("REG", new Date(System.currentTimeMillis()));
035                    Assert.assertTrue("Test Earn Group fetch failed", earnGroup!=null && StringUtils.equals("REG", earnGroup.getEarnGroup()));
036                    Assert.assertTrue("Test earn group def fetch failed", earnGroup.getEarnGroups()!=null && earnGroup.getEarnGroups().get(0).getHrEarnGroupId().equals("100"));
037            }
038    
039            @Test
040            public void testEarnGroupMaintenancePage() throws Exception{
041                    HtmlPage earnCodeLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.EARN_GROUP_MAINT_URL);
042                    earnCodeLookUp = HtmlUnitUtil.clickInputContainingText(earnCodeLookUp, "search");
043                    HtmlUnitUtil.createTempFile(earnCodeLookUp);
044                    Assert.assertTrue("Page contains REG entry", earnCodeLookUp.asText().contains("REG"));
045    
046                    EarnGroup earnGroup = TkServiceLocator.getEarnGroupService().getEarnGroup("REG", new Date(System.currentTimeMillis()));
047                    String earnGroupId = earnGroup.getHrEarnGroupId().toString();
048                    HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(earnCodeLookUp, "edit", earnGroupId);
049                    HtmlUnitUtil.createTempFile(maintPage);
050                    Assert.assertTrue("Maintenance Page contains REG entry",maintPage.asText().contains("REG"));
051            }
052    }