Search in sources :

Example 1 with GroupedJob

use of org.xwiki.job.GroupedJob 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)

Aggregations

Test (org.junit.Test)1 GroupedJob (org.xwiki.job.GroupedJob)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 LinkRefactoring (org.xwiki.refactoring.internal.LinkRefactoring)1 MoveRequest (org.xwiki.refactoring.job.MoveRequest)1 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)1