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.workschedule;
017
018 import org.junit.Assert;
019 import org.junit.Ignore;
020 import org.junit.Test;
021 import org.kuali.hr.test.KPMETestCase;
022 import org.kuali.hr.time.test.HtmlUnitUtil;
023 import org.kuali.hr.time.test.TkTestConstants;
024
025 import com.gargoylesoftware.htmlunit.html.HtmlInput;
026 import com.gargoylesoftware.htmlunit.html.HtmlPage;
027
028 @Ignore
029 public class WorkScheduleMaintTest extends KPMETestCase{
030
031 private static final String TEST_CODE = "test-schedule";
032
033 private static String TEST_CODE_DEPT_INVALID = "INVALID";
034 private static Long TEST_CODE_WORKAREA_INVALID = -1L;
035
036 private static Long workScheduleWithInvalidDept = 11L;
037 private static Long workScheduleIdWithInvalidWorkArea = 12L;
038
039 /**
040 * Test to check whether it is showing error message for Department on maintenance screen
041 * if we supply non exist deptId
042 *
043 * @throws Exception
044 */
045 @Test
046 @Ignore
047 public void testworkScheduleMaintForDeptErrorMessage()
048 throws Exception {
049 HtmlPage workScheduleLookUp = HtmlUnitUtil
050 .gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
051 workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
052 workScheduleLookUp, "search");
053 Assert.assertTrue("Page contains test workSchedule",
054 workScheduleLookUp.asText().contains(TEST_CODE));
055 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
056 workScheduleLookUp, "edit",
057 workScheduleWithInvalidDept.toString());
058 HtmlInput inputForDept = HtmlUnitUtil.getInputContainingText(maintPage,
059 TEST_CODE_DEPT_INVALID);
060 inputForDept.setValueAttribute(TEST_CODE_DEPT_INVALID);
061 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
062 maintPage, "* Document Description");
063 inputForDescription.setValueAttribute("Description");
064 HtmlPage resultantPageAfterEdit = HtmlUnitUtil
065 .clickInputContainingText(maintPage, "submit");
066 Assert.assertTrue("Maintenance Page contains error message for dept",
067 resultantPageAfterEdit.asText().contains(
068 "The specified department '" + TEST_CODE_DEPT_INVALID
069 + "' does not exist."));
070 }
071
072 /**
073 * Test to check whether it is showing error message for WorkArea on maintenance screen
074 * if we supply non exist workArea
075 *
076 * @throws Exception
077 */
078 @Test
079 public void testWorkScheduleMaintForWorkAreaErrorMessage()
080 throws Exception {
081 HtmlPage workScheduleLookUp = HtmlUnitUtil
082 .gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
083 workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
084 workScheduleLookUp, "search");
085 Assert.assertTrue("Page contains test workSchedule",
086 workScheduleLookUp.asText().contains(TEST_CODE));
087 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
088 workScheduleLookUp, "edit",
089 workScheduleIdWithInvalidWorkArea.toString());
090 HtmlInput inputForWorkArea = HtmlUnitUtil.getInputContainingText(maintPage,
091 Long.toString(TEST_CODE_WORKAREA_INVALID));
092 inputForWorkArea.setValueAttribute(Long.toString(TEST_CODE_WORKAREA_INVALID));
093 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText(
094 maintPage, "* Document Description");
095 inputForDescription.setValueAttribute("Description");
096 HtmlPage resultantPageAfterEdit = HtmlUnitUtil
097 .clickInputContainingText(maintPage, "submit");
098 Assert.assertTrue("Maintenance Page contains contains error message for workarea",
099 resultantPageAfterEdit.asText().contains(
100 "The specified workarea '" + TEST_CODE_WORKAREA_INVALID
101 + "' does not exist."));
102 }
103
104 @Test
105 public void testWorkScheduleRuleMaint() throws Exception {
106 HtmlPage workScheduleLookUp = HtmlUnitUtil
107 .gotoPageAndLogin(TkTestConstants.Urls.WORK_SCHEDULE_MAINT_URL);
108 workScheduleLookUp = HtmlUnitUtil.clickInputContainingText(
109 workScheduleLookUp, "search");
110 Assert.assertTrue("Page contains test workSchedule",
111 workScheduleLookUp.asText().contains(
112 TEST_CODE.toString()));
113 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(
114 workScheduleLookUp, "edit",
115 workScheduleWithInvalidDept.toString());
116 Assert.assertTrue("Maintenance Page contains test WorkSchedule ",
117 maintPage.asText().contains(TEST_CODE.toString()));
118 }
119 }