use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class RenameJobTest method convertNotTerminalDocumentToTerminalDocumentPreservingChildren.
@Test
public void convertNotTerminalDocumentToTerminalDocumentPreservingChildren() throws Throwable {
DocumentReference nonTerminalReference = new DocumentReference("wiki", "One", "WebHome");
DocumentReference terminalReference = new DocumentReference("wiki", "Zero", "One");
MoveRequest request = createRequest(nonTerminalReference, terminalReference);
request.setDeep(true);
run(request);
verifyNoMove();
verify(this.mocker.getMockedLogger()).error("You cannot transform a non-terminal document [{}] into a terminal document [{}]" + " and preserve its child documents at the same time.", nonTerminalReference, terminalReference);
}
use of org.xwiki.model.reference.DocumentReference 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.model.reference.DocumentReference 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.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method create.
@Test
public void create() throws Exception {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
getService().create(documentReference);
ArgumentCaptor<CreateRequest> request = ArgumentCaptor.forClass(CreateRequest.class);
verify(this.jobExecutor).execute(eq(RefactoringJobs.CREATE), request.capture());
assertEquals(RefactoringJobs.CREATE, request.getValue().getJobType());
assertEquals(Arrays.asList(documentReference), request.getValue().getEntityReferences());
assertTrue(request.getValue().isDeep());
}
use of org.xwiki.model.reference.DocumentReference 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());
}
Aggregations