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 |
|
|
24 |
|
import org.openqa.selenium.By; |
25 |
|
import org.openqa.selenium.WebDriverException; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.xwiki.test.ui.po.BasePage; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 85.7% |
Uncovered Elements: 4 (28) |
Complexity: 10 |
Complexity Density: 0.59 |
|
35 |
|
public class InvitationGuestActionsPage extends BasePage |
36 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
|
public enum Action |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
ACCEPT(null), |
42 |
|
DECLINE(null), |
43 |
|
REPORT("Note to the administrator who investigates this report (optional)"); |
44 |
|
|
45 |
|
public final String label; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
3 |
private Action(String label)... |
48 |
|
{ |
49 |
3 |
this.label = label; |
50 |
|
} |
51 |
|
} |
52 |
|
|
53 |
|
private final InvitationActionConfirmationElement confirm; |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0 |
public InvitationGuestActionsPage(String messageContent, Action action)... |
56 |
|
{ |
57 |
0 |
confirm = new InvitationActionConfirmationElement(); |
58 |
|
} |
59 |
|
|
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
31 |
public InvitationGuestActionsPage()... |
62 |
|
{ |
63 |
31 |
confirm = new InvitationActionConfirmationElement(); |
64 |
|
} |
65 |
|
|
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
3 |
public void setMemo(String memo)... |
68 |
|
{ |
69 |
3 |
confirm.setMemo(memo); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
72 |
24 |
public String getMessage()... |
73 |
|
{ |
74 |
24 |
List<WebElement> elements = getDriver().findElementsWithoutWaiting(By.id("invitation-action-message")); |
75 |
24 |
if (elements.size() > 0) { |
76 |
17 |
return elements.get(0).getText(); |
77 |
|
} |
78 |
|
|
79 |
7 |
return ""; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
84 |
3 |
public String confirm()... |
85 |
|
{ |
86 |
3 |
confirm.confirm(); |
87 |
3 |
return getDriver().findElement(By.id("invitation-action-message")).getText(); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
@return |
92 |
|
@since |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
4 |
public InvitationActionConfirmationElement getConfirmation()... |
95 |
|
{ |
96 |
4 |
return confirm; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
@param |
101 |
|
@param |
102 |
|
@return |
103 |
|
@since |
104 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
105 |
15 |
public static InvitationGuestActionsPage gotoPage(String htmlMessageContent, Action action)... |
106 |
|
{ |
107 |
15 |
int start = |
108 |
|
htmlMessageContent.indexOf(getUtil().getURL("Invitation", "InvitationGuestActions", "view", |
109 |
|
"doAction_" + action.toString().toLowerCase())); |
110 |
15 |
int end = htmlMessageContent.indexOf("\"", start); |
111 |
15 |
getUtil().gotoPage(htmlMessageContent.substring(start, end).replaceAll("&", "&")); |
112 |
|
|
113 |
15 |
InvitationGuestActionsPage page = new InvitationGuestActionsPage(); |
114 |
|
|
115 |
|
|
116 |
15 |
if (action.label != null && !page.getConfirmation().getLabel().equalsIgnoreCase(action.label)) { |
117 |
0 |
throw new WebDriverException("Not on correct page, expecting memo label to say \"" + action.label + "\""); |
118 |
|
} |
119 |
|
|
120 |
15 |
return new InvitationGuestActionsPage(); |
121 |
|
} |
122 |
|
} |