use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WikiTemplateManagerScriptTest method setUp.
@Before
public void setUp() throws Exception {
wikiTemplateManager = mocker.getInstance(WikiTemplateManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
execution = mocker.getInstance(Execution.class);
executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
currentUserRef = new DocumentReference("mainWiki", "XWiki", "User");
when(xcontext.getUserReference()).thenReturn(currentUserRef);
currentDoc = mock(XWikiDocument.class);
when(xcontext.getDoc()).thenReturn(currentDoc);
when(xcontext.getMainXWiki()).thenReturn("mainWiki");
when(entityReferenceSerializer.serialize(currentUserRef)).thenReturn("mainWiki:XWiki.User");
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class AbstractTestDocumentConfigurationSource method before.
@Before
public void before() throws Exception {
this.mockCache = mock(Cache.class);
this.mockConverter = this.componentManager.getInstance(ConverterManager.class);
when(this.mockConverter.convert(any(Type.class), anyObject())).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return invocation.getArguments()[1];
}
});
CacheManager cacheManager = this.componentManager.getInstance(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(this.mockCache);
WikiDescriptorManager wikiManager = this.componentManager.getInstance(WikiDescriptorManager.class);
when(wikiManager.getCurrentWikiId()).thenReturn(CURRENT_WIKI);
DocumentReferenceResolver<EntityReference> mockCurrentEntityResolver = this.componentManager.registerMockComponent(DocumentReferenceResolver.TYPE_REFERENCE, "current");
when(mockCurrentEntityResolver.resolve(eq(getClassReference()), any(DocumentReference.class))).thenReturn(new DocumentReference(getClassReference(), new WikiReference(CURRENT_WIKI)));
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class DefaultNotificationFilterManagerTest method setUp.
@Before
public void setUp() throws Exception {
componentManager = mocker.registerMockComponent(ComponentManager.class);
wikiDescriptorManager = mocker.registerMockComponent(WikiDescriptorManager.class);
modelBridge = mocker.registerMockComponent(ModelBridge.class, "cached");
testUser = new DocumentReference("wiki", "test", "user");
testProvider = mock(NotificationFilterPreferenceProvider.class);
when(componentManager.getInstanceList(NotificationFilterPreferenceProvider.class)).thenReturn(Collections.singletonList(testProvider));
// Set a default comportment for the wikiDescriptorManager
when(wikiDescriptorManager.getMainWikiId()).thenReturn("wiki");
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("currentWikiId");
when(wikiDescriptorManager.getAllIds()).thenReturn(Arrays.asList("wiki", "currentWikiId"));
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class GroupsClassPropertyValuesProviderTest method getValuesLocalAndGlobal.
@Test
public void getValuesLocalAndGlobal() throws Exception {
// We can have local groups.
when(this.wikiUserManager.getUserScope(this.classReference.getWikiReference().getName())).thenReturn(UserScope.GLOBAL_ONLY);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("chess");
this.mocker.getComponentUnderTest().getValues(this.propertyReference, 5, "foo");
verify(this.allowedValuesQuery).setWiki("chess");
verify(this.allowedValuesQuery, times(2)).execute();
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class UsersClassPropertyValuesProviderTest method getValuesLocalAndGlobal.
@Test
public void getValuesLocalAndGlobal() throws Exception {
when(this.wikiUserManager.getUserScope(this.classReference.getWikiReference().getName())).thenReturn(UserScope.LOCAL_AND_GLOBAL);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("chess");
DocumentReference aliceReference = new DocumentReference("wiki", "Users", "Alice");
when(this.xcontext.getWiki().getDocument(aliceReference, this.xcontext)).thenReturn(mock(XWikiDocument.class, "alice"));
DocumentReference bobReference = new DocumentReference("chess", "Users", "Bob");
when(this.xcontext.getWiki().getDocument(bobReference, this.xcontext)).thenReturn(mock(XWikiDocument.class, "bob"));
when(this.allowedValuesQuery.execute()).thenReturn(Collections.singletonList(bobReference), Collections.singletonList(aliceReference));
PropertyValues values = this.mocker.getComponentUnderTest().getValues(this.propertyReference, 5, "foo");
assertEquals(2, values.getPropertyValues().size());
assertEquals("Alice", values.getPropertyValues().get(0).getMetaData().get("label"));
assertEquals("Bob", values.getPropertyValues().get(1).getMetaData().get("label"));
verify(this.allowedValuesQuery).setWiki("chess");
verify(this.allowedValuesQuery, times(2)).execute();
}
Aggregations