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.krad.demo.ViewDemoAftBase;
19 import org.openqa.selenium.By;
20 import org.junit.Test;
21
22
23
24
25 public class DemoLookUpOperatorsAft extends ViewDemoAftBase {
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 waitAndClickDemoLink();
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 waitForProgressLoading();
83 waitForTextPresent("No values match this search.");
84 waitAndTypeByName(PRINCIPAL_NAME,"fr* && *k");
85 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
86 }
87
88 private void waitAndTestTravelAccountInput(String inputValue, String [] assertPresentStringValue, String assertNotPresentStringValue) throws InterruptedException{
89 waitAndTypeByName(TRAVEL_ACCOUNT_NUMBER,inputValue);
90 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
91 waitForProgressLoading();
92 if(assertPresentStringValue!=null) {
93 for(int i=0; i<assertPresentStringValue.length ; i++) {
94 waitForElementPresentByXpath("//table[@id='uLookupResults_layout']/*//a[contains(text(),'"+assertPresentStringValue[i]+"')]");
95 }
96 }
97 if(assertNotPresentStringValue!=null) {
98 waitForElementNotPresent(By.xpath(assertNotPresentStringValue));
99 }
100 waitAndClickButtonByText(CLEAR_VALUES_BUTTON_TEXT);
101 }
102
103 private void waitAndTestTravelAccountNameInput(String inputValue, String [] assertPresentStringValue, String assertNotPresentStringValue) throws InterruptedException{
104 waitAndTypeByName(TRAVEL_ACCOUNT_NAME,inputValue);
105 waitAndClickButtonByText(SEARCH_BUTTON_TEXT);
106 waitForProgressLoading();
107 if(assertPresentStringValue!=null) {
108 for(int i=0; i<assertPresentStringValue.length ; i++) {
109 waitForElementPresentByXpath("//table[@id='uLookupResults_layout']/*//a[contains(text(),'"+assertPresentStringValue[i]+"')]");
110 }
111 }
112 if(assertNotPresentStringValue!=null) {
113 waitForElementNotPresent(By.xpath(assertNotPresentStringValue));
114 }
115 waitAndClickButtonByText(CLEAR_VALUES_BUTTON_TEXT);
116 }
117
118 @Test
119 public void testLookUpOperatorsBookmark() throws Exception {
120 testLookUpOperators();
121 passed();
122 }
123
124 @Test
125 public void testLookUpOperatorsNav() throws Exception {
126 testLookUpOperators();
127 passed();
128 }
129 }