use of org.xwiki.component.wiki.internal.bridge.ContentParser in project xwiki-platform by xwiki.
the class DefaultWikiComponentBridgeTest method getHandledMethods.
@Test
public void getHandledMethods() throws Exception {
final ComponentManager componentManager = getComponentManager().getInstance(ComponentManager.class);
final ContentParser contentParser = getComponentManager().getInstance(ContentParser.class);
final Parser parser = getMockery().mock(Parser.class);
final XDOM xdom = new XDOM(new ArrayList<Block>());
final BaseObject methodObject = getMockery().mock(BaseObject.class, "method");
final Vector<BaseObject> methodObjects = new Vector<BaseObject>();
methodObjects.add(methodObject);
getMockery().checking(new Expectations() {
{
oneOf(componentDoc).getObjectNumbers(METHOD_CLASS);
will(returnValue(1));
oneOf(componentDoc).getObjects(METHOD_CLASS);
will(returnValue(methodObjects));
allowing(methodObject).getStringValue(METHOD_NAME_FIELD);
will(returnValue("test"));
allowing(methodObject).getStringValue(METHOD_CODE_FIELD);
will(returnValue("test"));
oneOf(componentDoc).getSyntax();
will(returnValue(Syntax.XWIKI_2_1));
oneOf(contentParser).parse("test", Syntax.XWIKI_2_1, DOC_REFERENCE);
will(returnValue(xdom));
}
});
Assert.assertEquals(1, bridge.getHandledMethods(DOC_REFERENCE).size());
}
use of org.xwiki.component.wiki.internal.bridge.ContentParser in project xwiki-platform by xwiki.
the class WikiUIExtensionComponentBuilderTest method buildComponents.
@Test
public void buildComponents() throws Exception {
BaseObject extensionObject = createExtensionObject("name", "extensionPointId", "content", "key=value=foo\nkey2=value2\ninvalid=\n\n=invalid", "user");
ContentParser contentParser = this.mocker.getInstance(ContentParser.class);
VelocityManager velocityManager = this.mocker.getInstance(VelocityManager.class);
List<WikiComponent> components = this.mocker.getComponentUnderTest().buildComponents(extensionObject);
assertEquals(1, components.size());
verify(contentParser).parse("content", Syntax.XWIKI_2_1, DOC_REF);
UIExtension uiExtension = (UIExtension) components.get(0);
Map<String, String> parameters = uiExtension.getParameters();
assertEquals(2, parameters.size());
verify(velocityManager.getVelocityEngine()).evaluate(any(VelocityContext.class), any(StringWriter.class), eq("name:key"), eq("value=foo"));
verify(velocityManager.getVelocityEngine()).evaluate(any(VelocityContext.class), any(StringWriter.class), eq("name:key2"), eq("value2"));
}
use of org.xwiki.component.wiki.internal.bridge.ContentParser in project xwiki-platform by xwiki.
the class WikiUIExtensionRendererTest method setUp.
@Before
public void setUp() throws Exception {
execution = cm.registerMockComponent(Execution.class);
ExecutionContext executionContext = mock(ExecutionContext.class);
renderingContext = mock(MutableRenderingContext.class);
cm.registerComponent(RenderingContext.class, renderingContext);
cm.registerMockComponent(Transformation.class, "macro");
contentParser = cm.registerMockComponent(ContentParser.class);
when(execution.getContext()).thenReturn(executionContext);
xdom = mock(XDOM.class);
}
Aggregations