1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.objects; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.junit.Assert; |
26 |
|
import org.junit.Before; |
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.test.jmock.AbstractComponentTestCase; |
29 |
|
|
30 |
|
import com.xpn.xwiki.web.Utils; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 7 |
Complexity Density: 0.23 |
|
37 |
|
public class ListPropertyTest extends AbstractComponentTestCase |
38 |
|
{ |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
40 |
6 |
@Before... |
41 |
|
public void configure() throws Exception |
42 |
|
{ |
43 |
6 |
Utils.setComponentManager(getComponentManager()); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
46 |
1 |
@Test... |
47 |
|
public void dirtyFlagPropagation() throws Exception |
48 |
|
{ |
49 |
1 |
ListProperty p = new ListProperty(); |
50 |
|
|
51 |
1 |
p.setValueDirty(false); |
52 |
|
|
53 |
1 |
List<String> list = p.getList(); |
54 |
|
|
55 |
1 |
list.add("foo"); |
56 |
|
|
57 |
1 |
Assert.assertTrue(p.isValueDirty()); |
58 |
|
|
59 |
1 |
p.setValueDirty(false); |
60 |
|
|
61 |
1 |
p.setList(null); |
62 |
|
|
63 |
1 |
Assert.assertTrue(p.isValueDirty()); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
66 |
1 |
@Test... |
67 |
|
public void cloneListProperty() throws Exception |
68 |
|
{ |
69 |
1 |
ListProperty p = new ListProperty(); |
70 |
|
|
71 |
1 |
List<String> pList = p.getList(); |
72 |
|
|
73 |
1 |
p.setValueDirty(false); |
74 |
|
|
75 |
1 |
ListProperty clone = p.clone(); |
76 |
|
|
77 |
1 |
List<String> cloneList = clone.getList(); |
78 |
|
|
79 |
1 |
Assert.assertFalse(clone.isValueDirty()); |
80 |
|
|
81 |
1 |
cloneList.add("foo"); |
82 |
|
|
83 |
1 |
Assert.assertFalse(p.isValueDirty()); |
84 |
1 |
Assert.assertTrue(clone.isValueDirty()); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
90 |
1 |
@Test... |
91 |
|
public void getTextValue() |
92 |
|
{ |
93 |
1 |
ListProperty listProperty = new ListProperty(); |
94 |
1 |
listProperty.setValue(Arrays.asList("a<b>c", "1\"2'3", "x{y&z")); |
95 |
1 |
Assert.assertEquals("a<b>c|1\"2'3|x{y&z", listProperty.getTextValue()); |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
@link |
100 |
|
|
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
102 |
1 |
@Test... |
103 |
|
public void toText() |
104 |
|
{ |
105 |
1 |
ListProperty listProperty = new ListProperty(); |
106 |
1 |
listProperty.setValue(Arrays.asList("c<b>a", "3\"2'1", "z{y&x")); |
107 |
1 |
Assert.assertEquals("c<b>a|3\"2'1|z{y&x", listProperty.toText()); |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
@link |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
113 |
1 |
@Test... |
114 |
|
public void toFormString() |
115 |
|
{ |
116 |
1 |
ListProperty listProperty = new ListProperty(); |
117 |
1 |
listProperty.setValue(Arrays.asList("o<n>e", "t\"w'o", "t{h&ree")); |
118 |
1 |
Assert.assertEquals("o<n>e|t"w'o|t{h&ree", listProperty.toFormString()); |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
@link |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
124 |
1 |
@Test... |
125 |
|
public void toTextValuesWithEscapedSeparators() |
126 |
|
{ |
127 |
1 |
ListProperty listProperty = new ListProperty(); |
128 |
1 |
listProperty.setValue(Arrays.asList("a|b", "c|d", "e\\|f")); |
129 |
1 |
Assert.assertEquals("a\\|b|c\\|d|e\\\\|f", listProperty.toText()); |
130 |
|
} |
131 |
|
} |