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