Search in sources :

Example 26 with WikiDescriptorManager

use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.

the class WebJarsScriptServiceTest method computeJavaScriptURLWithSuffixAndNoParameters.

@Test
public void computeJavaScriptURLWithSuffixAndNoParameters() throws Exception {
    WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
    when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
    WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "angular.js"));
    resourceReference.addParameter("r", "1");
    when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "angular.js"), resourceReference.getParameters()));
    assertEquals("/xwiki/angular/angular.js?r=1", this.mocker.getComponentUnderTest().url("angular", "angular.js"));
}
Also used : WebJarsResourceReference(org.xwiki.webjars.internal.WebJarsResourceReference) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ExtendedURL(org.xwiki.url.ExtendedURL) Test(org.junit.Test)

Example 27 with WikiDescriptorManager

use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.

the class DefaultNotificationEmailUserPreferenceManagerTest method setUp.

@Before
public void setUp() throws Exception {
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    referenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING);
    wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
    when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
    currentUser = new DocumentReference("someWiki", "XWiki", "User");
    when(documentAccessBridge.getCurrentUserReference()).thenReturn(currentUser);
}
Also used : WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 28 with WikiDescriptorManager

use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.

the class SolrReferenceResolverTest method registerComponents.

@BeforeComponent
public void registerComponents() throws Exception {
    this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    this.mocker.registerMockComponent(QueryManager.class);
    WikiDescriptorManager wikiDescriptorManager = this.mocker.registerMockComponent(WikiDescriptorManager.class);
    when(wikiDescriptorManager.getAllIds()).thenReturn(Arrays.asList(wikiReference1.getName(), wikiReference2.getName()));
}
Also used : WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 29 with WikiDescriptorManager

use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.

the class WikiTemplateMigrationTest method setUp.

@Before
public void setUp() throws Exception {
    wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
    queryManager = mocker.getInstance(QueryManager.class);
    // documentReferenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING, "current");
    documentReferenceResolver = mocker.getInstance(new DefaultParameterizedType(null, DocumentReferenceResolver.class, String.class));
    execution = mock(Execution.class);
    mocker.registerComponent(Execution.class, execution);
    xcontext = mock(XWikiContext.class);
    xwiki = mock(XWiki.class);
    ExecutionContext executionContext = mock(ExecutionContext.class);
    when(execution.getContext()).thenReturn(executionContext);
    when(executionContext.getProperty("xwikicontext")).thenReturn(xcontext);
    when(xcontext.getWiki()).thenReturn(xwiki);
    when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
    query = mock(Query.class);
    when(queryManager.createQuery(any(), eq(Query.XWQL))).thenReturn(query);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) Query(org.xwiki.query.Query) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) QueryManager(org.xwiki.query.QueryManager) XWikiContext(com.xpn.xwiki.XWikiContext) XWiki(com.xpn.xwiki.XWiki) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Before(org.junit.Before)

Example 30 with WikiDescriptorManager

use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.

the class WorkspaceMigrationTest method setUp.

@Before
public void setUp() throws Exception {
    wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
    documentRestorerFromAttachedXAR = mocker.getInstance(DocumentRestorerFromAttachedXAR.class);
    execution = mock(Execution.class);
    mocker.registerComponent(Execution.class, execution);
    xcontext = mock(XWikiContext.class);
    xwiki = mock(XWiki.class);
    ExecutionContext executionContext = mock(ExecutionContext.class);
    when(execution.getContext()).thenReturn(executionContext);
    when(executionContext.getProperty("xwikicontext")).thenReturn(xcontext);
    when(xcontext.getWiki()).thenReturn(xwiki);
    when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) XWikiContext(com.xpn.xwiki.XWikiContext) XWiki(com.xpn.xwiki.XWiki) Before(org.junit.Before)

Aggregations

WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)40 Test (org.junit.Test)17 DocumentReference (org.xwiki.model.reference.DocumentReference)14 Before (org.junit.Before)13 XWikiContext (com.xpn.xwiki.XWikiContext)11 Execution (org.xwiki.context.Execution)9 ExecutionContext (org.xwiki.context.ExecutionContext)9 XWiki (com.xpn.xwiki.XWiki)8 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)8 ExtensionId (org.xwiki.extension.ExtensionId)6 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)6 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)6 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)6 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)5 ExtendedURL (org.xwiki.url.ExtendedURL)5 WebJarsResourceReference (org.xwiki.webjars.internal.WebJarsResourceReference)5 InstalledExtension (org.xwiki.extension.InstalledExtension)4 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)4 Query (org.xwiki.query.Query)4 BaseObject (com.xpn.xwiki.objects.BaseObject)3