1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.query.internal

File LanguageQueryFilterTest.java

 

Code metrics

0
9
4
1
75
42
4
0.44
2.25
4
1

Classes

Class Line # Actions
LanguageQueryFilterTest 39 9 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
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    * Tests for {@link org.xwiki.query.internal.LanguageQueryFilter}
35    *
36    * @version $Id: 60895997ca64f5c164fe86aaa114d6cf540a97a9 $
37    * @since 5.1M2
38    */
 
39    public class LanguageQueryFilterTest
40    {
41    @Rule
42    public MockitoComponentMockingRule<LanguageQueryFilter> mocker =
43    new MockitoComponentMockingRule<LanguageQueryFilter>(LanguageQueryFilter.class);
44   
 
45  1 toggle @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   
 
53  1 toggle @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   
 
60  1 toggle @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   
 
68  1 toggle @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    }