Search in sources :

Example 1 with DefaultScriptMacro

use of org.xwiki.rendering.internal.macro.script.DefaultScriptMacro in project xwiki-platform by xwiki.

the class NestedScriptMacroValidatorTest method configure.

@Before
public void configure() throws Exception {
    // Mock macro manager returns a script macro for "script" and null otherwise.
    final MacroManager macroManager = getComponentManager().getInstance(MacroManager.class);
    final ScriptMacro scriptMacro = new DefaultScriptMacro();
    final TestNestedScriptMacroEnabled nestedScriptMacroEnabled = new TestNestedScriptMacroEnabled();
    getMockery().checking(new Expectations() {

        {
            allowing(macroManager).getMacro(with(new MacroId("script")));
            will(returnValue(scriptMacro));
            allowing(macroManager).getMacro(with(new MacroId("nestedscriptmacroenabled")));
            will(returnValue(nestedScriptMacroEnabled));
            allowing(macroManager).getMacro(with(any(MacroId.class)));
            will(returnValue(null));
        }
    });
    this.validator = getComponentManager().getInstance(EventListener.class, "nestedscriptmacrovalidator");
}
Also used : Expectations(org.jmock.Expectations) DefaultScriptMacro(org.xwiki.rendering.internal.macro.script.DefaultScriptMacro) DefaultScriptMacro(org.xwiki.rendering.internal.macro.script.DefaultScriptMacro) MacroId(org.xwiki.rendering.macro.MacroId) MacroManager(org.xwiki.rendering.macro.MacroManager) EventListener(org.xwiki.observation.EventListener) Before(org.junit.Before)

Aggregations

Expectations (org.jmock.Expectations)1 Before (org.junit.Before)1 EventListener (org.xwiki.observation.EventListener)1 DefaultScriptMacro (org.xwiki.rendering.internal.macro.script.DefaultScriptMacro)1 MacroId (org.xwiki.rendering.macro.MacroId)1 MacroManager (org.xwiki.rendering.macro.MacroManager)1