1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.doc; |
21 |
|
|
22 |
|
import static org.junit.Assert.*; |
23 |
|
import static org.mockito.Mockito.*; |
24 |
|
|
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Test; |
27 |
|
import org.suigeneris.jrcs.rcs.Archive; |
28 |
|
import org.suigeneris.jrcs.rcs.Version; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 6 |
Complexity Density: 0.4 |
|
35 |
|
public class XWikiAttachmentArchiveTest |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
private XWikiAttachmentArchive archive = new XWikiAttachmentArchive(); |
41 |
|
|
42 |
|
private XWikiAttachment attachment = mock(XWikiAttachment.class); |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
44 |
5 |
@Before... |
45 |
|
public void setUp() |
46 |
|
{ |
47 |
5 |
archive.setAttachment(attachment); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void getVersionsWhenThereIsNoHistory() |
52 |
|
{ |
53 |
1 |
Version version = new Version(3, 4); |
54 |
1 |
when(attachment.getRCSVersion()).thenReturn(version); |
55 |
|
|
56 |
1 |
assertArrayEquals(new Version[] {version}, archive.getVersions()); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
public void getVersions() throws Exception |
61 |
|
{ |
62 |
1 |
Archive rcsArchive = new Archive(new Object[] {"line"}, "file.txt", "5.2"); |
63 |
1 |
rcsArchive.addRevision(new Object[] {"line modified"}, ""); |
64 |
1 |
archive.setRCSArchive(rcsArchive); |
65 |
|
|
66 |
1 |
assertArrayEquals(new Version[] {new Version(5, 2), new Version(5, 3)}, archive.getVersions()); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void getCurrentRevisionWhenThereIsNoHistory() throws Exception |
71 |
|
{ |
72 |
1 |
String version = "1.3"; |
73 |
1 |
when(attachment.getVersion()).thenReturn(version); |
74 |
|
|
75 |
1 |
assertEquals(attachment, archive.getRevision(null, version, null)); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
78 |
1 |
@Test... |
79 |
|
public void getRevisionWhenThereIsNoHistory() throws Exception |
80 |
|
{ |
81 |
1 |
when(attachment.getVersion()).thenReturn("1.1"); |
82 |
|
|
83 |
1 |
assertNull(archive.getRevision(null, "2.7", null)); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
86 |
1 |
@Test... |
87 |
|
public void getRevisionWhichDoesNotExist() throws Exception |
88 |
|
{ |
89 |
1 |
archive.setRCSArchive(new Archive(new Object[] {"text"}, "file.txt", "1.2")); |
90 |
|
|
91 |
1 |
assertNull(archive.getRevision(null, "7.2", null)); |
92 |
|
} |
93 |
|
} |