Search in sources :

Example 86 with DocumentReference

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

Example 87 with DocumentReference

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

Example 88 with DocumentReference

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

Example 89 with DocumentReference

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());
}
Also used : CreateRequest(org.xwiki.refactoring.job.CreateRequest) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 90 with DocumentReference

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());
}
Also used : ContextualAuthorizationManager(org.xwiki.security.authorization.ContextualAuthorizationManager) MoveRequest(org.xwiki.refactoring.job.MoveRequest) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

DocumentReference (org.xwiki.model.reference.DocumentReference)1324 Test (org.junit.Test)711 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)482 BaseObject (com.xpn.xwiki.objects.BaseObject)250 XWikiContext (com.xpn.xwiki.XWikiContext)186 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)157 ArrayList (java.util.ArrayList)128 WikiReference (org.xwiki.model.reference.WikiReference)127 XWikiException (com.xpn.xwiki.XWikiException)121 EntityReference (org.xwiki.model.reference.EntityReference)113 SpaceReference (org.xwiki.model.reference.SpaceReference)96 XWiki (com.xpn.xwiki.XWiki)82 HashMap (java.util.HashMap)54 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)52 Expectations (org.jmock.Expectations)50 Before (org.junit.Before)50 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)46 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)45 AttachmentReference (org.xwiki.model.reference.AttachmentReference)44 Date (java.util.Date)42