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