use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class UsersClassPropertyValuesProviderTest method getValuesGlobal.
@Test
public void getValuesGlobal() throws Exception {
when(this.wikiUserManager.getUserScope(this.classReference.getWikiReference().getName())).thenReturn(UserScope.GLOBAL_ONLY);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("math");
this.mocker.getComponentUnderTest().getValues(this.propertyReference, 5, "foo");
verify(this.allowedValuesQuery).setWiki("math");
verify(this.allowedValuesQuery, times(1)).execute();
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLWithVersion.
@Test
public void computeURLWithVersion() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("ang:ular", "2.1.11", "angular.css"));
// Test that colon is not interpreted as groupId/artifactId separator (for backwards compatibility).
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "ang:ular", "2.1.11", "angular.css")));
assertEquals("/xwiki/ang%3Aular/2.1.11/angular.css", this.mocker.getComponentUnderTest().url("ang:ular/2.1.11/angular.css"));
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLWithoutVersionAndNoExtensionMatchingWebJarId.
@Test
public void computeURLWithoutVersionAndNoExtensionMatchingWebJarId() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "angular.css"));
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "angular.css")));
assertEquals("/xwiki/angular/angular.css", this.mocker.getComponentUnderTest().url("angular", "angular.css"));
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WikiCreationJobScriptServicesTest method setUp.
@Before
public void setUp() throws Exception {
wikiCreator = mocker.getInstance(WikiCreator.class);
execution = mocker.getInstance(Execution.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
distributionManager = mocker.getInstance(DistributionManager.class);
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
xwiki = mock(XWiki.class);
when(xcontext.getWiki()).thenReturn(xwiki);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWikiId");
ExecutionContext executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
ExtensionId extensionId = new ExtensionId("authorized-extension", "1.0");
when(distributionManager.getWikiUIExtensionId()).thenReturn(extensionId);
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class DefaultWikiDescriptorDocumentHelper method findXWikiServerClassDocumentReference.
@Override
public DocumentReference findXWikiServerClassDocumentReference(String wikiAlias) throws WikiManagerException {
if (wikiAlias == null) {
throw new IllegalArgumentException("Wiki alias cannot be null");
}
WikiDescriptorManager wikiDescriptorManager = wikiDescriptorManagerProvider.get();
DocumentReference result = null;
try {
Query query = this.queryManager.createQuery("where doc.object(XWiki.XWikiServerClass).server = :wikiAlias and doc.name like 'XWikiServer%'", Query.XWQL);
query.bindValue("wikiAlias", wikiAlias);
query.setWiki(wikiDescriptorManager.getMainWikiId());
List<String> documentNames = query.execute();
// Resolve the document name into a references
if (documentNames != null && !documentNames.isEmpty()) {
result = documentReferenceResolver.resolve(documentNames.get(0));
}
} catch (QueryException e) {
throw new WikiManagerException(String.format("Failed to locate XWiki.XWikiServerClass document for wiki alias [%s]", wikiAlias), e);
}
return result;
}
Aggregations