use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class ExtensionInstallerTest method installExtensionWithException.
@Test
public void installExtensionWithException() throws Exception {
// Test
WikiCreationException caughtException = null;
try {
mocker.getComponentUnderTest().installExtension("wikiId", new ExtensionId("extensionId", "version"));
} catch (WikiCreationException e) {
caughtException = e;
}
// Verify
assertNotNull(caughtException);
assertEquals("Failed to install the extension [extensionId/version] on the wiki [wikiId].", caughtException.getMessage());
assertTrue(caughtException.getCause() instanceof ComponentLookupException);
}
use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class ProvisionWikiStepTest method executeWhenSourceIsExtension.
@Test
public void executeWhenSourceIsExtension() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setWikiSource(WikiSource.EXTENSION);
ExtensionId extensionId = new ExtensionId("id", "version");
request.setExtensionId(extensionId);
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
verify(extensionInstaller).installExtension(eq("wikiId"), eq(extensionId));
verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext));
verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext));
verifyZeroInteractions(wikiCopier);
}
use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.
the class SaveWikiMetaDataStepTest method execute.
@Test
public void execute() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setDescription("description");
request.setPrettyName("pretty name");
request.setOwnerId("ownerId");
request.setTemplate(false);
request.setUserScope(UserScope.GLOBAL_ONLY);
request.setMembershipType(MembershipType.INVITE);
request.setWikiSource(WikiSource.EXTENSION);
ExtensionId extensionId = new ExtensionId("id", "version");
request.setExtensionId(extensionId);
// Mock
WikiDescriptor descriptor = new WikiDescriptor("wikiId", "alias");
when(wikiDescriptorManager.getById("wikiId")).thenReturn(descriptor);
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
assertEquals("description", descriptor.getDescription());
assertEquals("pretty name", descriptor.getPrettyName());
assertEquals("ownerId", descriptor.getOwnerId());
verify(wikiDescriptorManager).saveDescriptor(descriptor);
verify(wikiTemplateManager).setTemplate("wikiId", false);
verify(wikiUserManager).setUserScope("wikiId", UserScope.GLOBAL_ONLY);
verify(wikiUserManager).setMembershipType("wikiId", MembershipType.INVITE);
}
use of org.xwiki.extension.ExtensionId 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.extension.ExtensionId in project xwiki-platform by xwiki.
the class ExtensionInstanceOutputFilterStream method endExtension.
@Override
public void endExtension(String id, String version, FilterEventParameters parameters) throws FilterException {
// TODO: add support for complete extension
ExtensionId extensionId = new ExtensionId(id, factory.getVersion(version));
try {
LocalExtension localExtension = this.localRepository.getLocalExtension(extensionId);
if (localExtension == null) {
Extension extension;
try {
// Try to find and download the extension from a repository
extension = this.extensionRepository.resolve(extensionId);
} catch (ResolveException e) {
this.logger.debug("Can't find extension [{}]", extensionId, e);
// FIXME: Create a dummy extension. Need support for partial/lazy extension.
return;
}
localExtension = this.localRepository.storeExtension(extension);
}
String namespace = getCurrentNamespace();
// TODO: should probably make it configurable
if (installedRepository.getInstalledExtension(localExtension.getId().getId(), namespace) == null) {
for (ExtensionId feature : localExtension.getExtensionFeatures()) {
if (installedRepository.getInstalledExtension(feature.getId(), namespace) != null) {
// Already exist so don't register it or it could create a mess
return;
}
}
} else {
return;
}
// Register the extension as installed
installedRepository.installExtension(localExtension, namespace, false);
} catch (Exception e) {
this.logger.error("Failed to register extenion [{}] from the XAR", extensionId, e);
}
}
Aggregations