use of org.xwiki.test.mockito.StringReaderMatcher in project xwiki-platform by xwiki.
the class RenderingScriptServiceTest method parseAndRender.
@Test
public void parseAndRender() throws Exception {
Parser parser = this.mocker.registerMockComponent(Parser.class, "plain/1.0");
when(parser.parse(argThat(new StringReaderMatcher("some [[TODO]] stuff")))).thenReturn(new XDOM(Collections.<Block>emptyList()));
BlockRenderer blockRenderer = this.mocker.registerMockComponent(BlockRenderer.class, "xwiki/2.0");
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
WikiPrinter printer = (WikiPrinter) invocationOnMock.getArguments()[1];
printer.print("some ~[~[TODO]] stuff");
return null;
}
}).when(blockRenderer).render(any(XDOM.class), any());
XDOM xdom = this.mocker.getComponentUnderTest().parse("some [[TODO]] stuff", "plain/1.0");
assertEquals("some ~[~[TODO]] stuff", this.mocker.getComponentUnderTest().render(xdom, "xwiki/2.0"));
}
Aggregations