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