@Test public void testGetTableBlockWhenMacroContentDoesntContainTable() throws Exception { setUpContentExpectation("not a table"); try { getDataSource().getTableBlock("not a table", null); Assert.fail("Should have thrown an exception"); } catch (MacroExecutionException expected) { Assert.assertEquals("Unable to locate a suitable data table.", expected.getMessage()); } }
@Override protected TableBlock getTableBlock(String macroContent, MacroTransformationContext context) throws MacroExecutionException { if (StringUtils.isEmpty(macroContent)) { throw new MacroExecutionException("A Chart Macro using an inline source must have a data table defined in " + "its content."); } XDOM xdom = this.macroContentParser.parse(macroContent, context, true, false); List<TableBlock> tableBlocks = xdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT); if (tableBlocks.size() == 0) { throw new MacroExecutionException("Unable to locate a suitable data table."); } return tableBlocks.get(0); }
MacroContentTableBlockDataSource extends AbstractTableBlockDataSource { @Override protected TableBlock getTableBlock(String macroContent, MacroTransformationContext context) throws MacroExecutionException { if (StringUtils.isEmpty(macroContent)) { throw new MacroExecutionException("A Chart Macro using an inline source must have a data table defined in " + "its content."); } XDOM xdom = this.macroContentParser.parse(macroContent, context, true, false); List<TableBlock> tableBlocks = xdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT); if (tableBlocks.size() == 0) { throw new MacroExecutionException("Unable to locate a suitable data table."); } return tableBlocks.get(0); } }
MacroContentTableBlockDataSource extends AbstractTableBlockDataSource { @Override protected TableBlock getTableBlock(String macroContent, MacroTransformationContext context) throws MacroExecutionException { if (StringUtils.isEmpty(macroContent)) { throw new MacroExecutionException("A Chart Macro using an inline source must have a data table defined in " + "its content."); } XDOM xdom = this.macroContentParser.parse(macroContent, context, true, false); List<TableBlock> tableBlocks = xdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT); if (tableBlocks.size() == 0) { throw new MacroExecutionException("Unable to locate a suitable data table."); } return tableBlocks.get(0); }  }
MacroContentTableBlockDataSource extends AbstractTableBlockDataSource { @Override protected TableBlock getTableBlock(String macroContent, MacroTransformationContext context) throws MacroExecutionException { if (StringUtils.isEmpty(macroContent)) { throw new MacroExecutionException("A Chart Macro using an inline source must have a data table defined in " + "its content."); } XDOM xdom = this.macroContentParser.parse(macroContent, context, true, false); List<TableBlock> tableBlocks = xdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT); if (tableBlocks.size() == 0) { throw new MacroExecutionException("Unable to locate a suitable data table."); } return tableBlocks.get(0); }   }
MacroContentTableBlockDataSource extends AbstractTableBlockDataSource { @Override protected TableBlock getTableBlock(String macroContent, MacroTransformationContext context) throws MacroExecutionException { if (StringUtils.isEmpty(macroContent)) { throw new MacroExecutionException("A Chart Macro using an inline source must have a data table defined in " + "its content."); } XDOM xdom = this.macroContentParser.parse(macroContent, context, true, false); List<TableBlock> tableBlocks = xdom.getBlocks(new ClassBlockMatcher(TableBlock.class), Block.Axes.DESCENDANT); if (tableBlocks.size() == 0) { throw new MacroExecutionException("Unable to locate a suitable data table."); } return tableBlocks.get(0); }    }