1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.internal.query; |
21 |
|
|
22 |
|
import java.util.Locale; |
23 |
|
|
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.context.Execution; |
27 |
|
import org.xwiki.context.ExecutionContext; |
28 |
|
import org.xwiki.query.Query; |
29 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
30 |
|
|
31 |
|
import com.xpn.xwiki.XWikiContext; |
32 |
|
|
33 |
|
import static org.junit.Assert.assertEquals; |
34 |
|
import static org.mockito.Mockito.any; |
35 |
|
import static org.mockito.Mockito.mock; |
36 |
|
import static org.mockito.Mockito.when; |
37 |
|
|
38 |
|
|
39 |
|
@link |
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.1 |
|
44 |
|
public class CurrentLanguageQueryFilterTest |
45 |
|
{ |
46 |
|
@Rule |
47 |
|
public MockitoComponentMockingRule<CurrentLanguageQueryFilter> mocker = |
48 |
|
new MockitoComponentMockingRule<CurrentLanguageQueryFilter>(CurrentLanguageQueryFilter.class); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
50 |
1 |
@Test... |
51 |
|
public void filterStatement() throws Exception |
52 |
|
{ |
53 |
1 |
Execution execution = this.mocker.getInstance(Execution.class); |
54 |
1 |
ExecutionContext executionContext = mock(ExecutionContext.class); |
55 |
1 |
when(execution.getContext()).thenReturn(executionContext); |
56 |
1 |
XWikiContext xwikiContext = mock(XWikiContext.class); |
57 |
1 |
when(executionContext.getProperty("xwikicontext")).thenReturn(xwikiContext); |
58 |
1 |
com.xpn.xwiki.XWiki xwiki = mock(com.xpn.xwiki.XWiki.class); |
59 |
1 |
when(xwikiContext.getWiki()).thenReturn(xwiki); |
60 |
1 |
when(xwiki.getDefaultLocale(any(XWikiContext.class))).thenReturn(Locale.FRANCE); |
61 |
|
|
62 |
1 |
String result = this.mocker.getComponentUnderTest().filterStatement( |
63 |
|
"select doc.fullName from XWikiDocument doc where 1=1", Query.HQL); |
64 |
1 |
assertEquals("select doc.fullName from XWikiDocument doc where (doc.language is null or doc.language = '' or " |
65 |
|
+ "doc.language = 'fr_FR') and (1=1)", result); |
66 |
|
} |
67 |
|
} |