1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.invitation.test.po; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
import java.util.ArrayList; |
24 |
|
|
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.support.FindBy; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.openqa.selenium.WebDriverException; |
29 |
|
import org.xwiki.test.ui.po.BasePage; |
30 |
|
import org.xwiki.test.ui.po.TableElement; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 80.8% |
Uncovered Elements: 5 (26) |
Complexity: 7 |
Complexity Density: 0.41 |
|
38 |
|
public abstract class InspectInvitationsPage extends BasePage |
39 |
|
{ |
40 |
|
private InvitationFooterElement footer = new InvitationFooterElement(); |
41 |
|
|
42 |
|
@FindBy(tagName = "table") |
43 |
|
private WebElement tableWebEl; |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
7 |
public TableElement getTable()... |
46 |
|
{ |
47 |
7 |
return new TableElement(tableWebEl); |
48 |
|
} |
49 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
0 |
public InvitationFooterElement getFooter() {... |
51 |
0 |
return footer; |
52 |
|
} |
53 |
|
|
54 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
55 |
3 |
public String getStatusAndMemo()... |
56 |
|
{ |
57 |
3 |
List<WebElement> elements = getDriver().findElementsWithoutWaiting(By.id("message-status-and-memo")); |
58 |
3 |
if (elements.size() > 0) { |
59 |
3 |
return elements.get(0).getText(); |
60 |
|
} |
61 |
0 |
return null; |
62 |
|
} |
63 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
64 |
3 |
public OneMessage getMessageWhere(String columnName, String value)... |
65 |
|
{ |
66 |
3 |
List<String> columnEntries = new ArrayList<String>(); |
67 |
3 |
List<WebElement> column = getTable().getColumn(columnName); |
68 |
3 |
for (WebElement cell : column) { |
69 |
6 |
if (cell.getText().equals(value)) { |
70 |
|
|
71 |
3 |
WebElement link = getDriver().findElementsWithoutWaiting( |
72 |
|
getTable().getColumn("Subject").get(column.indexOf(cell)), By.tagName("a")).get(0); |
73 |
3 |
link.click(); |
74 |
3 |
return null; |
75 |
|
} |
76 |
3 |
columnEntries.add(cell.getText()); |
77 |
|
} |
78 |
0 |
throw new WebDriverException("Could not find message with " + column + " equal to " |
79 |
|
+ value + "\nIn columbn with entries: " + columnEntries.toString()); |
80 |
|
} |
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
83 |
1 |
protected TableElement clickMessageHistory()... |
84 |
|
{ |
85 |
1 |
getTable().getColumn("Message History").get(1).findElements(By.tagName("a")).get(0).click(); |
86 |
1 |
return new TableElement(getDriver().findElement(By.id("message-history-table")).findElement(By.tagName("table"))); |
87 |
|
} |
88 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
89 |
|
public static interface OneMessage |
90 |
|
{ |
91 |
|
public InvitationMessageDisplayElement getMessage(); |
92 |
|
|
93 |
|
|
94 |
|
public String notSpam(String message); |
95 |
|
|
96 |
|
public InvitationActionConfirmationElement cancel(); |
97 |
|
|
98 |
|
public String getStatusAndMemo(); |
99 |
|
|
100 |
|
public TableElement clickMessageHistory(); |
101 |
|
} |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.5 |
|
103 |
|
public static class AsAdmin extends InspectInvitationsPage |
104 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
105 |
1 |
@Override... |
106 |
|
public OneMessage getMessageWhere(String column, String value) |
107 |
|
{ |
108 |
1 |
super.getMessageWhere(column, value); |
109 |
1 |
return this.new OneMessage(); |
110 |
|
} |
111 |
|
|
|
|
| 46.7% |
Uncovered Elements: 8 (15) |
Complexity: 5 |
Complexity Density: 0.56 |
|
112 |
|
public class OneMessage extends AsAdmin implements InspectInvitationsPage.OneMessage |
113 |
|
{ |
114 |
|
@FindBy(id = "invitation-displaymessage") |
115 |
|
private WebElement preview; |
116 |
|
|
117 |
|
@FindBy(name = "doAction_notSpam") |
118 |
|
private WebElement notSpamButton; |
119 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
0 |
@Override... |
121 |
|
public InvitationMessageDisplayElement getMessage() |
122 |
|
{ |
123 |
0 |
return new InvitationMessageDisplayElement(preview); |
124 |
|
} |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
0 |
@Override... |
127 |
|
public TableElement clickMessageHistory() |
128 |
|
{ |
129 |
0 |
return super.clickMessageHistory(); |
130 |
|
} |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
0 |
@Override... |
133 |
|
public InvitationActionConfirmationElement cancel() |
134 |
|
{ |
135 |
0 |
throw new WebDriverException("Invitation cannot be canceled as an admin"); |
136 |
|
} |
137 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
138 |
1 |
@Override... |
139 |
|
public String notSpam(String message) |
140 |
|
{ |
141 |
1 |
notSpamButton.click(); |
142 |
1 |
InvitationActionConfirmationElement confirm = new InvitationActionConfirmationElement(); |
143 |
|
|
144 |
1 |
if (!confirm.getLabel().equalsIgnoreCase("Synopsis of findings and/or action taken")) { |
145 |
0 |
throw new WebDriverException("Not on 'not spam' confirm page, message says: " + confirm.getLabel()); |
146 |
|
} |
147 |
1 |
confirm.setMemo(message); |
148 |
1 |
return confirm.confirm(); |
149 |
|
} |
150 |
|
} |
151 |
|
} |
152 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.5 |
|
153 |
|
public static class AsUser extends InspectInvitationsPage |
154 |
|
{ |
155 |
|
@FindBy(name = "doAction_cancel") |
156 |
|
protected WebElement cancelButton; |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
158 |
2 |
@Override... |
159 |
|
public OneMessage getMessageWhere(String column, String value) |
160 |
|
{ |
161 |
2 |
super.getMessageWhere(column, value); |
162 |
2 |
return this.new OneMessage(); |
163 |
|
} |
164 |
|
|
|
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
165 |
|
public class OneMessage extends AsUser implements InspectInvitationsPage.OneMessage |
166 |
|
{ |
167 |
|
@FindBy(id = "invitation-displaymessage") |
168 |
|
private WebElement preview; |
169 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
0 |
@Override... |
171 |
|
public InvitationMessageDisplayElement getMessage() |
172 |
|
{ |
173 |
0 |
return new InvitationMessageDisplayElement(preview); |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
176 |
1 |
@Override... |
177 |
|
public TableElement clickMessageHistory() |
178 |
|
{ |
179 |
1 |
return super.clickMessageHistory(); |
180 |
|
} |
181 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
182 |
1 |
@Override... |
183 |
|
public InvitationActionConfirmationElement cancel() |
184 |
|
{ |
185 |
1 |
cancelButton.click(); |
186 |
1 |
return new InvitationActionConfirmationElement(); |
187 |
|
} |
188 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
189 |
0 |
@Override... |
190 |
|
public String notSpam(String message) |
191 |
|
{ |
192 |
0 |
throw new WebDriverException("Function only possible for admin."); |
193 |
|
} |
194 |
|
} |
195 |
|
} |
196 |
|
} |