use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method moveWithoutPR.
@Test
public void moveWithoutPR() throws Exception {
MoveRequest request = new MoveRequest();
request.setCheckRights(false);
request.setUserReference(new DocumentReference("wiki", "Users", "Bob"));
getService().move(request);
assertTrue(request.isCheckRights());
assertEquals(this.userReference, request.getUserReference());
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method convertToNestedDocument.
@Test
public void convertToNestedDocument() throws Exception {
DocumentReference terminalDocumentReference = new DocumentReference("code", "Model", "Entity");
DocumentReference nestedDocumentReference = new DocumentReference("code", Arrays.asList("Model", "Entity"), "WebHome");
getService().convertToNestedDocument(terminalDocumentReference);
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
verify(this.jobExecutor).execute(eq(RefactoringJobs.RENAME), request.capture());
assertEquals(Arrays.asList(terminalDocumentReference), request.getValue().getEntityReferences());
assertEquals(nestedDocumentReference, request.getValue().getDestination());
assertNull(getService().convertToNestedDocument(nestedDocumentReference));
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method moveWithPR.
@Test
public void moveWithPR() throws Exception {
MoveRequest request = new MoveRequest();
request.setCheckRights(false);
DocumentReference bobReference = new DocumentReference("wiki", "Users", "Bob");
request.setUserReference(bobReference);
ContextualAuthorizationManager authorization = this.mocker.getInstance(ContextualAuthorizationManager.class);
when(authorization.hasAccess(Right.PROGRAM)).thenReturn(true);
getService().move(request);
assertFalse(request.isCheckRights());
assertEquals(bobReference, request.getUserReference());
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method rename.
@Test
public void rename() throws Exception {
SpaceReference spaceReference = new SpaceReference("Alice", new SpaceReference("Users", new WikiReference("dev")));
getService().rename(spaceReference, "Bob");
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
verify(this.jobExecutor).execute(eq(RefactoringJobs.RENAME), request.capture());
assertEquals(RefactoringJobs.RENAME, request.getValue().getJobType());
assertEquals(Arrays.asList(spaceReference), request.getValue().getEntityReferences());
assertEquals(new SpaceReference("Bob", spaceReference.getParent()), request.getValue().getDestination());
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method moveWithException.
@Test
public void moveWithException() throws Exception {
MoveRequest request = new MoveRequest();
JobException exception = new JobException("Some error message");
when(this.jobExecutor.execute(RefactoringJobs.MOVE, request)).thenThrow(exception);
assertNull(getService().move(request));
assertSame(exception, getService().getLastError());
}
Aggregations