Search in sources :

Example 6 with WikiDescriptor

use of org.xwiki.wiki.descriptor.WikiDescriptor in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method getAllError.

@Test
public void getAllError() throws Exception {
    Exception exception = new WikiManagerException("error in getAll");
    when(wikiDescriptorManager.getAll()).thenThrow(exception);
    Collection<WikiDescriptor> result = mocker.getComponentUnderTest().getAll();
    assertTrue(result.isEmpty());
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 7 with WikiDescriptor

use of org.xwiki.wiki.descriptor.WikiDescriptor in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method saveDescriptorWhenIAmOwner.

@Test
public void saveDescriptorWhenIAmOwner() throws Exception {
    WikiDescriptor oldDescriptor = mock(WikiDescriptor.class);
    when(oldDescriptor.getId()).thenReturn("wikiId");
    when(oldDescriptor.getOwnerId()).thenReturn("mainWiki:XWiki.User");
    when(wikiDescriptorManager.getById(oldDescriptor.getId())).thenReturn(oldDescriptor);
    // Changing some value, not the owner.
    WikiDescriptor descriptor = new WikiDescriptor(oldDescriptor.getId(), "wikiAlias");
    descriptor.setOwnerId(oldDescriptor.getOwnerId());
    boolean result = mocker.getComponentUnderTest().saveDescriptor(descriptor);
    assertTrue(result);
    // The owner of the old descriptor was verified (once by us, once by the call).
    verify(oldDescriptor, times(2)).getOwnerId();
    // The descriptor has been saved
    verify(wikiDescriptorManager).saveDescriptor(descriptor);
}
Also used : WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 8 with WikiDescriptor

use of org.xwiki.wiki.descriptor.WikiDescriptor in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method getByAlias.

@Test
public void getByAlias() throws Exception {
    WikiDescriptor descriptor = new WikiDescriptor("wikiId", "wikiAlias");
    when(wikiDescriptorManager.getByAlias("wikiAlias")).thenReturn(descriptor);
    WikiDescriptor result = mocker.getComponentUnderTest().getByAlias("wikiAlias");
    assertEquals(descriptor, result);
}
Also used : WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 9 with WikiDescriptor

use of org.xwiki.wiki.descriptor.WikiDescriptor in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method createWikiWithoutCreateWikiRight.

@Test
public void createWikiWithoutCreateWikiRight() throws Exception {
    Exception exception = currentUserHasNotCreateWikiRight();
    WikiDescriptor result = mocker.getComponentUnderTest().createWiki("newwiki", "alias", "userA", true);
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Example 10 with WikiDescriptor

use of org.xwiki.wiki.descriptor.WikiDescriptor in project xwiki-platform by xwiki.

the class WikiManagerScriptServiceTest method createWikiWithoutPR.

@Test
public void createWikiWithoutPR() throws Exception {
    Exception exception = currentScriptHasNotProgrammingRight();
    WikiDescriptor result = mocker.getComponentUnderTest().createWiki("newwiki", "alias", "userA", true);
    assertNull(result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiDescriptor(org.xwiki.wiki.descriptor.WikiDescriptor) Test(org.junit.Test)

Aggregations

WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)60 Test (org.junit.Test)40 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)28 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)17 WikiReference (org.xwiki.model.reference.WikiReference)11 XWikiContext (com.xpn.xwiki.XWikiContext)9 WikiTemplateManagerException (org.xwiki.wiki.template.WikiTemplateManagerException)9 ArrayList (java.util.ArrayList)7 DocumentReference (org.xwiki.model.reference.DocumentReference)6 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)6 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)5 BaseObject (com.xpn.xwiki.objects.BaseObject)5 DefaultWikiDescriptor (org.xwiki.wiki.internal.descriptor.DefaultWikiDescriptor)5 WikiCreationRequest (org.xwiki.platform.wiki.creationjob.WikiCreationRequest)3 AuthorizationException (org.xwiki.security.authorization.AuthorizationException)3 WikiCopiedEvent (org.xwiki.bridge.event.WikiCopiedEvent)2 WikiCreatedEvent (org.xwiki.bridge.event.WikiCreatedEvent)2 WikiCreatingEvent (org.xwiki.bridge.event.WikiCreatingEvent)2 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)2 WikiDescriptorBuilderException (org.xwiki.wiki.internal.descriptor.builder.WikiDescriptorBuilderException)2