| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.query.internal; |
| 21 |
|
|
| 22 |
|
import java.util.Arrays; |
| 23 |
|
import java.util.List; |
| 24 |
|
|
| 25 |
|
import org.junit.Rule; |
| 26 |
|
import org.junit.Test; |
| 27 |
|
import org.xwiki.query.Query; |
| 28 |
|
import org.xwiki.test.mockito.MockitoComponentMockingRule; |
| 29 |
|
|
| 30 |
|
import static org.junit.Assert.assertEquals; |
| 31 |
|
import static org.junit.Assert.assertSame; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@link |
| 35 |
|
|
| 36 |
|
@version |
| 37 |
|
@since |
| 38 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 39 |
|
public class LanguageQueryFilterTest |
| 40 |
|
{ |
| 41 |
|
@Rule |
| 42 |
|
public MockitoComponentMockingRule<LanguageQueryFilter> mocker = |
| 43 |
|
new MockitoComponentMockingRule<LanguageQueryFilter>(LanguageQueryFilter.class); |
| 44 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 45 |
1 |
@Test... |
| 46 |
|
public void filterStatementWhenStatementMatches() throws Exception |
| 47 |
|
{ |
| 48 |
1 |
String result = this.mocker.getComponentUnderTest().filterStatement( |
| 49 |
|
"select doc.fullName from XWikiDocument doc ...", Query.HQL); |
| 50 |
1 |
assertEquals("select doc.fullName, doc.language from XWikiDocument doc ...", result); |
| 51 |
|
} |
| 52 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 53 |
1 |
@Test... |
| 54 |
|
public void filterStatementWhenStatementDoesntMatches() throws Exception |
| 55 |
|
{ |
| 56 |
1 |
String result = this.mocker.getComponentUnderTest().filterStatement("select whatever", Query.HQL); |
| 57 |
1 |
assertEquals("select whatever", result); |
| 58 |
|
} |
| 59 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 60 |
1 |
@Test... |
| 61 |
|
public void filterStatementWhenStatementIsNotHQL() throws Exception |
| 62 |
|
{ |
| 63 |
1 |
String result = this.mocker.getComponentUnderTest().filterStatement( |
| 64 |
|
"select doc.fullName from XWikiDocument doc ...", Query.XWQL); |
| 65 |
1 |
assertEquals("select doc.fullName from XWikiDocument doc ...", result); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 68 |
1 |
@Test... |
| 69 |
|
public void ffilterResults() throws Exception |
| 70 |
|
{ |
| 71 |
1 |
List<String> items = Arrays.asList("one", "two"); |
| 72 |
1 |
List<String> result = this.mocker.getComponentUnderTest().filterResults(items); |
| 73 |
1 |
assertSame(items, result); |
| 74 |
|
} |
| 75 |
|
} |