1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.internal.objects.classes

File DefaultDBListQueryBuilderTest.java

 

Code metrics

0
11
1
1
69
34
1
0.09
11
1
1

Classes

Class Line # Actions
DefaultDBListQueryBuilderTest 40 11 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

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 com.xpn.xwiki.internal.objects.classes;
21   
22    import org.junit.Rule;
23    import org.junit.Test;
24    import org.xwiki.component.util.DefaultParameterizedType;
25    import org.xwiki.query.Query;
26    import org.xwiki.query.QueryBuilder;
27    import org.xwiki.test.mockito.MockitoComponentMockingRule;
28   
29    import com.xpn.xwiki.objects.classes.DBListClass;
30   
31    import static org.junit.Assert.*;
32    import static org.mockito.Mockito.*;
33   
34    /**
35    * Unit tests for {@link DefaultDBListQueryBuilder}.
36    *
37    * @version $Id: 3a3a33f3fff62385d2714e2bfd10c3e66837a0e7 $
38    * @since 9.8RC1
39    */
 
40    public class DefaultDBListQueryBuilderTest
41    {
42    @Rule
43    public MockitoComponentMockingRule<QueryBuilder<DBListClass>> mocker =
44    new MockitoComponentMockingRule<QueryBuilder<DBListClass>>(DefaultDBListQueryBuilder.class);
45   
 
46  1 toggle @Test
47    public void build() throws Exception
48    {
49  1 DBListClass dbListClass = new DBListClass();
50   
51  1 DefaultParameterizedType dbListQueryBuilderType =
52    new DefaultParameterizedType(null, QueryBuilder.class, DBListClass.class);
53  1 QueryBuilder<DBListClass> explicitlyAllowedValuesQueryBuilder =
54    this.mocker.getInstance(dbListQueryBuilderType, "explicitlyAllowedValues");
55  1 QueryBuilder<DBListClass> implicitlyAllowedValuesQueryBuilder =
56    this.mocker.getInstance(dbListQueryBuilderType, "implicitlyAllowedValues");
57   
58  1 Query explicitlyAllowedValuesQuery = mock(Query.class, "explicit");
59  1 when(explicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(explicitlyAllowedValuesQuery);
60   
61  1 Query implicitlyAllowedValuesQuery = mock(Query.class, "implicit");
62  1 when(implicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(implicitlyAllowedValuesQuery);
63   
64  1 assertSame(implicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
65   
66  1 dbListClass.setSql("test");
67  1 assertSame(explicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
68    }
69    }