1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui.po.diff; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.xwiki.test.ui.po.BaseElement; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 80.4% |
Uncovered Elements: 10 (51) |
Complexity: 21 |
Complexity Density: 0.7 |
|
35 |
|
public class DocumentDiffSummary extends BaseElement |
36 |
|
{ |
37 |
|
private static final String PAGE_PROPERTIES = "Page properties"; |
38 |
|
|
39 |
|
private static final String ATTACHMENTS = "Attachments"; |
40 |
|
|
41 |
|
private static final String OBJECTS = "Objects"; |
42 |
|
|
43 |
|
private static final String CLASS_PROPERTIES = "Class properties"; |
44 |
|
|
45 |
|
private static final String ACTION_CHANGE = "change"; |
46 |
|
|
47 |
|
private static final String ACTION_INSERT = "insert"; |
48 |
|
|
49 |
|
private static final String ACTION_DELETE = "delete"; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private WebElement container; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
2 |
public DocumentDiffSummary(WebElement container)... |
62 |
|
{ |
63 |
2 |
this.container = container; |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
66 |
1 |
public List<String> getItems()... |
67 |
|
{ |
68 |
1 |
List<WebElement> items = |
69 |
|
getDriver().findElementsWithoutWaiting(this.container, By.xpath(".//div[@class = 'diff-summary-item']/a")); |
70 |
1 |
List<String> labels = new ArrayList<>(); |
71 |
1 |
for (WebElement item : items) { |
72 |
4 |
labels.add(item.getText()); |
73 |
|
} |
74 |
1 |
return labels; |
75 |
|
} |
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
1 |
public String getPagePropertiesSummary()... |
78 |
|
{ |
79 |
1 |
return getSummaryItemHint(PAGE_PROPERTIES); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
1 |
public String getAttachmentsSummary()... |
83 |
|
{ |
84 |
1 |
return getSummaryItemHint(ATTACHMENTS); |
85 |
|
} |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
1 |
public DocumentDiffSummary toggleAttachmentsDetails()... |
88 |
|
{ |
89 |
1 |
return toggleDetails(ATTACHMENTS); |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
public List<String> getModifiedAttachments()... |
93 |
|
{ |
94 |
0 |
return getSummaryItemDetails(ATTACHMENTS, ACTION_CHANGE); |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
1 |
public List<String> getAddedAttachments()... |
98 |
|
{ |
99 |
1 |
return getSummaryItemDetails(ATTACHMENTS, ACTION_INSERT); |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0 |
public List<String> getRemovedAttachments()... |
103 |
|
{ |
104 |
0 |
return getSummaryItemDetails(ATTACHMENTS, ACTION_DELETE); |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
1 |
public String getObjectsSummary()... |
108 |
|
{ |
109 |
1 |
return getSummaryItemHint(OBJECTS); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
2 |
public DocumentDiffSummary toggleObjectsDetails()... |
113 |
|
{ |
114 |
2 |
return toggleDetails(OBJECTS); |
115 |
|
} |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
117 |
1 |
public List<String> getModifiedObjects()... |
118 |
|
{ |
119 |
1 |
return getSummaryItemDetails(OBJECTS, ACTION_CHANGE); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
122 |
1 |
public List<String> getAddedObjects()... |
123 |
|
{ |
124 |
1 |
return getSummaryItemDetails(OBJECTS, ACTION_INSERT); |
125 |
|
} |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
public List<String> getRemovedObjects()... |
128 |
|
{ |
129 |
0 |
return getSummaryItemDetails(OBJECTS, ACTION_DELETE); |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
1 |
public String getClassPropertiesSummary()... |
133 |
|
{ |
134 |
1 |
return getSummaryItemHint(CLASS_PROPERTIES); |
135 |
|
} |
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
1 |
public DocumentDiffSummary toggleClassPropertiesDetails()... |
138 |
|
{ |
139 |
1 |
return toggleDetails(CLASS_PROPERTIES); |
140 |
|
} |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0 |
public List<String> getModifiedClassProperties()... |
143 |
|
{ |
144 |
0 |
return getSummaryItemDetails(CLASS_PROPERTIES, ACTION_CHANGE); |
145 |
|
} |
146 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
147 |
1 |
public List<String> getAddedClassProperties()... |
148 |
|
{ |
149 |
1 |
return getSummaryItemDetails(CLASS_PROPERTIES, ACTION_INSERT); |
150 |
|
} |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0 |
public List<String> getRemovedClassProperties()... |
153 |
|
{ |
154 |
0 |
return getSummaryItemDetails(CLASS_PROPERTIES, ACTION_DELETE); |
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
4 |
private String getSummaryItemHint(String label)... |
158 |
|
{ |
159 |
4 |
return this.container.findElement( |
160 |
|
By.xpath(".//span[@class = 'diff-summary-item-hint' and preceding-sibling::a[. = '" + label + "']]")) |
161 |
|
.getText(); |
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
164 |
4 |
private List<String> getSummaryItemDetails(String label, String action)... |
165 |
|
{ |
166 |
4 |
List<WebElement> elements = |
167 |
|
getDriver().findElementsWithoutWaiting( |
168 |
|
this.container, |
169 |
|
By.xpath(".//li[@class = 'diff-summary-item' and child::span[@class = 'diff-icon diff-icon-" + action |
170 |
|
+ "'] and parent::ul/preceding-sibling::div[1]/a[. = '" + label + "']]")); |
171 |
4 |
List<String> labels = new ArrayList<>(); |
172 |
4 |
for (WebElement element : elements) { |
173 |
5 |
labels.add(element.getText().trim()); |
174 |
|
} |
175 |
4 |
return labels; |
176 |
|
} |
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
178 |
4 |
private DocumentDiffSummary toggleDetails(String label)... |
179 |
|
{ |
180 |
4 |
this.container.findElement(By.xpath(".//div[@class = 'diff-summary-item']/a[. = '" + label + "']")).click(); |
181 |
4 |
return this; |
182 |
|
} |
183 |
|
} |