View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.lm.employeeoverride;
17  
18  import org.junit.Ignore;
19  import org.kuali.hr.KPMEWebTestCase;
20  import org.kuali.kpme.core.FunctionalTest;
21  
22  @Ignore
23  @FunctionalTest
24  public class EmployeeOverrideMaintTest extends KPMEWebTestCase{
25  	private static final String EFFECTIVE_DATE_REQUIRED = "Effective Date (Effective Date) is a required field.";
26  	private static final String PRINCIPAL_ID_REQUIRED = "Principal Id (Principal Id) is a required field.";
27  	private static final String LEAVE_PLAN_REQUIRED = "Leave Plan (Leave Plan) is a required field.";
28  	private static final String ACCRUAL_CATEGORY_REQUIRED = "Accrual Category (Accrual Category) is a required field.";
29  	private static final String OVERRIDE_TYPE_REQUIRED = "Override Type (Override Type) is a required field.";
30  	private static final String AC_NOT_FOUND = "The specified Accrual Category 'test' does not exist.";
31  	private static final String PHA_NOT_FOUND = "The specified Principal HR Attributes 'test' does not exist.";
32  	private static final String LEAVE_PLAN_INCONSISTENT = "The specified principal id and Accrual Category have different leave plans.";
33  	private static final String OVERRIDE_VALUE_MAX_LENGTH_ERROR = "The specified Override Value (Override Value) must not be longer than 5 characters.";
34  	 /*
35  	  * TODO resolve this: FATAL org.kuali.rice.core.database.KualiTransactionInterceptor - 
36  	  * Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction.
37  	  * org.kuali.rice.kew.exception.DocumentTypeNotFoundException: unknown document type 'EmployeeOverrideDocumentType'
38  	  */
39  	
40  	/*
41  	@Test
42  	public void testRequiredFields() throws Exception {
43  	  	String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL;
44  	  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
45  	  	assertNotNull(page);
46  	 
47  	  	HtmlForm form = page.getFormByName("KualiForm");
48  	  	assertNotNull("Search form was missing from page.", form);
49  	  	
50  	  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
51  	  	assertNotNull("Could not locate submit button", input);
52  	  	
53  	  	HtmlElement element = page.getElementByName("methodToCall.route");
54  	  	page = element.click();
55  	  	assertFalse("page text contains: Incident Report", page.asText().contains("Incident Report"));
56  	  	assertTrue("Errors number is wrong", page.asText().contains("7 error(s) found on page."));
57  	  	assertTrue("page text does not contain:\n" + EFFECTIVE_DATE_REQUIRED, page.asText().contains(EFFECTIVE_DATE_REQUIRED));
58  	    assertTrue("page text does not contain:\n" + PRINCIPAL_ID_REQUIRED, page.asText().contains(PRINCIPAL_ID_REQUIRED));
59  	    assertTrue("page text does not contain:\n" + LEAVE_PLAN_REQUIRED, page.asText().contains(LEAVE_PLAN_REQUIRED));
60  	    assertTrue("page text does not contain:\n" + ACCRUAL_CATEGORY_REQUIRED, page.asText().contains(ACCRUAL_CATEGORY_REQUIRED));
61  	    assertTrue("page text does not contain:\n" + OVERRIDE_TYPE_REQUIRED, page.asText().contains(OVERRIDE_TYPE_REQUIRED));
62  	}
63  	
64  	@Test
65  	public void testLookupPage() throws Exception {	 
66  		HtmlPage eoLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_URL);
67  		eoLookup = HtmlUnitUtil.clickInputContainingText(eoLookup, "search");
68  		assertTrue("Page contains test EmployeeOverride", eoLookup.asText().contains("testAC"));
69  		HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(eoLookup, "edit");
70  		assertTrue("Maintenance Page contains test EmployeeOverride",maintPage.asText().contains("test"));	 
71  	}
72  	
73  	@Test
74  	public void testAddNew() throws Exception {
75  	  	String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL;
76  	  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
77  	  	assertNotNull(page);
78  	 
79  	  	HtmlForm form = page.getFormByName("KualiForm");
80  	  	assertNotNull("Search form was missing from page.", form);
81  	  	System.out.println(page.asXml());
82  	  	System.out.println("=================================================================================\n");
83  	  	System.out.println(form.asXml());
84  	  	
85  	  	HtmlUnitUtil.setFieldValue(page, "document.documentHeader.documentDescription", "Employee Override");
86  	    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2011");
87  	    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.principalId", "test");	// nonexist principal HR attributes
88  	    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.accrualCategory", "test");	//nonexist accrual catetory
89  	    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.overrideTypeMax Transfer Amount", "on");
90  	    HtmlUnitUtil.setFieldValue(page, "document.newMaintainableObject.overrideValue", "123456");	//max length is 5
91  	  	
92  	  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
93  	  	assertNotNull("Could not locate submit button", input);
94  	  	HtmlElement element = page.getElementByName("methodToCall.route");
95  	  	page = element.click();
96  	  	assertTrue("page text does not contain:\n" + OVERRIDE_VALUE_MAX_LENGTH_ERROR, page.asText().contains(OVERRIDE_VALUE_MAX_LENGTH_ERROR));
97  	  	assertTrue("page text does not contain:\n" + AC_NOT_FOUND, page.asText().contains(AC_NOT_FOUND));
98  	  	assertTrue("page text does not contain:\n" + PHA_NOT_FOUND, page.asText().contains(PHA_NOT_FOUND));
99  	  	
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 }