View Javadoc
1   /**
2    * Copyright 2005-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.rice.krad.demo.lookup.view;
17  
18  import org.kuali.rice.krad.demo.ViewDemoAftBase;
19  import org.junit.Test;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class DemoBasicLookUpAft extends ViewDemoAftBase {
25  
26      /**
27       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleView
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleView";
30      
31      /**
32       *	lookupCriteria[number]
33       */
34      private static final String TRAVEL_ACCOUNT_NUMBER_NAME="lookupCriteria[number]";
35      
36      /**
37       *	lookupCriteria[name]
38       */
39      private static final String TRAVEL_ACCOUNT_NAME="lookupCriteria[name]";
40      
41      /**
42       * lookupCriteria[fiscalOfficer.principalName]
43       */
44      private static final String PRINCIPAL_NAME="lookupCriteria[fiscalOfficer.principalName]";
45      
46      @Override
47      public String getBookmarkUrl() {
48          return BOOKMARK_URL;
49      }
50  
51      @Override
52      protected void navigate() throws Exception {
53          waitAndClickDemoLink();
54          jGrowl("Click Lookup Link (Basic Lookup)");
55          waitAndClickByXpath("//a[@href='lookup?methodToCall=start&viewId=LookupSampleView']");
56      }
57  
58      protected void testBasicLookUp() throws InterruptedException {
59      	//Search By Number
60      	waitAndTypeByName(TRAVEL_ACCOUNT_NUMBER_NAME,"BALFTYHTB");
61      	waitAndClickSearchByText();
62          waitForProgressLoading();
63      	waitForTextPresent("BALFTYHTB");
64          waitAndClickClearValues();
65  
66      	//Search By Name
67      	waitAndTypeByName(TRAVEL_ACCOUNT_NAME,"Travel Account 2");
68          waitAndClickSearchByText();
69          waitForProgressLoading();
70      	waitForTextPresent("Travel Account 2");
71          waitAndClickClearValues();
72      	
73      	//Search By Principal Name
74      	waitAndTypeByName(PRINCIPAL_NAME,"fred");
75          waitAndClickSearchByText();
76          waitForProgressLoading();
77      	waitForTextPresent("Travel Account 1");
78          waitAndClickClearValues();
79      	
80      	//Search By Date
81      	waitAndTypeByName("lookupCriteria[rangeLowerBoundKeyPrefix_createDate]","06/01/2000");
82      	waitAndTypeByName("lookupCriteria[createDate]","06/01/2050");
83          waitAndClickSearchByText();
84          waitForProgressLoading();
85      	waitForTextPresent("Travel Account");
86      }
87      
88      protected void testBasicLookUpSearchEditSave() throws InterruptedException {
89      	//Search By Number
90          waitAndTypeByName(TRAVEL_ACCOUNT_NUMBER_NAME,"a2");
91          waitAndClickSearchByText();
92          waitForProgressLoading();
93          waitForTextPresent("a2");
94          waitAndClickByLinkText("edit");
95      	
96      	//Edit & Save
97      	waitAndTypeByName("document.documentHeader.documentDescription","Edited Description");
98      	getTextByXpath("//div[@data-label='Travel Account Name']");
99      	waitAndTypeByName("document.newMaintainableObject.dataObject.name"," Edited");
100 
101         submitSuccessfully();
102     }
103    
104     @Test
105     public void testBasicLookUpBookmark() throws Exception {
106         testBasicLookUp();
107         passed();
108     }
109 
110     @Test
111     public void testBasicLookUpNav() throws Exception {
112         testBasicLookUp();
113         passed();
114     }
115     
116     @Test
117     public void testBasicLookUpSearchEditSaveBookmark() throws Exception {
118     	testBasicLookUpSearchEditSave();
119         passed();
120     }
121 
122     @Test
123     public void testBasicLookUpSearchEditSaveNav() throws Exception {
124     	testBasicLookUpSearchEditSave();
125         passed();
126     }
127 }