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.overtime.weekly;
017    
018    import org.junit.Assert;
019    import org.junit.Test;
020    import org.kuali.hr.util.HtmlUnitUtil;
021    import org.kuali.kpme.core.FunctionalTest;
022    
023    import com.gargoylesoftware.htmlunit.html.HtmlElement;
024    import com.gargoylesoftware.htmlunit.html.HtmlForm;
025    import com.gargoylesoftware.htmlunit.html.HtmlInput;
026    import com.gargoylesoftware.htmlunit.html.HtmlPage;
027    
028    
029    @FunctionalTest
030    public class WeeklyOvertimeRuleGroupMaintenanceTest extends WeeklyOvertimeRuleMaintenanceTest {
031    
032            protected static final String OVERTIME_EARN_GROUP="OVT";
033            @Test
034            //tests WeeklyOvertimeRuleValidation
035            public void testSubmitWeeklyOvertimeRuleGroupMaint() throws Exception {
036            String baseUrl = getBaseURL() + "/kr/maintenance.do?businessObjectClassName=org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRuleGroup&methodToCall=edit";
037            HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
038            Assert.assertNotNull(page);
039    
040            HtmlForm form = page.getFormByName("KualiForm");
041            Assert.assertNotNull("Search form was missing from page.", form);
042    
043            HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
044            Assert.assertNotNull("Could not locate submit button", input);
045            HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "test");
046                    HtmlElement element = page.getElementByName("methodToCall.route");
047            HtmlPage finalPage = element.click();
048            //HtmlUnitUtil.createTempFile(finalPage, "final");
049            Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified maxHoursEarnGroup '" + TEST_CODE + "' does not exist."));
050            Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertFromEarnGroup '" + TEST_CODE + "' does not exist."));
051            Assert.assertTrue("Maintenance Page contains error messages",finalPage.asText().contains("The specified convertToEarnCode '" + TEST_CODE + "' does not exist."));
052    
053                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.effectiveDate", "4/01/2011");
054                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHoursEarnGroup", "REG");
055                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertFromEarnGroup", "REG");
056                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.convertToEarnCode", OVERTIME_EARN_GROUP);
057                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.maxHours", "5");
058                    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.add.lstWeeklyOvertimeRules.step", "10");
059            element = (HtmlElement)page.getElementById("methodToCall.addLine.lstWeeklyOvertimeRules.(!!org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule!!)");
060            Assert.assertNotNull("Missing Add Line button", element);
061    
062            HtmlPage addPage = element.click();
063            //HtmlUnitUtil.createTempFile(addPage, "worgmt");
064    
065            Assert.assertTrue("Maintenance Page contains error messages",addPage.asText().contains("Rule already exists for step '10'."));
066            }
067    
068    }