@Test public void executeWhenTransformationException() throws Exception { XDOM parsedBlocks = new XDOM(Collections.emptyList()); ContentParser contentParser = this.mocker.getInstance(ContentParser.class); when(contentParser.parse("", Syntax.PLAIN_1_0)).thenReturn(parsedBlocks); TransformationContext transformationContext = new TransformationContext(); MacroTransformationContext context = new MacroTransformationContext(transformationContext); Transformation macroTransformation = this.mocker.getInstance(Transformation.class, "macro"); doThrow(new TransformationException("error")) .when(macroTransformation).transform(parsedBlocks, transformationContext); try { this.mocker.getComponentUnderTest().execute("", Syntax.PLAIN_1_0, context); fail("Should have raised a ContentExecutorException"); } catch (ContentExecutorException expected) { assertEquals("Failed to execute content", expected.getMessage()); } }
@Override public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) throws ParseException, MissingParserException, ContentExecutorException { XDOM xdom = this.contentParser.parse(content, syntax); executeContent(xdom, macroContext); return xdom; }
MacroContentExecutor implements ContentExecutor<MacroTransformationContext> { @Override public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) throws ParseException, MissingParserException, ContentExecutorException { XDOM xdom = this.contentParser.parse(content, syntax); executeContent(xdom, macroContext); return xdom; } }
MacroContentExecutor implements ContentExecutor<MacroTransformationContext> { @Override public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) throws ParseException, MissingParserException, ContentExecutorException { XDOM xdom = this.contentParser.parse(content, syntax); executeContent(xdom, macroContext); return xdom; }  }
MacroContentExecutor implements ContentExecutor<MacroTransformationContext> { @Override public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) throws ParseException, MissingParserException, ContentExecutorException { XDOM xdom = this.contentParser.parse(content, syntax); executeContent(xdom, macroContext); return xdom; }  @Override XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext); @Override XDOM execute(String content, Syntax syntax, EntityReference source, MacroTransformationContext macroContext); }
MacroContentExecutor implements ContentExecutor<MacroTransformationContext> { @Override public XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext) throws ParseException, MissingParserException, ContentExecutorException { XDOM xdom = this.contentParser.parse(content, syntax); executeContent(xdom, macroContext); return xdom; }  @Override XDOM execute(String content, Syntax syntax, MacroTransformationContext macroContext); @Override XDOM execute(String content, Syntax syntax, EntityReference source, MacroTransformationContext macroContext);  }