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.HashMap; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.openqa.selenium.support.FindBy; |
28 |
|
import org.xwiki.test.ui.po.BasePage; |
29 |
|
import org.xwiki.test.ui.po.FormElement; |
30 |
|
import org.xwiki.test.ui.po.TableElement; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 93.6% |
Uncovered Elements: 3 (47) |
Complexity: 15 |
Complexity Density: 0.58 |
|
38 |
|
public class InvitationSenderPage extends BasePage |
39 |
|
{ |
40 |
|
@FindBy(id = "invitation-sender-form") |
41 |
|
private WebElement form; |
42 |
|
|
43 |
|
private FormElement formElement; |
44 |
|
|
45 |
|
@FindBy(xpath = "//form[@id='invitation-sender-form']/div/div/span/input[@type='submit'][@name='preview']") |
46 |
|
private WebElement previewButton; |
47 |
|
|
48 |
|
@FindBy(xpath = "//form[@id='invitation-sender-form']/div/div/span/input[@type='submit'][@name='sendMail']") |
49 |
|
private WebElement sendButton; |
50 |
|
|
51 |
|
@FindBy(id = "invitation-displaymessage") |
52 |
|
private WebElement preview; |
53 |
|
|
54 |
|
private InvitationMessageDisplayElement previewElement; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
22 |
public static InvitationSenderPage gotoPage()... |
57 |
|
{ |
58 |
22 |
getUtil().gotoPage(getURL()); |
59 |
22 |
return new InvitationSenderPage(); |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
22 |
public static String getURL()... |
63 |
|
{ |
64 |
22 |
return getUtil().getURL("Invitation", "WebHome"); |
65 |
|
} |
66 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
67 |
2 |
public boolean userIsSpammer()... |
68 |
|
{ |
69 |
2 |
for (WebElement error : getDriver().findElementsWithoutWaiting(By.id("invitation-permission-error"))) { |
70 |
1 |
if (error.getText().equals( |
71 |
|
"A message which you sent was reported as spam and your privilege to send mail has" |
72 |
|
+ " been suspended pending investigation, we apologize for the inconvenience.")) { |
73 |
1 |
return true; |
74 |
|
} |
75 |
|
} |
76 |
1 |
return false; |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
12 |
public void fillInDefaultValues()... |
80 |
|
{ |
81 |
12 |
fillForm("user@localhost.localdomain", "This is a subject line.", "This is my message"); |
82 |
|
} |
83 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
84 |
18 |
public void fillForm(final String recipients,... |
85 |
|
final String subjectLine, |
86 |
|
final String messageBody) |
87 |
|
{ |
88 |
18 |
Map<String, String> map = new HashMap<String, String>(); |
89 |
18 |
if (recipients != null) { |
90 |
18 |
map.put("recipients", recipients); |
91 |
|
} |
92 |
18 |
if (subjectLine != null) { |
93 |
12 |
map.put("subjectLine", subjectLine); |
94 |
|
} |
95 |
18 |
if (messageBody != null) { |
96 |
13 |
map.put("messageBody", messageBody); |
97 |
|
} |
98 |
18 |
getForm().fillFieldsByName(map); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
101 |
11 |
public InvitationSentPage send()... |
102 |
|
{ |
103 |
11 |
this.sendButton.click(); |
104 |
11 |
return this.new InvitationSentPage(); |
105 |
|
} |
106 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
107 |
1 |
public InvitationMessageDisplayElement preview()... |
108 |
|
{ |
109 |
1 |
this.previewButton.click(); |
110 |
|
|
111 |
1 |
if (this.previewElement == null) { |
112 |
1 |
this.previewElement = new InvitationMessageDisplayElement(this.preview); |
113 |
|
} |
114 |
1 |
return this.previewElement; |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
117 |
18 |
public FormElement getForm()... |
118 |
|
{ |
119 |
18 |
if (this.formElement == null) { |
120 |
17 |
this.formElement = new FormElement(this.form); |
121 |
|
} |
122 |
18 |
return this.formElement; |
123 |
|
} |
124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
9 |
public InvitationFooterElement getFooter()... |
126 |
|
{ |
127 |
9 |
return new InvitationFooterElement(); |
128 |
|
} |
129 |
|
|
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
131 |
|
public class InvitationSentPage extends BasePage |
132 |
|
{ |
133 |
|
@FindBy(id = "invitation-action-message") |
134 |
|
private WebElement messageBox; |
135 |
|
|
136 |
|
@FindBy(xpath = "//div[@class='message-table']/table") |
137 |
|
private WebElement table; |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
4 |
public String getMessageBoxContent()... |
140 |
|
{ |
141 |
4 |
return this.messageBox.getText(); |
142 |
|
} |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
144 |
2 |
public TableElement getTable()... |
145 |
|
{ |
146 |
2 |
return new TableElement(this.table); |
147 |
|
} |
148 |
|
} |
149 |
|
} |