Search in sources :

Example 6 with WikiCopiedEvent

use of org.xwiki.bridge.event.WikiCopiedEvent 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);
}
Also used : WikiCopiedEvent(org.xwiki.bridge.event.WikiCopiedEvent) WikiProvisionedEvent(org.xwiki.bridge.event.WikiProvisionedEvent) WikiProvisioningEvent(org.xwiki.bridge.event.WikiProvisioningEvent) WikiCreationRequest(org.xwiki.platform.wiki.creationjob.WikiCreationRequest) Test(org.junit.Test)

Example 7 with WikiCopiedEvent

use of org.xwiki.bridge.event.WikiCopiedEvent in project xwiki-platform by xwiki.

the class DefaultWikiManagerTest method copyWhenWikiAvailable.

@Test
public void copyWhenWikiAvailable() throws Exception {
    // The wiki does not already exist
    when(wikiDescriptorManager.exists("wikiid1")).thenReturn(false);
    // The new id is valid
    when(xwiki.Param("xwiki.virtual.reserved_wikis")).thenReturn("forbidden");
    // The wiki name is available
    when(store.isWikiNameAvailable(eq("wikiid1"), any(XWikiContext.class))).thenReturn(true);
    // Other mocks
    DefaultWikiDescriptor descriptor = new DefaultWikiDescriptor("wikiid1", "wikialias1");
    when(wikiCreator.create("wikiid1", "wikialias1")).thenReturn(descriptor);
    // Copy
    WikiDescriptor newWikiDescriptor = this.mocker.getComponentUnderTest().copy("wikiid", "wikiid1", "wikialias1", true, true, true);
    assertNotNull(newWikiDescriptor);
    // Verify that the wiki has been created
    verify(wikiCreator).create("wikiid1", "wikialias1");
    // Verify that the wiki has been copied
    verify(wikiCopier).copyDocuments(eq("wikiid"), eq("wikiid1"), eq(true));
    // Verify that deleted documents has been copied too
    verify(wikiCopier).copyDeletedDocuments(eq("wikiid"), eq("wikiid1"));
    // Verify that events has been sent
    verify(observationManager).notify(new WikiCopiedEvent("wikiid", "wikiid1"), "wikiid", xcontext);
}
Also used : WikiCopiedEvent(org.xwiki.bridge.event.WikiCopiedEvent) XWikiContext(com.xpn.xwiki.XWikiContext) DefaultWikiDescriptor(org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor) DefaultWikiDescriptor(org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Aggregations

WikiCopiedEvent (org.xwiki.bridge.event.WikiCopiedEvent)7 Test (org.junit.Test)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 WikiProvisionedEvent (org.xwiki.bridge.event.WikiProvisionedEvent)2 WikiProvisioningEvent (org.xwiki.bridge.event.WikiProvisioningEvent)2 WikiProvisioningFailedEvent (org.xwiki.bridge.event.WikiProvisioningFailedEvent)2 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)2 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)2 InstalledExtension (org.xwiki.extension.InstalledExtension)1 ObservationManager (org.xwiki.observation.ObservationManager)1 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)1 WikiCreationRequest (org.xwiki.platform.wiki.creationjob.WikiCreationRequest)1 DefaultWikiDescriptor (org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor)1 WikiProvisioningJobRequest (org.xwiki.wiki.provisioning.WikiProvisioningJobRequest)1