1 /**
2 * Copyright 2004-2013 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.test.KPMETestCase;
20
21 @Ignore
22 public class EmployeeOverrideMaintTest extends KPMETestCase{
23 private static final String EFFECTIVE_DATE_REQUIRED = "Effective Date (Effective Date) is a required field.";
24 private static final String PRINCIPAL_ID_REQUIRED = "Principal Id (Principal Id) is a required field.";
25 private static final String LEAVE_PLAN_REQUIRED = "Leave Plan (Leave Plan) is a required field.";
26 private static final String ACCRUAL_CATEGORY_REQUIRED = "Accrual Category (Accrual Category) is a required field.";
27 private static final String OVERRIDE_TYPE_REQUIRED = "Override Type (Override Type) is a required field.";
28 private static final String AC_NOT_FOUND = "The specified Accrual Category 'test' does not exist.";
29 private static final String PHA_NOT_FOUND = "The specified Principal HR Attributes 'test' does not exist.";
30 private static final String LEAVE_PLAN_INCONSISTENT = "The specified principal id and Accrual Category have different leave plans.";
31 private static final String OVERRIDE_VALUE_MAX_LENGTH_ERROR = "The specified Override Value (Override Value) must not be longer than 5 characters.";
32 /*
33 * TODO resolve this: FATAL org.kuali.rice.core.database.KualiTransactionInterceptor -
34 * Exception caught by Transaction Interceptor, this will cause a rollback at the end of the transaction.
35 * org.kuali.rice.kew.exception.DocumentTypeNotFoundException: unknown document type 'EmployeeOverrideDocumentType'
36 */
37
38 /*
39 @Test
40 public void testRequiredFields() throws Exception {
41 String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL;
42 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
43 assertNotNull(page);
44
45 HtmlForm form = page.getFormByName("KualiForm");
46 assertNotNull("Search form was missing from page.", form);
47
48 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
49 assertNotNull("Could not locate submit button", input);
50
51 HtmlElement element = page.getElementByName("methodToCall.route");
52 page = element.click();
53 assertFalse("page text contains: Incident Report", page.asText().contains("Incident Report"));
54 assertTrue("Errors number is wrong", page.asText().contains("7 error(s) found on page."));
55 assertTrue("page text does not contain:\n" + EFFECTIVE_DATE_REQUIRED, page.asText().contains(EFFECTIVE_DATE_REQUIRED));
56 assertTrue("page text does not contain:\n" + PRINCIPAL_ID_REQUIRED, page.asText().contains(PRINCIPAL_ID_REQUIRED));
57 assertTrue("page text does not contain:\n" + LEAVE_PLAN_REQUIRED, page.asText().contains(LEAVE_PLAN_REQUIRED));
58 assertTrue("page text does not contain:\n" + ACCRUAL_CATEGORY_REQUIRED, page.asText().contains(ACCRUAL_CATEGORY_REQUIRED));
59 assertTrue("page text does not contain:\n" + OVERRIDE_TYPE_REQUIRED, page.asText().contains(OVERRIDE_TYPE_REQUIRED));
60 }
61
62 @Test
63 public void testLookupPage() throws Exception {
64 HtmlPage eoLookup = HtmlUnitUtil.gotoPageAndLogin(TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_URL);
65 eoLookup = HtmlUnitUtil.clickInputContainingText(eoLookup, "search");
66 assertTrue("Page contains test EmployeeOverride", eoLookup.asText().contains("testAC"));
67 HtmlPage maintPage = HtmlUnitUtil.clickAnchorContainingText(eoLookup, "edit");
68 assertTrue("Maintenance Page contains test EmployeeOverride",maintPage.asText().contains("test"));
69 }
70
71 @Test
72 public void testAddNew() throws Exception {
73 String baseUrl = TkTestConstants.Urls.EMPLOYEE_OVERRIDE_MAINT_NEW_URL;
74 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(baseUrl);
75 assertNotNull(page);
76
77 HtmlForm form = page.getFormByName("KualiForm");
78 assertNotNull("Search form was missing from page.", form);
79 System.out.println(page.asXml());
80 System.out.println("=================================================================================\n");
81 System.out.println(form.asXml());
82
83 setFieldValue(page, "document.documentHeader.documentDescription", "Employee Override");
84 setFieldValue(page, "document.newMaintainableObject.effectiveDate", "04/01/2011");
85 setFieldValue(page, "document.newMaintainableObject.principalId", "test"); // nonexist principal HR attributes
86 setFieldValue(page, "document.newMaintainableObject.accrualCategory", "test"); //nonexist accrual catetory
87 setFieldValue(page, "document.newMaintainableObject.overrideTypeMax Transfer Amount", "on");
88 setFieldValue(page, "document.newMaintainableObject.overrideValue", "123456"); //max length is 5
89
90 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
91 assertNotNull("Could not locate submit button", input);
92 HtmlElement element = page.getElementByName("methodToCall.route");
93 page = element.click();
94 assertTrue("page text does not contain:\n" + OVERRIDE_VALUE_MAX_LENGTH_ERROR, page.asText().contains(OVERRIDE_VALUE_MAX_LENGTH_ERROR));
95 assertTrue("page text does not contain:\n" + AC_NOT_FOUND, page.asText().contains(AC_NOT_FOUND));
96 assertTrue("page text does not contain:\n" + PHA_NOT_FOUND, page.asText().contains(PHA_NOT_FOUND));
97
98 setFieldValue(page, "document.newMaintainableObject.overrideValue", "123");
99 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 }