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.clock.log; 017 018 import org.junit.Assert; 019 import org.junit.Test; 020 import org.kuali.hr.test.KPMETestCase; 021 import org.kuali.hr.time.test.HtmlUnitUtil; 022 import org.kuali.hr.time.test.TkTestConstants; 023 024 import com.gargoylesoftware.htmlunit.html.HtmlInput; 025 import com.gargoylesoftware.htmlunit.html.HtmlPage; 026 027 public class ClockLogMaintenanceTest extends KPMETestCase{ 028 private static Long TEST_CODE_INVALID_TASK_ID =9999L; 029 private static Long TEST_CODE_INVALID_WORK_AREA_ID =9999L; 030 private static Long clockLogId = 1L; 031 032 @Test 033 public void testClockLogMaint() throws Exception { 034 HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.CLOCK_LOG_MAINT_URL); 035 clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search"); 036 Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST")); 037 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString()); 038 Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST")); 039 } 040 041 @Test 042 public void testClockLogMaintForErrorMessages() throws Exception { 043 HtmlPage clockLogLookUp = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.CLOCK_LOG_MAINT_URL); 044 clockLogLookUp = HtmlUnitUtil.clickInputContainingText(clockLogLookUp, "search"); 045 Assert.assertTrue("Page contains test ClockLog", clockLogLookUp.asText().contains("TEST")); 046 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(clockLogLookUp, "edit",clockLogId.toString()); 047 Assert.assertTrue("Maintenance Page contains test ClockLog",maintPage.asText().contains("TEST")); 048 049 HtmlInput inputForDescription = HtmlUnitUtil.getInputContainingText( 050 maintPage, "* Document Description"); 051 inputForDescription.setValueAttribute("Test_Description"); 052 setFieldValue(maintPage, "document.newMaintainableObject.workArea", TEST_CODE_INVALID_WORK_AREA_ID.toString()); 053 setFieldValue(maintPage, "document.newMaintainableObject.task", TEST_CODE_INVALID_TASK_ID.toString()); 054 HtmlPage resultantPageAfterEdit = HtmlUnitUtil 055 .clickInputContainingText(maintPage, "submit"); 056 HtmlUnitUtil.createTempFile(resultantPageAfterEdit); 057 058 Assert.assertTrue("Maintenance Page contains test Workarea ", 059 resultantPageAfterEdit.asText().contains( 060 "The specified Workarea '" 061 + TEST_CODE_INVALID_WORK_AREA_ID 062 + "' does not exist.")); 063 064 HtmlUnitUtil.createTempFile(resultantPageAfterEdit); 065 066 Assert.assertTrue("Maintenance Page contains test Task ", 067 resultantPageAfterEdit.asText().contains( 068 "The specified Task '" 069 + TEST_CODE_INVALID_TASK_ID 070 + "' does not exist.")); 071 072 073 } 074 075 }