use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RenameJobTest method renameDocument.
@Test
public void renameDocument() throws Throwable {
DocumentReference oldReference = new DocumentReference("wiki", "Space", "Old");
when(this.modelBridge.exists(oldReference)).thenReturn(true);
DocumentReference newReference = new DocumentReference("wiki", "Space", "New");
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
when(this.modelBridge.copy(oldReference, newReference)).thenReturn(true);
MoveRequest request = createRequest(oldReference, newReference);
request.setCheckRights(false);
request.setInteractive(false);
request.setUserReference(userReference);
run(request);
verify(this.modelBridge).setContextUserReference(userReference);
verify(this.modelBridge).delete(oldReference);
verify(this.modelBridge).createRedirect(oldReference, newReference);
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RenameJobTest method renameMultipleEntities.
@Test
public void renameMultipleEntities() throws Throwable {
DocumentReference blackReference = new DocumentReference("wiki", "Color", "Black");
DocumentReference whiteReference = new DocumentReference("wiki", "Color", "White");
DocumentReference orangeReference = new DocumentReference("wiki", "Color", "Orange");
MoveRequest request = new MoveRequest();
request.setEntityReferences(Arrays.<EntityReference>asList(blackReference, whiteReference));
request.setDestination(orangeReference);
run(request);
verifyNoMove();
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method convertToTerminalDocument.
@Test
public void convertToTerminalDocument() throws Exception {
DocumentReference terminalDocumentReference = new DocumentReference("code", "Model", "Entity");
DocumentReference nestedDocumentReference = new DocumentReference("code", Arrays.asList("Model", "Entity"), "WebHome");
DocumentReference rootDocumentReference = new DocumentReference("wiki", "Space", "WebHome");
getService().convertToTerminalDocument(nestedDocumentReference);
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
verify(this.jobExecutor).execute(eq(RefactoringJobs.RENAME), request.capture());
assertEquals(Arrays.asList(nestedDocumentReference), request.getValue().getEntityReferences());
assertEquals(terminalDocumentReference, request.getValue().getDestination());
assertNull(getService().convertToTerminalDocument(terminalDocumentReference));
assertNull(getService().convertToTerminalDocument(rootDocumentReference));
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method move.
@Test
public void move() throws Exception {
SpaceReference source = new SpaceReference("Space", new WikiReference("math"));
WikiReference destination = new WikiReference("code");
Job job = mock(Job.class);
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
when(this.jobExecutor.execute(eq(RefactoringJobs.MOVE), request.capture())).thenReturn(job);
assertSame(job, getService().move(source, destination));
assertEquals(Arrays.asList(source), request.getValue().getEntityReferences());
assertEquals(destination, request.getValue().getDestination());
assertEquals(Arrays.asList(RefactoringJobs.GROUP, "move"), request.getValue().getId().subList(0, 2));
assertEquals(RefactoringJobs.MOVE, request.getValue().getJobType());
assertEquals(this.userReference, request.getValue().getUserReference());
assertEquals(false, request.getValue().isDeep());
assertEquals(true, request.getValue().isDeleteSource());
assertEquals(true, request.getValue().isUpdateLinks());
assertEquals(true, request.getValue().isAutoRedirect());
assertEquals(false, request.getValue().isInteractive());
assertEquals(true, request.getValue().isCheckRights());
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method copy.
@Test
public void copy() throws Exception {
SpaceReference source = new SpaceReference("Space", new WikiReference("math"));
WikiReference destination = new WikiReference("code");
getService().copy(source, destination);
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
// The MOVE job can perform a COPY too.
verify(this.jobExecutor).execute(eq(RefactoringJobs.MOVE), request.capture());
assertEquals(RefactoringJobs.COPY, request.getValue().getJobType());
assertFalse(request.getValue().isDeleteSource());
}
Aggregations