View Javadoc
1   /**
2    * Copyright 2004-2015 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.core.institution;
17  
18  import org.junit.Assert;
19  import org.junit.Test;
20  import org.kuali.hr.KPMEWebTestCase;
21  import org.kuali.hr.util.HtmlUnitUtil;
22  import org.kuali.kpme.core.FunctionalTest;
23  import org.kuali.kpme.core.util.HrTestConstants;
24  
25  import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
26  import com.gargoylesoftware.htmlunit.html.HtmlElement;
27  import com.gargoylesoftware.htmlunit.html.HtmlForm;
28  import com.gargoylesoftware.htmlunit.html.HtmlInput;
29  import com.gargoylesoftware.htmlunit.html.HtmlPage;
30  
31  @FunctionalTest
32  public class InstitutionMaintTest extends KPMEWebTestCase {
33  
34  	private static final String INST_CODE = "SOME-CODE";
35  
36  	@Override
37  	public void setUp() throws Exception {
38  		super.setUp();
39  	}
40  	
41  	@Override
42  	public void tearDown() throws Exception {
43  		super.tearDown();
44  	}
45  	
46  	@Test
47  	public void testRequiredFields() throws Exception {
48  	  	String baseUrl = HrTestConstants.Urls.INSTITUTION_MAINT_NEW_URL;
49  	  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
50  	  	Assert.assertNotNull(page);
51  	 
52  	  	HtmlForm form = page.getFormByName("KualiForm");
53  	  	Assert.assertNotNull("Search form was missing from page.", form);
54  	  	
55  	  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
56  	  	Assert.assertNotNull("Could not locate submit button", input);
57  	  	
58  	  	HtmlElement element = page.getElementByName("methodToCall.route");
59  	  	page = element.click();
60  	  	Assert.assertTrue("page text does not contain:\n" + "Effective Date (Effective Date) is a required field.", 
61  	  			page.asText().contains("Effective Date (Effective Date) is a required field."));
62  	  	Assert.assertTrue("page text does not contain:\n" + "Institution Code (Institution Code) is a required field.", 
63  	  			page.asText().contains("Institution Code (Institution Code) is a required field."));
64  
65  	}
66  	
67  	@Test
68  	public void testLookup() throws Exception {
69  	  	String baseUrl = HrTestConstants.Urls.INSTITUTION_MAINT_URL;
70  	  	HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
71  	  	Assert.assertNotNull(page);
72  	 
73  	  	HtmlForm form = page.getFormByName("KualiForm");
74  	  	Assert.assertNotNull("Search form was missing from page.", form);
75  	  	
76  	  	Assert.assertNotNull("form should have show history", form.getInputByName("history"));
77  
78  	  	Assert.assertNotNull("form should have active field", form.getInputByName("active"));
79  
80  	  	Assert.assertNotNull("form should have institution code", form.getInputByName("institutionCode"));
81  	  	Assert.assertNotNull("form should have effectiveDateTo", form.getInputByName("effectiveDate"));
82  	  	HtmlInput  input  = HtmlUnitUtil.getInputContainingText(form, "search");
83  	  	Assert.assertNotNull("search input not found", input);
84  	  	
85  	  	HtmlPage resultPage = input.click();
86  	  	
87  	  	Assert.assertTrue("page text does not contain institution", 
88  	  			resultPage.asText().contains(INST_CODE));
89  	  	
90  	  	HtmlAnchor viewAnchor = resultPage.getAnchorByText("view");
91  	  	Assert.assertNotNull("no 'view' anchor found", viewAnchor);
92  	  	
93  	  	HtmlAnchor editAnchor = resultPage.getAnchorByText("edit");
94  	  	Assert.assertNotNull("no 'edit' anchor found", editAnchor);
95  	}
96  	
97  }