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