Search in sources :

Example 1 with WikiUserManager

use of org.xwiki.wiki.user.WikiUserManager in project xwiki-platform by xwiki.

the class WikiUserManagerScriptServiceTest method setUp.

@Before
public void setUp() throws Exception {
    // Components mocks
    wikiUserManager = mocker.getInstance(WikiUserManager.class);
    wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
    authorizationManager = mocker.getInstance(AuthorizationManager.class);
    xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    documentReferenceResolver = mocker.getInstance(new DefaultParameterizedType(null, DocumentReferenceResolver.class, String.class));
    execution = mocker.getInstance(Execution.class);
    // Frequent uses
    xcontext = mock(XWikiContext.class);
    when(xcontextProvider.get()).thenReturn(xcontext);
    when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
    when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("subwiki");
    executionContext = new ExecutionContext();
    when(execution.getContext()).thenReturn(executionContext);
    currentDoc = mock(XWikiDocument.class);
    when(xcontext.getDoc()).thenReturn(currentDoc);
    userDocRef = new DocumentReference("mainWiki", "XWiki", "User");
    when(xcontext.getUserReference()).thenReturn(userDocRef);
    DocumentReference userReference = new DocumentReference("mainWiki", "XWiki", "User");
    when(documentReferenceResolver.resolve("mainWiki:XWiki.User")).thenReturn(userReference);
    DocumentReference otherUser = new DocumentReference("mainWiki", "XWiki", "OtherUser");
    when(documentReferenceResolver.resolve("mainWiki:XWiki.OtherUser")).thenReturn(otherUser);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) XWikiContext(com.xpn.xwiki.XWikiContext) AuthorizationManager(org.xwiki.security.authorization.AuthorizationManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) DocumentReference(org.xwiki.model.reference.DocumentReference) WikiUserManager(org.xwiki.wiki.user.WikiUserManager) Before(org.junit.Before)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 Before (org.junit.Before)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 Execution (org.xwiki.context.Execution)1 ExecutionContext (org.xwiki.context.ExecutionContext)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)1 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)1 WikiUserManager (org.xwiki.wiki.user.WikiUserManager)1