1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.xar.internal.question; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.xwiki.extension.xar.question.ConflictQuestion; |
24 |
|
import org.xwiki.extension.xar.question.ConflictQuestion.GlobalAction; |
25 |
|
import org.xwiki.model.reference.DocumentReference; |
26 |
|
|
27 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
28 |
|
|
29 |
|
import static org.junit.Assert.*; |
30 |
|
import static org.mockito.Mockito.*; |
31 |
|
|
32 |
|
|
33 |
|
@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
|
38 |
|
public class ConflictQuestionRecorderTest |
39 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
40 |
1 |
@Test... |
41 |
|
public void recordAndReplay() |
42 |
|
{ |
43 |
1 |
XWikiDocument alice = mock(XWikiDocument.class, "Alice"); |
44 |
1 |
when(alice.getDocumentReference()).thenReturn(new DocumentReference("dev", "Users", "Alice")); |
45 |
1 |
ConflictQuestion aliceQuestion = new ConflictQuestion(null, null, alice, null); |
46 |
1 |
aliceQuestion.setGlobalAction(GlobalAction.CURRENT); |
47 |
|
|
48 |
1 |
XWikiDocument bob = mock(XWikiDocument.class, "Bob"); |
49 |
1 |
when(bob.getDocumentReference()).thenReturn(new DocumentReference("dev", "Users", "Bob")); |
50 |
1 |
ConflictQuestion bobQuestion = new ConflictQuestion(null, null, bob, null); |
51 |
1 |
bobQuestion.setGlobalAction(GlobalAction.PREVIOUS); |
52 |
1 |
bobQuestion.setAlways(true); |
53 |
|
|
54 |
1 |
ConflictQuestionRecorder recorder = new ConflictQuestionRecorder(); |
55 |
1 |
recorder.record(aliceQuestion); |
56 |
1 |
recorder.record(bobQuestion); |
57 |
|
|
58 |
1 |
XWikiDocument carol = mock(XWikiDocument.class, "Carol"); |
59 |
1 |
when(carol.getDocumentReference()).thenReturn(new DocumentReference("drafts", "Users", "Carol")); |
60 |
1 |
ConflictQuestion carolQuestion = new ConflictQuestion(null, null, carol, null); |
61 |
1 |
assertFalse(recorder.replay(carolQuestion)); |
62 |
1 |
assertEquals(GlobalAction.MERGED, carolQuestion.getGlobalAction()); |
63 |
1 |
assertFalse(carolQuestion.isAlways()); |
64 |
|
|
65 |
1 |
XWikiDocument aliceDrafts = mock(XWikiDocument.class, "AliceDrafts"); |
66 |
1 |
when(aliceDrafts.getDocumentReference()).thenReturn(new DocumentReference("drafts", "Users", "Alice")); |
67 |
1 |
ConflictQuestion aliceDraftsQuestion = new ConflictQuestion(null, null, aliceDrafts, null); |
68 |
1 |
assertTrue(recorder.replay(aliceDraftsQuestion)); |
69 |
1 |
assertEquals(GlobalAction.CURRENT, aliceDraftsQuestion.getGlobalAction()); |
70 |
1 |
assertFalse(aliceDraftsQuestion.isAlways()); |
71 |
|
|
72 |
1 |
XWikiDocument bobDrafts = mock(XWikiDocument.class, "BobDrafts"); |
73 |
1 |
when(bobDrafts.getDocumentReference()).thenReturn(new DocumentReference("drafts", "Users", "Bob")); |
74 |
1 |
ConflictQuestion bobDraftsQuestion = new ConflictQuestion(null, null, bobDrafts, null); |
75 |
1 |
assertTrue(recorder.replay(bobDraftsQuestion)); |
76 |
1 |
assertEquals(GlobalAction.PREVIOUS, bobDraftsQuestion.getGlobalAction()); |
77 |
1 |
assertTrue(bobDraftsQuestion.isAlways()); |
78 |
|
} |
79 |
|
} |