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.lm.employeeoverride; 017 018 import org.junit.Ignore; 019 import org.kuali.hr.test.KPMETestCase; 020 021 @Ignore 022 public class EmployeeOverrideMaintTest extends KPMETestCase{ 023 private static final String EFFECTIVE_DATE_REQUIRED = "Effective Date (Effective Date) is a required field."; 024 private static final String PRINCIPAL_ID_REQUIRED = "Principal Id (Principal Id) is a required field."; 025 private static final String LEAVE_PLAN_REQUIRED = "Leave Plan (Leave Plan) is a required field."; 026 private static final String ACCRUAL_CATEGORY_REQUIRED = "Accrual Category (Accrual Category) is a required field."; 027 private static final String OVERRIDE_TYPE_REQUIRED = "Override Type (Override Type) is a required field."; 028 private static final String AC_NOT_FOUND = "The specified Accrual Category 'test' does not exist."; 029 private static final String PHA_NOT_FOUND = "The specified Principal HR Attributes 'test' does not exist."; 030 private static final String LEAVE_PLAN_INCONSISTENT = "The specified principal id and Accrual Category have different leave plans."; 031 private static final String OVERRIDE_VALUE_MAX_LENGTH_ERROR = "The specified Override Value (Override Value) must not be longer than 5 characters."; 032 /* 033 * TODO resolve this: FATAL org.kuali.rice.core.database.KualiTransactionInterceptor - 034 * Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction. 035 * org.kuali.rice.kew.exception.DocumentTypeNotFoundException: unknown document type 'EmployeeOverrideDocumentType' 036 */ 037 038 /* 039 @Test 040 public void testRequiredFields() throws Exception { 041 String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL; 042 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl); 043 assertNotNull(page); 044 045 HtmlForm form = page.getFormByName("KualiForm"); 046 assertNotNull("Search form was missing from page.", form); 047 048 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route"); 049 assertNotNull("Could not locate submit button", input); 050 051 HtmlElement element = page.getElementByName("methodToCall.route"); 052 page = element.click(); 053 assertFalse("page text contains: Incident Report", page.asText().contains("Incident Report")); 054 assertTrue("Errors number is wrong", page.asText().contains("7 error(s) found on page.")); 055 assertTrue("page text does not contain:\n" + EFFECTIVE_DATE_REQUIRED, page.asText().contains(EFFECTIVE_DATE_REQUIRED)); 056 assertTrue("page text does not contain:\n" + PRINCIPAL_ID_REQUIRED, page.asText().contains(PRINCIPAL_ID_REQUIRED)); 057 assertTrue("page text does not contain:\n" + LEAVE_PLAN_REQUIRED, page.asText().contains(LEAVE_PLAN_REQUIRED)); 058 assertTrue("page text does not contain:\n" + ACCRUAL_CATEGORY_REQUIRED, page.asText().contains(ACCRUAL_CATEGORY_REQUIRED)); 059 assertTrue("page text does not contain:\n" + OVERRIDE_TYPE_REQUIRED, page.asText().contains(OVERRIDE_TYPE_REQUIRED)); 060 } 061 062 @Test 063 public void testLookupPage() throws Exception { 064 HtmlPage eoLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_URL); 065 eoLookup = HtmlUnitUtil.clickInputContainingText(eoLookup, "search"); 066 assertTrue("Page contains test EmployeeOverride", eoLookup.asText().contains("testAC")); 067 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(eoLookup, "edit"); 068 assertTrue("Maintenance Page contains test EmployeeOverride",maintPage.asText().contains("test")); 069 } 070 071 @Test 072 public void testAddNew() throws Exception { 073 String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL; 074 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl); 075 assertNotNull(page); 076 077 HtmlForm form = page.getFormByName("KualiForm"); 078 assertNotNull("Search form was missing from page.", form); 079 System.out.println(page.asXml()); 080 System.out.println("=================================================================================\n"); 081 System.out.println(form.asXml()); 082 083 setFieldValue(page, "document.documentHeader.documentDescription", "Employee Override"); 084 setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2011"); 085 setFieldValue(page, "document.newMaintainableObject.principalId", "test"); // nonexist principal HR attributes 086 setFieldValue(page, "document.newMaintainableObject.accrualCategory", "test"); //nonexist accrual catetory 087 setFieldValue(page, "document.newMaintainableObject.overrideTypeMax Transfer Amount", "on"); 088 setFieldValue(page, "document.newMaintainableObject.overrideValue", "123456"); //max length is 5 089 090 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route"); 091 assertNotNull("Could not locate submit button", input); 092 HtmlElement element = page.getElementByName("methodToCall.route"); 093 page = element.click(); 094 assertTrue("page text does not contain:\n" + OVERRIDE_VALUE_MAX_LENGTH_ERROR, page.asText().contains(OVERRIDE_VALUE_MAX_LENGTH_ERROR)); 095 assertTrue("page text does not contain:\n" + AC_NOT_FOUND, page.asText().contains(AC_NOT_FOUND)); 096 assertTrue("page text does not contain:\n" + PHA_NOT_FOUND, page.asText().contains(PHA_NOT_FOUND)); 097 098 setFieldValue(page, "document.newMaintainableObject.overrideValue", "123"); 099 setFieldValue(page, "document.newMaintainableObject.principalId", "111"); // existing principal HR Attributes 100 setFieldValue(page, "document.newMaintainableObject.accrualCategory", "testAC2"); // existing accrual category, inconsistent leave plan 101 element = page.getElementByName("methodToCall.route"); 102 page = element.click(); 103 assertFalse("page text contains:\n" + OVERRIDE_VALUE_MAX_LENGTH_ERROR, page.asText().contains(OVERRIDE_VALUE_MAX_LENGTH_ERROR)); 104 assertFalse("page text contains:\n" + AC_NOT_FOUND, page.asText().contains(AC_NOT_FOUND)); 105 assertFalse("page text contains:\n" + PHA_NOT_FOUND, page.asText().contains(PHA_NOT_FOUND)); 106 assertTrue("page text does not contain:\n" + LEAVE_PLAN_INCONSISTENT, page.asText().contains(LEAVE_PLAN_INCONSISTENT)); 107 108 } 109 */ 110 }