use of org.xwiki.extension.InstalledExtension 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.InstalledExtension 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.InstalledExtension 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));
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class ExtensionPingDataProvider method provideData.
@Override
public Map<String, Object> provideData() {
Collection<InstalledExtension> installedExtensions = this.extensionRepository.getInstalledExtensions();
JSONObject[] extensions = new JSONObject[installedExtensions.size()];
Iterator<InstalledExtension> it = installedExtensions.iterator();
int i = 0;
while (it.hasNext()) {
InstalledExtension extension = it.next();
Map<String, Object> extensionMap = new HashMap<>();
extensionMap.put(PROPERTY_ID, extension.getId().getId());
extensionMap.put(PROPERTY_VERSION, extension.getId().getVersion().toString());
extensionMap.put(PROPERTY_FEATURES, extension.getFeatures().toArray());
extensions[i] = JSONObject.fromObject(extensionMap);
i++;
}
return Collections.singletonMap(PROPERTY_EXTENSIONS, (Object) extensions);
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class RepairXarJobTest method testRepairInvalidOnRoot.
@Test
public void testRepairInvalidOnRoot() throws Throwable {
ExtensionId extensionId = new ExtensionId("invalid", "1.0");
repair(extensionId, null, LogLevel.ERROR);
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
assertFalse(installedExtension.isValid(null));
}
Aggregations