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 static org.junit.Assert.*; |
23 |
|
|
24 |
|
import java.sql.Timestamp; |
25 |
|
import java.util.Date; |
26 |
|
|
27 |
|
import org.junit.Before; |
28 |
|
import org.junit.Rule; |
29 |
|
import org.junit.Test; |
30 |
|
import org.xwiki.model.internal.reference.LocalStringEntityReferenceSerializer; |
31 |
|
import org.xwiki.test.ComponentManagerRule; |
32 |
|
import org.xwiki.test.annotation.ComponentList; |
33 |
|
|
34 |
|
import com.xpn.xwiki.web.Utils; |
35 |
|
|
36 |
|
|
37 |
|
@link |
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@ComponentList({ |
43 |
|
LocalStringEntityReferenceSerializer.class |
44 |
|
}) |
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 4 |
Complexity Density: 0.31 |
|
45 |
|
public class DatePropertyTest |
46 |
|
{ |
47 |
|
@Rule |
48 |
|
public ComponentManagerRule componentManager = new ComponentManagerRule(); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
3 |
@Before... |
51 |
|
public void setUp() |
52 |
|
{ |
53 |
3 |
Utils.setComponentManager(this.componentManager); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void setValue() |
58 |
|
{ |
59 |
1 |
Date date = new Date(); |
60 |
1 |
DateProperty property = new DateProperty(); |
61 |
1 |
property.setValue(date); |
62 |
1 |
assertSame(date, property.getValue()); |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
|
@link |
67 |
|
|
68 |
|
@see |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void setValueWithExtendedDate() |
72 |
|
{ |
73 |
1 |
Timestamp timestamp = new Timestamp(new Date().getTime()); |
74 |
1 |
DateProperty property = new DateProperty(); |
75 |
1 |
property.setValue(timestamp); |
76 |
1 |
assertSame(Date.class, property.getValue().getClass()); |
77 |
1 |
assertEquals(timestamp.getTime(), ((Date) property.getValue()).getTime()); |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void setValueWithNullDate() |
85 |
|
{ |
86 |
1 |
DateProperty property = new DateProperty(); |
87 |
1 |
property.setValue(null); |
88 |
1 |
assertNull(property.getValue()); |
89 |
|
} |
90 |
|
} |