1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.administration.test.po; |
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.index.tree.test.po.DocumentPickerModal; |
28 |
|
import org.xwiki.model.EntityType; |
29 |
|
import org.xwiki.model.reference.EntityReference; |
30 |
|
import org.xwiki.test.ui.po.BaseElement; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
@since |
38 |
|
|
|
|
| 80% |
Uncovered Elements: 8 (40) |
Complexity: 11 |
Complexity Density: 0.39 |
|
39 |
|
public class LocationPicker extends BaseElement |
40 |
|
{ |
41 |
|
private String name; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
43 |
8 |
public LocationPicker(String name)... |
44 |
|
{ |
45 |
8 |
this.name = name; |
46 |
|
} |
47 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
48 |
2 |
public LocationPicker add(String value)... |
49 |
|
{ |
50 |
2 |
EntityReference spaceReference = getUtil().resolveSpaceReference(value); |
51 |
2 |
EntityReference wikiReference = spaceReference.extractReference(EntityType.WIKI); |
52 |
2 |
if (wikiReference != null) { |
53 |
2 |
spaceReference = spaceReference.removeParent(wikiReference); |
54 |
|
} |
55 |
2 |
EntityReference documentReference = new EntityReference("WebHome", EntityType.DOCUMENT, spaceReference); |
56 |
2 |
String[] path = |
57 |
|
documentReference.getReversedReferenceChain().stream().map(EntityReference::getName).toArray(String[]::new); |
58 |
2 |
browse().selectDocument(path); |
59 |
2 |
return waitToDisplayValue(value); |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
62 |
0 |
public LocationPicker remove(String value)... |
63 |
|
{ |
64 |
0 |
getRemoveButton(value).click(); |
65 |
0 |
return this; |
66 |
|
} |
67 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
68 |
2 |
public List<String> getValue()... |
69 |
|
{ |
70 |
2 |
List<String> values = new ArrayList<>(); |
71 |
2 |
for (WebElement path : getDriver() |
72 |
|
.findElementsWithoutWaiting(By.cssSelector(".path input[name='" + this.name + "'][value]"))) { |
73 |
0 |
values.add(path.getText()); |
74 |
|
} |
75 |
2 |
return values; |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
78 |
2 |
public LocationPicker setValue(List<String> values)... |
79 |
|
{ |
80 |
2 |
clear(); |
81 |
2 |
for (String value : values) { |
82 |
2 |
add(value); |
83 |
|
} |
84 |
2 |
return this; |
85 |
|
} |
86 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
87 |
2 |
public LocationPicker clear()... |
88 |
|
{ |
89 |
2 |
for (String value : getValue()) { |
90 |
0 |
remove(value); |
91 |
|
} |
92 |
2 |
return this; |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
95 |
2 |
public DocumentPickerModal browse()... |
96 |
|
{ |
97 |
2 |
getAddButton().click(); |
98 |
2 |
return new DocumentPickerModal(By.cssSelector(".location-picker.modal")).waitForIt(); |
99 |
|
} |
100 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
2 |
public WebElement getAddButton()... |
102 |
|
{ |
103 |
2 |
return getDriver() |
104 |
|
.findElementWithoutWaiting(By.cssSelector(".paths input[name='" + this.name + "'] + a[href='#path-add']")); |
105 |
|
} |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0 |
public WebElement getRemoveButton(String value)... |
108 |
|
{ |
109 |
0 |
return getDriver().findElementWithoutWaiting(By.xpath("//*[@class = 'paths']//input[@name = '" + this.name |
110 |
|
+ "' and @value = '" + value + "']/preceding-sibling::a[@class = 'path-delete']")); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
113 |
2 |
private LocationPicker waitToDisplayValue(String value)... |
114 |
|
{ |
115 |
2 |
getDriver().waitUntilElementIsVisible(By.xpath("//*[@class='path']/input[@name='" + this.name + "' and @value='" |
116 |
|
+ value + "']/following-sibling::*[@class='breadcrumb']/li[not(@class='loading')]")); |
117 |
2 |
return this; |
118 |
|
} |
119 |
|
} |