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);
}
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);
}
Aggregations