1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.blog.test.po; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.apache.commons.lang.StringUtils; |
26 |
|
import org.openqa.selenium.By; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.openqa.selenium.support.FindBy; |
29 |
|
import org.xwiki.test.ui.po.InlinePage; |
30 |
|
import org.xwiki.test.ui.po.editor.wysiwyg.EditorElement; |
31 |
|
import org.xwiki.test.ui.po.editor.wysiwyg.RichTextAreaElement; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@version |
37 |
|
@since |
38 |
|
|
|
|
| 81.5% |
Uncovered Elements: 10 (54) |
Complexity: 17 |
Complexity Density: 0.53 |
|
39 |
|
public class BlogPostInlinePage extends InlinePage |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
@FindBy(id = "Blog.BlogPostClass_0_title") |
45 |
|
private WebElement titleInput; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@FindBy(className = "blog-categories-list") |
51 |
|
private WebElement categoryList; |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@FindBy(id = "Blog.BlogPostClass_0_hidden") |
57 |
|
private WebElement hiddenCheckBox; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
private final EditorElement contentEditor = new EditorElement("Blog.BlogPostClass_0_content"); |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
private final EditorElement summaryEditor = new EditorElement("Blog.BlogPostClass_0_extract"); |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
@param |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
74 |
2 |
public void setTitle(String title)... |
75 |
|
{ |
76 |
2 |
titleInput.clear(); |
77 |
2 |
titleInput.sendKeys(title); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
@return |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
2 |
public String getTitle()... |
84 |
|
{ |
85 |
2 |
return titleInput.getAttribute("value"); |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
@param |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
93 |
2 |
public void setContent(String content)... |
94 |
|
{ |
95 |
2 |
RichTextAreaElement richTextArea = contentEditor.getRichTextArea(); |
96 |
2 |
richTextArea.clear(); |
97 |
2 |
richTextArea.sendKeys(content); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
1 |
@Override... |
101 |
|
public String getContent() |
102 |
|
{ |
103 |
1 |
return contentEditor.getRichTextArea().getText(); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@param |
110 |
|
|
|
|
| 91.7% |
Uncovered Elements: 1 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
111 |
2 |
public void setCategories(List<String> categories)... |
112 |
|
{ |
113 |
2 |
for (String categoryName : categories) { |
114 |
3 |
String categoryReference = categoryName; |
115 |
3 |
if (categoryReference.indexOf('.') < 0) { |
116 |
3 |
categoryReference = "Blog." + categoryName; |
117 |
|
} |
118 |
3 |
String categoryXPath = |
119 |
|
"//input[@name = 'Blog.BlogPostClass_0_category' and @value = '" + categoryReference + "']"; |
120 |
3 |
for (WebElement category : categoryList.findElements(By.xpath(categoryXPath))) { |
121 |
3 |
if (!category.isSelected()) { |
122 |
2 |
category.click(); |
123 |
|
} |
124 |
|
} |
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
@return |
130 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
131 |
1 |
public List<String> getCategories()... |
132 |
|
{ |
133 |
1 |
List<String> categories = new ArrayList<String>(); |
134 |
1 |
for (WebElement category : categoryList.findElements(By |
135 |
|
.xpath("//input[@name = 'Blog.BlogPostClass_0_category']"))) { |
136 |
7 |
if (category.isSelected()) { |
137 |
1 |
categories.add(StringUtils.substringAfter(category.getAttribute("value"), ".")); |
138 |
|
} |
139 |
|
} |
140 |
1 |
return categories; |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
|
@return |
145 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
146 |
1 |
public boolean isPublished()... |
147 |
|
{ |
148 |
1 |
for (WebElement publishCheckBox : getDriver().findElements(By.id("Blog.BlogPostClass_0_published"))) { |
149 |
1 |
return publishCheckBox.isSelected(); |
150 |
|
} |
151 |
|
|
152 |
0 |
return true; |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@param |
159 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
160 |
1 |
public void setPublished(boolean published)... |
161 |
|
{ |
162 |
1 |
for (WebElement publishCheckBox : getDriver().findElements(By.id("Blog.BlogPostClass_0_published"))) { |
163 |
1 |
if (publishCheckBox.isSelected() != published) { |
164 |
1 |
publishCheckBox.click(); |
165 |
|
} |
166 |
|
} |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
|
@return |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0 |
public boolean isHidden()... |
173 |
|
{ |
174 |
0 |
return hiddenCheckBox.isSelected(); |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
@param |
181 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
182 |
0 |
public void setHidden(boolean hidden)... |
183 |
|
{ |
184 |
0 |
if (hiddenCheckBox.isSelected() != hidden) { |
185 |
0 |
hiddenCheckBox.click(); |
186 |
|
} |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
192 |
2 |
public void waitToLoad()... |
193 |
|
{ |
194 |
2 |
contentEditor.waitToLoad(); |
195 |
2 |
summaryEditor.waitToLoad(); |
196 |
|
} |
197 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
198 |
2 |
@Override... |
199 |
|
protected BlogPostViewPage createViewPage() |
200 |
|
{ |
201 |
2 |
return new BlogPostViewPage(); |
202 |
|
} |
203 |
|
} |