Search in sources :

Example 11 with ModelContext

use of org.xwiki.model.ModelContext in project xwiki-platform by xwiki.

the class WikiUIExtensionComponentBuilderTest method configure.

@Before
public void configure() throws Exception {
    // Required by BaseObjectReference
    DocumentReferenceResolver<String> resolver = this.mocker.registerMockComponent(DocumentReferenceResolver.TYPE_STRING);
    when(resolver.resolve("XWiki.UIExtension")).thenReturn(new DocumentReference("xwiki", "XWiki", "UIExtensionClass"));
    DelegateComponentManager wikiComponentManager = new DelegateComponentManager();
    wikiComponentManager.setComponentManager(this.mocker);
    this.mocker.registerComponent(ComponentManager.class, "wiki", wikiComponentManager);
    // Components accessed through dynamic lookup.
    VelocityManager velocityManager = this.mocker.registerMockComponent(VelocityManager.class);
    when(velocityManager.getVelocityEngine()).thenReturn(mock(VelocityEngine.class));
    when(velocityManager.getVelocityContext()).thenReturn(mock(VelocityContext.class));
    ModelContext modelContext = this.mocker.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(DOC_REF);
    this.mocker.registerMockComponent(RenderingContext.class);
    this.mocker.registerMockComponent(Transformation.class, "macro");
    this.mocker.registerMockComponent(ContentParser.class);
    // The document holding the UI extension object.
    this.componentDoc = mock(XWikiDocument.class, "xwiki:XWiki.MyUIExtension");
    when(this.componentDoc.getDocumentReference()).thenReturn(DOC_REF);
    when(this.componentDoc.getAuthorReference()).thenReturn(AUTHOR_REFERENCE);
    when(this.componentDoc.getContentAuthorReference()).thenReturn(AUTHOR_REFERENCE);
    when(this.componentDoc.getSyntax()).thenReturn(Syntax.XWIKI_2_1);
    this.oldcore.getDocuments().put(DOC_REF, componentDoc);
}
Also used : ModelContext(org.xwiki.model.ModelContext) VelocityEngine(org.xwiki.velocity.VelocityEngine) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) VelocityManager(org.xwiki.velocity.VelocityManager) VelocityContext(org.apache.velocity.VelocityContext) DelegateComponentManager(org.xwiki.component.internal.multi.DelegateComponentManager) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 12 with ModelContext

use of org.xwiki.model.ModelContext in project xwiki-platform by xwiki.

the class WikiUIExtensionParametersTest method setUp.

@Before
public void setUp() throws Exception {
    VelocityManager velocityManager = componentManager.registerMockComponent(VelocityManager.class);
    execution = componentManager.registerMockComponent(Execution.class);
    modelContext = componentManager.registerMockComponent(ModelContext.class);
    velocityEngine = mock(VelocityEngine.class);
    velocityContext = new VelocityContext();
    ExecutionContext executionContext = mock(ExecutionContext.class);
    when(execution.getContext()).thenReturn(executionContext);
    when(velocityManager.getVelocityContext()).thenReturn(velocityContext);
    when(velocityManager.getVelocityEngine()).thenReturn(velocityEngine);
}
Also used : ModelContext(org.xwiki.model.ModelContext) VelocityEngine(org.xwiki.velocity.VelocityEngine) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) VelocityManager(org.xwiki.velocity.VelocityManager) VelocityContext(org.apache.velocity.VelocityContext) Before(org.junit.Before)

Aggregations

ModelContext (org.xwiki.model.ModelContext)12 WikiReference (org.xwiki.model.reference.WikiReference)7 ExecutionContext (org.xwiki.context.ExecutionContext)5 DocumentReference (org.xwiki.model.reference.DocumentReference)5 Test (org.junit.Test)4 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)4 XWikiContext (com.xpn.xwiki.XWikiContext)3 Properties (java.util.Properties)3 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)3 EnvironmentConfiguration (org.xwiki.environment.internal.EnvironmentConfiguration)3 Copier (org.xwiki.mail.internal.thread.context.Copier)3 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)3 VelocityContext (org.apache.velocity.VelocityContext)2 Before (org.junit.Before)2 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)2 Execution (org.xwiki.context.Execution)2 XDOM (org.xwiki.rendering.block.XDOM)2 ChartMacroParameters (org.xwiki.rendering.macro.chart.ChartMacroParameters)2 Parser (org.xwiki.rendering.parser.Parser)2 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)2