1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.internal.macro.chart.source.table

File MacroContentTableBlockDataSourceTest.java

 

Code metrics

0
13
3
1
71
40
6
0.46
4.33
3
2

Classes

Class Line # Actions
MacroContentTableBlockDataSourceTest 32 13 0% 6 3
0.812581.2%
 

Contributing tests

This file is covered by 3 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.rendering.internal.macro.chart.source.table;
21   
22    import org.junit.Assert;
23    import org.junit.Test;
24    import org.xwiki.rendering.macro.MacroExecutionException;
25   
26    /**
27    * Unit tests for {@link MacroContentTableBlockDataSource}.
28    *
29    * @version $Id: 32c33bac536c3d733ac22b9ce77b07150336b80c $
30    * @since 2.4M2
31    */
 
32    public class MacroContentTableBlockDataSourceTest extends AbstractMacroContentTableBlockDataSourceTest
33    {
 
34  1 toggle @Test
35    public void testGetTableBlockWhenNullMacroContent() throws Exception
36    {
37  1 try {
38  1 getDataSource().getTableBlock(null, null);
39  0 Assert.fail("Should have thrown an exception");
40    } catch (MacroExecutionException expected) {
41  1 Assert.assertEquals("A Chart Macro using an inline source must have a data table defined in its content.",
42    expected.getMessage());
43    }
44    }
45   
 
46  1 toggle @Test
47    public void testGetTableBlockWhenEmptyMacroContent() throws Exception
48    {
49  1 try {
50  1 getDataSource().getTableBlock("", null);
51  0 Assert.fail("Should have thrown an exception");
52    } catch (MacroExecutionException expected) {
53  1 Assert.assertEquals("A Chart Macro using an inline source must have a data table defined in its content.",
54    expected.getMessage());
55    }
56    }
57   
 
58  1 toggle @Test
59    public void testGetTableBlockWhenMacroContentDoesntContainTable() throws Exception
60    {
61    // Simulate a macro content of "not a table", i.e. not containing a table.
62  1 setUpContentExpectation("not a table");
63   
64  1 try {
65  1 getDataSource().getTableBlock("not a table", null);
66  0 Assert.fail("Should have thrown an exception");
67    } catch (MacroExecutionException expected) {
68  1 Assert.assertEquals("Unable to locate a suitable data table.", expected.getMessage());
69    }
70    }
71    }