Search in sources :

Example 16 with WikiCreationRequest

use of org.xwiki.platform.wiki.creationjob.WikiCreationRequest in project xwiki-platform by xwiki.

the class AddUsersStepTest method execute.

@Test
public void execute() throws Exception {
    WikiCreationRequest request = new WikiCreationRequest();
    request.setWikiId("wikiId");
    List<String> members = new ArrayList<>();
    request.setMembers(members);
    // Test
    mocker.getComponentUnderTest().execute(request);
    // Verify
    verify(wikiUserManager).addMembers(members, "wikiId");
}
Also used : WikiCreationRequest(org.xwiki.platform.wiki.creationjob.WikiCreationRequest) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with WikiCreationRequest

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

Aggregations

Test (org.junit.Test)17 WikiCreationRequest (org.xwiki.platform.wiki.creationjob.WikiCreationRequest)17 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)6 WikiProvisioningEvent (org.xwiki.bridge.event.WikiProvisioningEvent)3 ExtensionId (org.xwiki.extension.ExtensionId)3 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)3 ArrayList (java.util.ArrayList)2 WikiProvisionedEvent (org.xwiki.bridge.event.WikiProvisionedEvent)2 Job (org.xwiki.job.Job)2 WikiCreationStep (org.xwiki.platform.wiki.creationjob.WikiCreationStep)2 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)2 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)2 InOrder (org.mockito.InOrder)1 Marker (org.slf4j.Marker)1 WikiCopiedEvent (org.xwiki.bridge.event.WikiCopiedEvent)1 WikiProvisioningFailedEvent (org.xwiki.bridge.event.WikiProvisioningFailedEvent)1 JobException (org.xwiki.job.JobException)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 WikiReference (org.xwiki.model.reference.WikiReference)1 WikiUserManagerException (org.xwiki.wiki.user.WikiUserManagerException)1