use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class QueryGeneratorTest method setUp.
@Before
public void setUp() throws Exception {
queryManager = mocker.getInstance(QueryManager.class);
notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
serializer = mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
userPreferencesSource = mocker.getInstance(ConfigurationSource.class, "user");
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
notificationFilterManager = mocker.getInstance(NotificationFilterManager.class);
startDate = new Date(10);
query = mock(Query.class);
when(queryManager.createQuery(anyString(), anyString())).thenReturn(query);
pref1StartDate = new Date(100000000);
NotificationPreference pref1 = mock(NotificationPreference.class);
when(pref1.getProperties()).thenReturn(Collections.singletonMap(NotificationPreferenceProperty.EVENT_TYPE, "create"));
when(pref1.getFormat()).thenReturn(NotificationFormat.ALERT);
when(pref1.getStartDate()).thenReturn(pref1StartDate);
when(pref1.isNotificationEnabled()).thenReturn(true);
when(notificationPreferenceManager.getPreferences(userReference, true, NotificationFormat.ALERT)).thenReturn(Arrays.asList(pref1));
NotificationFilterPreference fakeFilterPreference = mock(NotificationFilterPreference.class);
when(fakeFilterPreference.isActive()).thenReturn(true);
when(notificationFilterManager.getFilterPreferences(any(DocumentReference.class))).thenReturn(Sets.newSet(fakeFilterPreference));
when(userPreferencesSource.getProperty("displayHiddenDocuments", 0)).thenReturn(0);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("xwiki");
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class MoveJobTest method updateLinksOnFarm.
@Test
public void updateLinksOnFarm() throws Throwable {
DocumentReference oldReference = new DocumentReference("foo", "One", "Page");
when(this.modelBridge.exists(oldReference)).thenReturn(true);
DocumentReference newReference = new DocumentReference("foo", "Two", "Page");
when(this.modelBridge.exists(newReference)).thenReturn(false);
when(this.modelBridge.copy(oldReference, newReference)).thenReturn(true);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getAllIds()).thenReturn(Arrays.asList("foo", "bar"));
DocumentReference aliceReference = new DocumentReference("foo", "Alice", "BackLink");
when(this.modelBridge.getBackLinkedReferences(oldReference, "foo")).thenReturn(Arrays.asList(aliceReference));
DocumentReference bobReference = new DocumentReference("bar", "Bob", "BackLink");
when(this.modelBridge.getBackLinkedReferences(oldReference, "bar")).thenReturn(Arrays.asList(bobReference));
MoveRequest request = createRequest(oldReference, newReference.getParent());
request.setCheckRights(false);
request.setInteractive(false);
request.setUpdateLinksOnFarm(true);
GroupedJob job = (GroupedJob) run(request);
assertEquals(RefactoringJobs.GROUP, job.getGroupPath().toString());
LinkRefactoring linkRefactoring = getMocker().getInstance(LinkRefactoring.class);
verify(linkRefactoring).renameLinks(aliceReference, oldReference, newReference);
verify(linkRefactoring).renameLinks(bobReference, oldReference, newReference);
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WikiUserFromXEMMigrationTest method setUp.
@Before
public void setUp() throws Exception {
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
wikiUserConfigurationHelper = mocker.getInstance(WikiUserConfigurationHelper.class);
execution = mock(Execution.class);
mocker.registerComponent(Execution.class, execution);
xcontext = mock(XWikiContext.class);
xwiki = mock(XWiki.class);
ExecutionContext executionContext = mock(ExecutionContext.class);
when(execution.getContext()).thenReturn(executionContext);
when(executionContext.getProperty("xwikicontext")).thenReturn(xcontext);
when(xcontext.getWiki()).thenReturn(xwiki);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager 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);
}
use of org.xwiki.wiki.descriptor.WikiDescriptorManager in project xwiki-platform by xwiki.
the class WikiManagerScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
wikiManager = mocker.getInstance(WikiManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
scriptServiceManager = mocker.getInstance(ScriptServiceManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
standardURLConfiguration = mocker.getInstance(StandardURLConfiguration.class);
wikiConfiguration = mocker.getInstance(WikiConfiguration.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(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
when(entityReferenceSerializer.serialize(currentUserRef)).thenReturn("mainWiki:XWiki.User");
wikiDescriptorDocumentHelper = mocker.getInstance(WikiDescriptorDocumentHelper.class);
}
Aggregations