1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.lookup.view;
17
18 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19 import org.openqa.selenium.By;
20 import org.junit.Test;
21
22
23
24
25 public class DemoLookUpOperatorsAft extends WebDriverLegacyITBase {
26
27
28
29
30 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=OperatorsLookupSampleView&hideReturnLink=true";
31
32
33
34
35 private static final String TRAVEL_ACCOUNT_NUMBER="lookupCriteria[number]";
36
37
38
39
40 private static final String TRAVEL_ACCOUNT_NAME="lookupCriteria[name]";
41
42
43
44
45 private static final String SEARCH_BUTTON_TEXT="Search";
46
47
48
49
50 private static final String CLEAR_VALUES_BUTTON_TEXT="Clear Values";
51
52
53
54
55 private static final String PRINCIPAL_NAME="lookupCriteria[fiscalOfficer.principalName]";
56
57 @Override
58 public String getBookmarkUrl() {
59 return BOOKMARK_URL;
60 }
61
62 @Override
63 protected void navigate() throws Exception {
64 waitAndClickById("Demo-DemoLink", "");
65 waitAndClickByLinkText("Lookup Operators");
66 }
67
68 protected void testLookUpOperators() throws InterruptedException {
69 waitAndTestTravelAccountInput("a1*", new String[]{"a1","a10","a11","a12"}, null);
70 waitAndTestTravelAccountInput("!a1", new String[]{"a7","a10","a11","a12","a2","a3","a8","a9"}, null);
71 waitAndTestTravelAccountInput("a1?", new String[]{"a10","a13","a14","a11","a12"}, null);
72 waitAndTestTravelAccountInput("a1|a6", new String[]{"a1","a6"}, "a10");
73 waitAndTestTravelAccountInput("a1..a3", new String[]{"a1","a2","a3","a10","a11","a12","a13","a14"}, null);
74 waitAndTestTravelAccountInput("a1..a3", new String[]{"a1","a2","a3","a10","a11","a12","a13","a14"}, null);
75 waitAndTestTravelAccountInput(">a3", new String[]{"a4","a5","a6","a7","a8","a9"}, "a3");
76 waitAndTestTravelAccountInput(">=a3", new String[]{"a3","a4","a5","a6","a7","a8","a9"}, "a1");
77 waitAndTestTravelAccountInput("<a3", new String[]{"a1","a2","a10","a11","a12","a13","a14"}, "a3");
78 waitAndTestTravelAccountInput("<=a3", new String[]{"a1","a2","a3","a10","a11","a12","a13","a14"}, "a4");
79 waitAndTestTravelAccountNameInput("!NULL",new String[]{"a1","a6","a7","a10","a11","a12","a13","a14"}, "a2");
80 waitAndTypeByName(TRAVEL_ACCOUNT_NAME,"NULL");
81 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
82 waitForTextPresent("No values match this search.");
83 waitAndTypeByName(PRINCIPAL_NAME,"fr* && *k");
84 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
85 }
86
87 private void waitAndTestTravelAccountInput(String inputValue, String [] assertPresentStringValue, String assertNotPresentStringValue) throws InterruptedException{
88 waitAndTypeByName(TRAVEL_ACCOUNT_NUMBER,inputValue);
89 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
90 if(assertPresentStringValue!=null) {
91 for(int i=0; i<assertPresentStringValue.length ; i++) {
92 waitForElementPresentByXpath("//table[@id='uLookupResults_layout']/*//a[contains(text(),'"+assertPresentStringValue[i]+"')]");
93 }
94 }
95 if(assertNotPresentStringValue!=null) {
96 waitForElementNotPresent(By.xpath(assertNotPresentStringValue));
97 }
98 waitAndClickButtonByText(CLEAR_VALUES_BUTTON_TEXT);
99 }
100
101 private void waitAndTestTravelAccountNameInput(String inputValue, String [] assertPresentStringValue, String assertNotPresentStringValue) throws InterruptedException{
102 waitAndTypeByName(TRAVEL_ACCOUNT_NAME,inputValue);
103 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
104 if(assertPresentStringValue!=null) {
105 for(int i=0; i<assertPresentStringValue.length ; i++) {
106 waitForElementPresentByXpath("//table[@id='uLookupResults_layout']/*//a[contains(text(),'"+assertPresentStringValue[i]+"')]");
107 }
108 }
109 if(assertNotPresentStringValue!=null) {
110 waitForElementNotPresent(By.xpath(assertNotPresentStringValue));
111 }
112 waitAndClickButtonByText(CLEAR_VALUES_BUTTON_TEXT);
113 }
114
115 @Test
116 public void testLookUpOperatorsBookmark() throws Exception {
117 testLookUpOperators();
118 passed();
119 }
120
121 @Test
122 public void testLookUpOperatorsNav() throws Exception {
123 testLookUpOperators();
124 passed();
125 }
126 }