1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.lesscss.internal.resources; |
21 |
|
|
22 |
|
import org.junit.Before; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
25 |
|
import org.xwiki.model.reference.DocumentReference; |
26 |
|
import org.xwiki.model.reference.EntityReferenceSerializer; |
27 |
|
import org.xwiki.model.reference.ObjectPropertyReference; |
28 |
|
import org.xwiki.model.reference.ObjectReference; |
29 |
|
|
30 |
|
import static org.junit.Assert.assertEquals; |
31 |
|
import static org.mockito.ArgumentMatchers.eq; |
32 |
|
import static org.mockito.Mockito.mock; |
33 |
|
import static org.mockito.Mockito.when; |
34 |
|
|
35 |
|
|
36 |
|
@link |
37 |
|
|
38 |
|
@since |
39 |
|
@version |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.3 |
|
41 |
|
public class LESSObjectPropertyResourceReferenceTest |
42 |
|
{ |
43 |
|
private EntityReferenceSerializer<String> entityReferenceSerializer; |
44 |
|
|
45 |
|
private DocumentAccessBridge bridge; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
47 |
2 |
@Before... |
48 |
|
public void SetUp() throws Exception |
49 |
|
{ |
50 |
2 |
entityReferenceSerializer = mock(EntityReferenceSerializer.class); |
51 |
2 |
bridge = mock(DocumentAccessBridge.class); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
54 |
1 |
@Test... |
55 |
|
public void getContent() throws Exception |
56 |
|
{ |
57 |
1 |
ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property", |
58 |
|
new ObjectReference("class", new DocumentReference("wiki", "Space", "Document"))); |
59 |
1 |
LESSObjectPropertyResourceReference lessObjectPropertyResourceReference |
60 |
|
= new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge); |
61 |
|
|
62 |
|
|
63 |
1 |
when(bridge.getProperty(eq(objectPropertyReference))).thenReturn("content"); |
64 |
|
|
65 |
|
|
66 |
1 |
assertEquals("content", lessObjectPropertyResourceReference.getContent("skin")); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void serialize() throws Exception |
71 |
|
{ |
72 |
1 |
ObjectPropertyReference objectPropertyReference = new ObjectPropertyReference("property", |
73 |
|
new ObjectReference("class", new DocumentReference("wiki", "Space", "Document"))); |
74 |
1 |
LESSObjectPropertyResourceReference lessObjectPropertyResourceReference |
75 |
|
= new LESSObjectPropertyResourceReference(objectPropertyReference, entityReferenceSerializer, bridge); |
76 |
|
|
77 |
|
|
78 |
1 |
when(entityReferenceSerializer.serialize(eq(objectPropertyReference))).thenReturn("objPropertyRef"); |
79 |
|
|
80 |
|
|
81 |
1 |
assertEquals("LessXObjectProperty[objPropertyRef]", lessObjectPropertyResourceReference.serialize()); |
82 |
|
} |
83 |
|
} |