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.daily;
017
018
019 import org.apache.log4j.Logger;
020 import org.junit.Assert;
021 import org.junit.Test;
022 import org.kuali.hr.KPMEWebTestCase;
023 import org.kuali.hr.util.HtmlUnitUtil;
024 import org.kuali.kpme.core.FunctionalTest;
025 import org.kuali.kpme.tklm.utils.TkTestConstants;
026
027 import com.gargoylesoftware.htmlunit.html.HtmlInput;
028 import com.gargoylesoftware.htmlunit.html.HtmlPage;
029
030 @FunctionalTest
031 public class DailyOvertimeRuleMaintenanceTest extends KPMEWebTestCase{
032 private static final Logger LOG = Logger.getLogger(DailyOvertimeRuleMaintenanceTest.class);
033 private static final String TEST_CODE="BL";
034 private static String TEST_CODE_INVALID_DEPT_ID ="INVALID";
035 private static Long TEST_CODE_INVALID_TASK_ID =-1L;
036 private static Long TEST_CODE_INVALID_WORK_AREA_ID =-1L;
037 private static String dailyOvertimeRuleId = "5";
038
039 @Test
040 public void testDailyOvertimeRuleMaintForErrorMessages() throws Exception {
041 HtmlPage maintPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.DAILY_OVERTIME_RULE_MAINT_NEW_URL);
042
043 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
044 maintPage, "* Document Description");
045 inputForDescription.setValueAttribute("Test_Description");
046
047 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.effectiveDate", "01/01/2010");
048 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.location", "BL");
049 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.paytype", "HR");
050 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.dept", TEST_CODE_INVALID_DEPT_ID);
051 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString());
052 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.maxGap", "1.0");
053 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.minHours", "2");
054 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.earnCode", "OVT");
055 HtmlUnitUtil.setFieldValue(maintPage, "document.newMaintainableObject.fromEarnGroup", "RGN");
056
057 HtmlPage resultantPageAfterEdit = HtmlUnitUtil
058 .clickInputContainingText(maintPage, "submit");
059 LOG.debug(resultantPageAfterEdit.asText());
060 Assert.assertTrue("Maintenance Page contains test deptErrormessage",
061 resultantPageAfterEdit.asText().contains(
062 "The specified department '"
063 + TEST_CODE_INVALID_DEPT_ID
064 + "' does not exist."));
065
066 // test Convert from EarnCodeGroup has overtime earn codes error
067 HtmlUnitUtil.setFieldValue(resultantPageAfterEdit, "document.newMaintainableObject.fromEarnGroup", "OVT");
068 HtmlPage finalPage = HtmlUnitUtil.clickInputContainingText(resultantPageAfterEdit, "submit");
069 Assert.assertTrue("Maintenance Page should contains EarnCodeGroup has overtime earn code error",
070 finalPage.asText().contains("Earn Group 'OVT' has overtime earn codes."));
071
072 }
073
074 }