use of org.xwiki.rendering.macro.MacroManager in project xwiki-platform by xwiki.
the class RenderingScriptServiceTest method getMacroDescriptors.
@Test
public void getMacroDescriptors() throws Exception {
MacroManager macroManager = this.mocker.registerMockComponent(MacroManager.class);
MacroId macroId = new MacroId("macroid");
when(macroManager.getMacroIds(Syntax.XWIKI_2_1)).thenReturn(Collections.singleton(macroId));
Macro macro = mock(Macro.class);
when(macroManager.getMacro(macroId)).thenReturn(macro);
MacroDescriptor descriptor = mock(MacroDescriptor.class);
when(macro.getDescriptor()).thenReturn(descriptor);
List<MacroDescriptor> descriptors = this.mocker.getComponentUnderTest().getMacroDescriptors(Syntax.XWIKI_2_1);
assertEquals(1, descriptors.size());
assertSame(descriptor, descriptors.get(0));
}
use of org.xwiki.rendering.macro.MacroManager 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");
}
use of org.xwiki.rendering.macro.MacroManager in project xwiki-platform by xwiki.
the class VelocityMacroSecurityTest method setUp.
@Before
public void setUp() throws Exception {
authorizationManager = mocker.registerMockComponent(ContextualAuthorizationManager.class);
BeanDescriptor mockBeanDescriptor = mock(BeanDescriptor.class);
when(mockBeanDescriptor.getProperties()).thenReturn(Collections.EMPTY_LIST);
BeanManager beanManager = mocker.getInstance(BeanManager.class);
when(beanManager.getBeanDescriptor(any(Class.class))).thenReturn(mockBeanDescriptor);
Macro velocityMacro = mocker.getComponentUnderTest();
MacroManager mockMacroManager = mocker.registerMockComponent(MacroManager.class);
when(mockMacroManager.getMacro(any(MacroId.class))).thenReturn(velocityMacro);
}
Aggregations