1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.appwithinminutes.test.po; |
21 |
|
|
22 |
|
import org.apache.commons.lang.StringUtils; |
23 |
|
import org.openqa.selenium.By; |
24 |
|
import org.openqa.selenium.WebElement; |
25 |
|
import org.xwiki.test.ui.po.ConfirmationPage; |
26 |
|
import org.xwiki.test.ui.po.LiveTableElement; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 13 |
Complexity Density: 0.57 |
|
34 |
|
public class ApplicationsLiveTableElement extends LiveTableElement |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
private static final String APP_NAME_FILTER_ID = "xwiki-livetable-livetable-filter-1"; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private static final String APP_NAME_COLUMN_TITLE = "Application name"; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
14 |
public ApplicationsLiveTableElement()... |
50 |
|
{ |
51 |
14 |
super("livetable"); |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@return |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
2 |
public boolean isApplicationListed(String appName)... |
59 |
|
{ |
60 |
2 |
return hasRow(APP_NAME_COLUMN_TITLE, appName); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
@param |
65 |
|
@return |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
2 |
public boolean isApplicationListed(String... appPath)... |
68 |
|
{ |
69 |
2 |
return hasRow(APP_NAME_COLUMN_TITLE, join(appPath)); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
72 |
1 |
public ApplicationHomePage viewApplication(String... path)... |
73 |
|
{ |
74 |
1 |
String escapedPath = getUtil().escapeXPath(join(path)); |
75 |
1 |
getDriver().findElementWithoutWaiting( |
76 |
|
By.xpath("//td[contains(@class, 'doc_space')]/a[. = " + escapedPath + "]")).click(); |
77 |
1 |
return new ApplicationHomePage(); |
78 |
|
} |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
3 |
private String join(String... path)... |
81 |
|
{ |
82 |
3 |
return StringUtils.join(path, " \u00BB "); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@param |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
90 |
2 |
public ConfirmationPage clickDeleteApplication(String appName)... |
91 |
|
{ |
92 |
2 |
clickAction(appName, "delete"); |
93 |
2 |
return new ConfirmationPage(); |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
@param |
98 |
|
@return |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
3 |
public boolean canDeleteApplication(String appName)... |
101 |
|
{ |
102 |
3 |
return hasAction(appName, "delete"); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
@param |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
110 |
1 |
public ApplicationClassEditPage clickEditApplication(String appName)... |
111 |
|
{ |
112 |
1 |
clickAction(appName, "edit"); |
113 |
1 |
return new ApplicationClassEditPage(); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
@param |
118 |
|
@return |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
3 |
public boolean canEditApplication(String appName)... |
121 |
|
{ |
122 |
3 |
return hasAction(appName, "edit"); |
123 |
|
} |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@param |
129 |
|
@param |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
131 |
3 |
protected void clickAction(String appName, String action)... |
132 |
|
{ |
133 |
3 |
String escapedAppName = appName.replace("\\", "\\\\").replace("'", "\\'"); |
134 |
3 |
String actionLinkXPath = |
135 |
|
"//tr[td[contains(@class, 'doc_space') and . = '" + escapedAppName |
136 |
|
+ "']]/td[@class = 'actions']//a[contains(@class, 'action" + action + "')]"; |
137 |
3 |
WebElement liveTableBody = getDriver().findElement(By.id("livetable-display")); |
138 |
3 |
liveTableBody.findElement(By.xpath(actionLinkXPath)).click(); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
@return |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
144 |
6 |
protected boolean hasAction(String appName, String action)... |
145 |
|
{ |
146 |
6 |
String escapedAppName = appName.replace("\\", "\\\\").replace("'", "\\'"); |
147 |
6 |
String actionLinkXPath = |
148 |
|
"//tr[td[contains(@class, 'doc_space') and . = '" + escapedAppName |
149 |
|
+ "']]/td[@class = 'actions']//a[contains(@class, 'action" + action + "')]"; |
150 |
6 |
WebElement liveTableBody = getDriver().findElement(By.id("livetable-display")); |
151 |
6 |
return liveTableBody.findElements(By.xpath(actionLinkXPath)).size() > 0; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
@param |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
4 |
public void filterApplicationName(String appNameFilter)... |
160 |
|
{ |
161 |
4 |
super.filterColumn(APP_NAME_FILTER_ID, appNameFilter); |
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
2 |
public String getApplicationNameFilter()... |
165 |
|
{ |
166 |
2 |
return super.getFilterValue(APP_NAME_FILTER_ID); |
167 |
|
} |
168 |
|
} |