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

File QueryExceptionTest.java

 

Code metrics

0
14
2
1
64
31
2
0.14
7
2
1

Classes

Class Line # Actions
QueryExceptionTest 35 14 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 2 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 org.junit.Test;
23    import org.xwiki.query.Query;
24    import org.xwiki.query.QueryException;
25   
26    import static org.junit.Assert.assertEquals;
27    import static org.mockito.Mockito.*;
28   
29    /**
30    * Unit tests for {@link org.xwiki.query.QueryException}
31    *
32    * @version $Id: bb9d12cecb0a2c976ccbe62b84e47bffd88928ce $
33    * @since 6.1M1
34    */
 
35    public class QueryExceptionTest
36    {
 
37  1 toggle @Test
38    public void getMessageWhenStatement()
39    {
40  1 Query query = mock(Query.class);
41  1 when(query.isNamed()).thenReturn(false);
42  1 when(query.getStatement()).thenReturn("statement");
43   
44  1 Exception nestedException = mock(Exception.class);
45  1 when(nestedException.getMessage()).thenReturn("nestedmessage");
46   
47  1 QueryException queryException = new QueryException("message", query, nestedException);
48  1 assertEquals("message. Query statement = [statement]", queryException.getMessage());
49    }
50   
 
51  1 toggle @Test
52    public void getMessageWhenNamedQuery()
53    {
54  1 Query query = mock(Query.class);
55  1 when(query.isNamed()).thenReturn(true);
56  1 when(query.getStatement()).thenReturn("namedquery");
57   
58  1 Exception nestedException = mock(Exception.class);
59  1 when(nestedException.getMessage()).thenReturn("nestedmessage");
60   
61  1 QueryException queryException = new QueryException("message", query, nestedException);
62  1 assertEquals("message. Named query = [namedquery]", queryException.getMessage());
63    }
64    }