use of org.xwiki.extension.repository.InstalledExtensionRepository in project xwiki-platform by xwiki.
the class ExtensionManagerScriptServiceTest method testOverwriteAllowedNamespaces.
@Test
public void testOverwriteAllowedNamespaces() throws Throwable {
InstallRequest installRequest = this.scriptService.createInstallRequest("extension", "version", "namespace");
// Indicate all extensions of type "test" should be installed on root
((ScriptExtensionRewriter) installRequest.getRewriter()).installExtensionTypeOnRootNamespace("test");
// Allow redirect on root
installRequest.setRootModificationsAllowed(true);
Job job = this.scriptService.install(installRequest);
if (job == null) {
throw this.scriptService.getLastError();
}
job.join();
List<LogEvent> errors = job.getStatus().getLog().getLogsFrom(LogLevel.WARN);
if (!errors.isEmpty()) {
throw errors.get(0).getThrowable();
}
// Validate
InstalledExtensionRepository repository = mocker.getInstance(InstalledExtensionRepository.class);
assertNotNull(repository.getInstalledExtension("extension", null));
}
use of org.xwiki.extension.repository.InstalledExtensionRepository in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLWithoutVersion.
@Test
public void computeURLWithoutVersion() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
InstalledExtensionRepository installedExtensionRepository = this.mocker.getInstance(InstalledExtensionRepository.class);
InstalledExtension extension = mock(InstalledExtension.class);
when(installedExtensionRepository.getInstalledExtension("org.webjars:angular", "wiki:math")).thenReturn(extension);
when(extension.getId()).thenReturn(new ExtensionId("bar", "2.1.11"));
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "2.1.11", "angular.css"));
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "2.1.11", "angular.css")));
assertEquals("/xwiki/angular/2.1.11/angular.css", this.mocker.getComponentUnderTest().url("angular", "angular.css"));
}
use of org.xwiki.extension.repository.InstalledExtensionRepository in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLWithParametersAndWikiIsNotSpecifiedInParameter.
@Test
public void computeURLWithParametersAndWikiIsNotSpecifiedInParameter() throws Exception {
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("math");
InstalledExtensionRepository installedExtensionRepository = this.mocker.getInstance(InstalledExtensionRepository.class);
InstalledExtension extension = mock(InstalledExtension.class);
when(installedExtensionRepository.getInstalledExtension("org.webjars:angular", "wiki:math")).thenReturn(extension);
when(extension.getId()).thenReturn(new ExtensionId("bar", "2.1.11"));
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "2.1.11", "angular.css"));
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "2.1.11", "angular.css")));
assertEquals("/xwiki/angular/2.1.11/angular.css", this.mocker.getComponentUnderTest().url("angular", "angular.css", Collections.<String, Object>emptyMap()));
}
use of org.xwiki.extension.repository.InstalledExtensionRepository in project xwiki-platform by xwiki.
the class WebJarsScriptServiceTest method computeURLForBackwardCompatibilityWhenWikiIsSpecifiedAsParameter.
@Test
public void computeURLForBackwardCompatibilityWhenWikiIsSpecifiedAsParameter() throws Exception {
InstalledExtensionRepository installedExtensionRepository = this.mocker.getInstance(InstalledExtensionRepository.class);
InstalledExtension extension = mock(InstalledExtension.class);
when(installedExtensionRepository.getInstalledExtension("org.webjars:angular", "wiki:math")).thenReturn(extension);
when(extension.getId()).thenReturn(new ExtensionId("bar", "2.1.11"));
WebJarsResourceReference resourceReference = new WebJarsResourceReference("wiki:math", Arrays.asList("angular", "2.1.11", "angular.css"));
when(this.serializer.serialize(resourceReference)).thenReturn(new ExtendedURL(Arrays.asList("xwiki", "angular", "2.1.11", "angular.css")));
assertEquals("/xwiki/angular/2.1.11/angular.css", this.mocker.getComponentUnderTest().url("angular", "angular.css", Collections.singletonMap("wiki", "math")));
}
use of org.xwiki.extension.repository.InstalledExtensionRepository in project xwiki-platform by xwiki.
the class ExtensionPingDataProviderTest method provideData.
@Test
public void provideData() throws Exception {
ExtensionId extensionId = new ExtensionId("extensionid", "1.0");
InstalledExtension extension = mock(InstalledExtension.class);
when(extension.getId()).thenReturn(extensionId);
when(extension.getFeatures()).thenReturn(Arrays.asList("feature1", "feature2"));
InstalledExtensionRepository repository = this.mocker.getInstance(InstalledExtensionRepository.class);
when(repository.getInstalledExtensions()).thenReturn(Collections.singletonList(extension));
Map<String, Object> data = this.mocker.getComponentUnderTest().provideData();
assertEquals(1, data.size());
JSONObject[] extensions = (JSONObject[]) data.get("extensions");
assertEquals(1, extensions.length);
JSONObject propertiesData = extensions[0];
assertEquals(3, propertiesData.size());
assertEquals("extensionid", propertiesData.get("id"));
assertEquals("1.0", propertiesData.get("version"));
JSONArray features = (JSONArray) propertiesData.get("features");
assertEquals(2, features.size());
assertEquals("feature1", features.get(0));
assertEquals("feature2", features.get(1));
}
Aggregations