use of org.xwiki.platform.wiki.creationjob.WikiCreationRequest 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.platform.wiki.creationjob.WikiCreationRequest in project xwiki-platform by xwiki.
the class ProvisionWikiStepTest method executeWhenSourceIsTemplate.
@Test
public void executeWhenSourceIsTemplate() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setWikiSource(WikiSource.TEMPLATE);
request.setTemplateId("template");
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
verify(wikiCopier).copyDocuments(eq("template"), eq("wikiId"), eq(false));
verify(observationManager).notify(eq(new WikiProvisioningEvent("wikiId")), eq("wikiId"), eq(xcontext));
verify(observationManager).notify(eq(new WikiCopiedEvent("template", "wikiId")), eq("template"), eq(xcontext));
verify(observationManager).notify(eq(new WikiProvisionedEvent("wikiId")), eq("wikiId"), eq(xcontext));
verifyZeroInteractions(extensionInstaller);
}
use of org.xwiki.platform.wiki.creationjob.WikiCreationRequest 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.platform.wiki.creationjob.WikiCreationRequest in project xwiki-platform by xwiki.
the class SaveWikiMetaDataStepTest method executeWithException.
@Test
public void executeWithException() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
// Mock
WikiDescriptor descriptor = new WikiDescriptor("wikiId", "alias");
when(wikiDescriptorManager.getById("wikiId")).thenReturn(descriptor);
Exception exception = new WikiManagerException("Exception on WikiManager.");
doThrow(exception).when(wikiDescriptorManager).saveDescriptor(descriptor);
// Test
WikiCreationException caughtException = null;
try {
mocker.getComponentUnderTest().execute(request);
} catch (WikiCreationException e) {
caughtException = e;
}
// Verify
assertEquals("Failed to set metadata to the wiki [wikiId].", caughtException.getMessage());
assertEquals(exception, caughtException.getCause());
}
use of org.xwiki.platform.wiki.creationjob.WikiCreationRequest in project xwiki-platform by xwiki.
the class SaveWikiMetaDataStepTest method executeWhenSourceIsTemplate.
@Test
public void executeWhenSourceIsTemplate() throws Exception {
WikiCreationRequest request = new WikiCreationRequest();
request.setWikiId("wikiId");
request.setTemplate(false);
request.setUserScope(UserScope.LOCAL_ONLY);
request.setMembershipType(MembershipType.OPEN);
request.setWikiSource(WikiSource.TEMPLATE);
// Mock
WikiDescriptor descriptor = new WikiDescriptor("wikiId", "alias");
when(wikiDescriptorManager.getById("wikiId")).thenReturn(descriptor);
// Test
mocker.getComponentUnderTest().execute(request);
// Verify
verify(wikiDescriptorManager).saveDescriptor(descriptor);
verify(wikiUserManager).setUserScope("wikiId", UserScope.LOCAL_ONLY);
verify(wikiUserManager).setMembershipType("wikiId", MembershipType.OPEN);
}
Aggregations