Search in sources :

Example 6 with WikiDescriptorManager

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");
}
Also used : NotificationFilterManager(org.xwiki.notifications.filters.NotificationFilterManager) NotificationPreference(org.xwiki.notifications.preferences.NotificationPreference) ConfigurationSource(org.xwiki.configuration.ConfigurationSource) NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) Query(org.xwiki.query.Query) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) QueryManager(org.xwiki.query.QueryManager) NotificationFilterPreference(org.xwiki.notifications.filters.NotificationFilterPreference) Date(java.util.Date) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Example 7 with WikiDescriptorManager

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);
}
Also used : GroupedJob(org.xwiki.job.GroupedJob) LinkRefactoring(org.xwiki.refactoring.internal.LinkRefactoring) MoveRequest(org.xwiki.refactoring.job.MoveRequest) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 8 with WikiDescriptorManager

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");
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) XWikiContext(com.xpn.xwiki.XWikiContext) XWiki(com.xpn.xwiki.XWiki) Before(org.junit.Before)

Example 9 with WikiDescriptorManager

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

Example 10 with WikiDescriptorManager

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);
}
Also used : WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) WikiConfiguration(org.xwiki.wiki.configuration.WikiConfiguration) ScriptServiceManager(org.xwiki.script.service.ScriptServiceManager) XWikiContext(com.xpn.xwiki.XWikiContext) WikiDescriptorDocumentHelper(org.xwiki.wiki.internal.descriptor.document.WikiDescriptorDocumentHelper) WikiManager(org.xwiki.wiki.manager.WikiManager) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) AuthorizationManager(org.xwiki.security.authorization.AuthorizationManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) StandardURLConfiguration(org.xwiki.url.internal.standard.StandardURLConfiguration) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Aggregations

WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)40 Test (org.junit.Test)17 DocumentReference (org.xwiki.model.reference.DocumentReference)14 Before (org.junit.Before)13 XWikiContext (com.xpn.xwiki.XWikiContext)11 Execution (org.xwiki.context.Execution)9 ExecutionContext (org.xwiki.context.ExecutionContext)9 XWiki (com.xpn.xwiki.XWiki)8 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)8 ExtensionId (org.xwiki.extension.ExtensionId)6 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)6 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)6 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)6 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)5 ExtendedURL (org.xwiki.url.ExtendedURL)5 WebJarsResourceReference (org.xwiki.webjars.internal.WebJarsResourceReference)5 InstalledExtension (org.xwiki.extension.InstalledExtension)4 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)4 Query (org.xwiki.query.Query)4 BaseObject (com.xpn.xwiki.objects.BaseObject)3