use of org.xwiki.rendering.internal.transformation.macro.MacroTransformation in project xwiki-platform by xwiki.
the class CacheMacroTest method createMacroTransformationContext.
private MacroTransformationContext createMacroTransformationContext() throws Exception {
MacroTransformation macroTransformation = getComponentManager().getInstance(Transformation.class, "macro");
MacroTransformationContext context = new MacroTransformationContext();
context.setTransformation(macroTransformation);
context.setSyntax(Syntax.XWIKI_2_0);
return context;
}
use of org.xwiki.rendering.internal.transformation.macro.MacroTransformation in project xwiki-platform by xwiki.
the class IncludeMacroTest method runIncludeMacro.
private List<Block> runIncludeMacro(final Context context, String includedContent, boolean restricted) throws Exception {
final DocumentReference includedDocumentReference = new DocumentReference("wiki", "Space", "IncludedPage");
String includedDocStringRef = "wiki:space.page";
setUpDocumentMock(includedDocStringRef, includedDocumentReference, includedContent);
getMockery().checking(new Expectations() {
{
allowing(mockSetup.bridge).isDocumentViewable(with(same(includedDocumentReference)));
will(returnValue(true));
// Verify that push/pop are called when context is NEW
if (context == Context.NEW) {
oneOf(mockSetup.bridge).pushDocumentInContext(with(any(Map.class)), with(same(mockDocument)));
oneOf(mockSetup.bridge).getCurrentDocumentReference();
will(returnValue(includedDocumentReference));
oneOf(mockSetup.bridge).popDocumentFromContext(with(any(Map.class)));
} else {
oneOf(mockSetup.bridge).getCurrentDocumentReference();
will(returnValue(new DocumentReference("wiki", "Space", "IncludingPage")));
}
}
});
this.includeMacro.setDocumentAccessBridge(this.mockSetup.bridge);
IncludeMacroParameters parameters = new IncludeMacroParameters();
parameters.setReference(includedDocStringRef);
parameters.setContext(context);
// Create a Macro transformation context with the Macro transformation object defined so that the include
// macro can transform included page which is using a new context.
MacroTransformation macroTransformation = getComponentManager().getInstance(Transformation.class, "macro");
MacroTransformationContext macroContext = createMacroTransformationContext(includedDocStringRef, false);
macroContext.setId("wiki:Space.IncludingPage");
macroContext.setTransformation(macroTransformation);
macroContext.getTransformationContext().setRestricted(restricted);
return this.includeMacro.execute(parameters, null, macroContext);
}
use of org.xwiki.rendering.internal.transformation.macro.MacroTransformation in project xwiki-platform by xwiki.
the class DisplayMacroTest method runDisplayMacro.
private List<Block> runDisplayMacro(DisplayMacroParameters parameters, String displayedContent) throws Exception {
final DocumentReference displayedDocumentReference = new DocumentReference("wiki", "Space", "DisplayedPage");
String displayedDocStringRef = "wiki:space.page";
setUpDocumentMock(displayedDocStringRef, displayedDocumentReference, displayedContent);
getMockery().checking(new Expectations() {
{
allowing(mockSetup.bridge).isDocumentViewable(with(same(displayedDocumentReference)));
will(returnValue(true));
oneOf(mockSetup.bridge).pushDocumentInContext(with(any(Map.class)), with(same(mockDocument)));
atMost(1).of(mockSetup.bridge).getCurrentDocumentReference();
will(returnValue(displayedDocumentReference));
oneOf(mockSetup.bridge).popDocumentFromContext(with(any(Map.class)));
}
});
this.displayMacro.setDocumentAccessBridge(this.mockSetup.bridge);
parameters.setReference(displayedDocStringRef);
// Create a Macro transformation context with the Macro transformation object defined so that the display
// macro can transform displayed page which is using a new context.
MacroTransformation macroTransformation = (MacroTransformation) getComponentManager().getInstance(Transformation.class, "macro");
MacroTransformationContext macroContext = createMacroTransformationContext(displayedDocStringRef, false);
macroContext.setId("wiki:Space.DisplayingPage");
macroContext.setTransformation(macroTransformation);
return this.displayMacro.execute(parameters, null, macroContext);
}
Aggregations