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

File DefaultPageQueryBuilderTest.java

 

Code metrics

0
8
1
1
74
37
1
0.12
8
1
1

Classes

Class Line # Actions
DefaultPageQueryBuilderTest 45 8 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 javax.inject.Named;
23   
24    import org.junit.jupiter.api.Test;
25    import org.xwiki.query.Query;
26    import org.xwiki.query.QueryBuilder;
27    import org.xwiki.test.junit5.mockito.ComponentTest;
28    import org.xwiki.test.junit5.mockito.InjectMockComponents;
29    import org.xwiki.test.junit5.mockito.MockComponent;
30   
31    import com.xpn.xwiki.objects.classes.DBListClass;
32    import com.xpn.xwiki.objects.classes.PageClass;
33   
34    import static org.junit.jupiter.api.Assertions.assertSame;
35    import static org.mockito.Mockito.mock;
36    import static org.mockito.Mockito.when;
37   
38    /**
39    * Unit tests for {@link DefaultPageQueryBuilder}.
40    *
41    * @version $Id: 6a8d722b91fe93847e777f10a3e9e700c4557e11 $
42    * @since 10.6
43    */
44    @ComponentTest
 
45    public class DefaultPageQueryBuilderTest
46    {
47    @InjectMockComponents
48    private DefaultPageQueryBuilder queryBuilder;
49   
50    @MockComponent
51    @Named("explicitlyAllowedValues")
52    private QueryBuilder<DBListClass> explicitlyAllowedValuesQueryBuilder;
53   
54    @MockComponent
55    @Named("implicitlyAllowedValues")
56    private QueryBuilder<PageClass> implicitlyAllowedValuesQueryBuilder;
57   
 
58  1 toggle @Test
59    public void build() throws Exception
60    {
61  1 PageClass pageClass = new PageClass();
62   
63  1 Query explicitlyAllowedValuesQuery = mock(Query.class, "explicit");
64  1 when(this.explicitlyAllowedValuesQueryBuilder.build(pageClass)).thenReturn(explicitlyAllowedValuesQuery);
65   
66  1 Query implicitlyAllowedValuesQuery = mock(Query.class, "implicit");
67  1 when(this.implicitlyAllowedValuesQueryBuilder.build(pageClass)).thenReturn(implicitlyAllowedValuesQuery);
68   
69  1 assertSame(implicitlyAllowedValuesQuery, this.queryBuilder.build(pageClass));
70   
71  1 pageClass.setSql("test");
72  1 assertSame(explicitlyAllowedValuesQuery, this.queryBuilder.build(pageClass));
73    }
74    }