use of org.xwiki.extension.ExtensionId 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.ExtensionId 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));
}
use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class RepairXarJobTest method testRepairOnRoot.
@Test
public void testRepairOnRoot() throws Throwable {
ExtensionId extensionId = new ExtensionId("test", "1.0");
repair(extensionId, null, LogLevel.WARN);
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
assertTrue(installedExtension.isValid(null));
installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0"));
assertTrue(installedExtension.isValid(null));
}
use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class RepairXarJobTest method testRepairOnWiki.
@Test
public void testRepairOnWiki() throws Throwable {
ExtensionId extensionId = new ExtensionId("test", "1.0");
repair(extensionId, new String[] { "wiki:wiki1" }, LogLevel.WARN);
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId);
assertTrue(installedExtension.isValid(null));
installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0"));
assertTrue(installedExtension.isValid(null));
}
use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class XarInstalledExtensionRepositoryTest method testInit.
// Tests
@Test
public void testInit() throws ResolveException, SearchException {
assertEquals(1, this.installedExtensionRepository.countExtensions());
XarInstalledExtension xarInstalledExtension = this.installedExtensionRepository.resolve(new ExtensionId("xarinstalledextension", "1.0"));
assertNotNull(xarInstalledExtension);
assertNotNull(this.installedExtensionRepository.getInstalledExtension(new ExtensionId("xarinstalledextension", "1.0")));
assertNotNull(this.installedExtensionRepository.getInstalledExtension("xarinstalledextension", null));
assertNull(this.installedExtensionRepository.getInstalledExtension("notexisting", null));
assertEquals(1, this.installedExtensionRepository.getInstalledExtensions().size());
assertEquals(1, this.installedExtensionRepository.getInstalledExtensions(null).size());
assertEquals(1, this.installedExtensionRepository.search("xarinstalledextension", 0, -1).getSize());
assertEquals(1, this.installedExtensionRepository.search(null, 0, -1).getSize());
assertEquals(1, this.installedExtensionRepository.searchInstalledExtensions("xarinstalledextension", null, 0, -1).getSize());
assertEquals(1, this.installedExtensionRepository.searchInstalledExtensions(null, null, 0, -1).getSize());
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page")));
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("wiki2", "space", "page")));
assertEquals(Arrays.asList(xarInstalledExtension), this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ROOT)));
assertEquals(0, this.installedExtensionRepository.getXarInstalledExtensions(new DocumentReference("xwiki", "space", "page", Locale.ENGLISH)).size());
}
Aggregations