use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class ProvisionWikiStepTest method executeWhenException.
@Test
public void executeWhenException() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setWikiSource(WikiSource.EXTENSION);
ExtensionId extensionId = new ExtensionId("id", "version");
request.setExtensionId(extensionId);
// Mocks
WikiCreationException exception = new WikiCreationException("Exception in ExtensionInstaller");
doThrow(exception).when(extensionInstaller).installExtension("wikiId", extensionId);
// Test
WikiCreationException caughtException = null;
try {
mocker.getComponentUnderTest().execute(request);
} catch (WikiCreationException e) {
caughtException = e;
}
// Verify
assertNotNull(caughtException);
assertEquals("Failed to provision the wiki [wikiId].", caughtException.getMessage());
assertEquals(exception, caughtException.getCause());
verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext));
verify(observationManager).notify(eq(new WikiProvisioningFailedEvent("wikiId")), eq("wikiId"), eq(xcontext));
}
use of org.xwiki.extension.ExtensionId 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.ExtensionId 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.ExtensionId 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.ExtensionId in project xwiki-platform by xwiki.
the class DistributionPingDataProviderTest method provideData.
@Test
public void provideData() throws Exception {
InstanceId id = new InstanceId(UUID.randomUUID().toString());
InstanceIdManager idManager = this.mocker.getInstance(InstanceIdManager.class);
when(idManager.getInstanceId()).thenReturn(id);
ExtensionId environmentExtensionId = new ExtensionId("environmentextensionid", "2.0");
CoreExtension environmentExtension = mock(CoreExtension.class);
when(environmentExtension.getId()).thenReturn(environmentExtensionId);
CoreExtensionRepository CoreExtensionRepository = this.mocker.getInstance(CoreExtensionRepository.class);
when(CoreExtensionRepository.getEnvironmentExtension()).thenReturn(environmentExtension);
Map<String, Object> data = this.mocker.getComponentUnderTest().provideData();
assertEquals(3, data.size());
assertEquals("environmentextensionid", data.get("distributionId"));
assertEquals("2.0", data.get("distributionVersion"));
assertEquals(id.getInstanceId(), data.get("instanceId"));
}
Aggregations