### Question:
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); }    }### Answer:
@Test public void testGetTableBlockWhenNullMacroContent() throws Exception { try { getDataSource().getTableBlock(null, null); Assert.fail("Should have thrown an exception"); } catch (MacroExecutionException expected) { Assert.assertEquals("A Chart Macro using an inline source must have a data table defined in its content.", expected.getMessage()); } }
@Test public void testGetTableBlockWhenEmptyMacroContent() throws Exception { try { getDataSource().getTableBlock("", null); Assert.fail("Should have thrown an exception"); } catch (MacroExecutionException expected) { Assert.assertEquals("A Chart Macro using an inline source must have a data table defined in its content.", expected.getMessage()); } }
@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()); } }