use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class MoveJobTest method moveToUnsupportedDestination.
@Test
public void moveToUnsupportedDestination() throws Throwable {
run(createRequest(new DocumentReference("wiki", "Space", "Page"), new WikiReference("test")));
verify(this.mocker.getMockedLogger()).error("Unsupported destination entity type [{}] for a document.", EntityType.WIKI);
run(createRequest(new DocumentReference("wiki", "Space", "Page"), new DocumentReference("test", "A", "B")));
verify(this.mocker.getMockedLogger()).error("Unsupported destination entity type [{}] for a document.", EntityType.DOCUMENT);
run(createRequest(new SpaceReference("Space", new WikiReference("wiki")), new DocumentReference("test", "A", "B")));
verify(this.mocker.getMockedLogger()).error("Unsupported destination entity type [{}] for a space.", EntityType.DOCUMENT);
verifyNoMove();
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class MoveJobTest method moveSpaceToSpaceHome.
@Test
public void moveSpaceToSpaceHome() throws Throwable {
SpaceReference sourceSpace = new SpaceReference("wiki", "A", "B");
DocumentReference sourceDoc = new DocumentReference("X", sourceSpace);
when(this.modelBridge.getDocumentReferences(sourceSpace)).thenReturn(Arrays.asList(sourceDoc));
when(this.modelBridge.exists(sourceDoc)).thenReturn(true);
DocumentReference destination = new DocumentReference("wiki", "C", "WebHome");
MoveRequest request = createRequest(sourceSpace, destination);
request.setCheckRights(false);
run(request);
verify(this.modelBridge).copy(sourceDoc, new DocumentReference("wiki", Arrays.asList("C", "B"), "X"));
}
use of org.xwiki.model.reference.SpaceReference 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.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class CreateJobTest method createSpaceFromTemplate.
@Test
public void createSpaceFromTemplate() throws Throwable {
SpaceReference newSpaceReference = new SpaceReference("wiki", "Space");
SpaceReference templateSpaceReference = new SpaceReference("wiki", "Code", "Template");
DocumentReference templateDocumentReference = new DocumentReference("Index", templateSpaceReference);
when(this.modelBridge.getDocumentReferences(templateSpaceReference)).thenReturn(Arrays.asList(templateDocumentReference));
when(this.modelBridge.exists(templateDocumentReference)).thenReturn(true);
DocumentReference newDocumentReference = new DocumentReference("Index", newSpaceReference);
when(this.modelBridge.exists(newDocumentReference)).thenReturn(false);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
CreateRequest request = createRequest(newSpaceReference, templateSpaceReference);
request.setUserReference(userReference);
request.setCheckRights(false);
run(request);
verify(this.modelBridge).setContextUserReference(userReference);
verify(this.modelBridge).copy(templateDocumentReference, newDocumentReference);
verify(this.modelBridge, never()).removeLock(any(DocumentReference.class));
}
use of org.xwiki.model.reference.SpaceReference in project xwiki-platform by xwiki.
the class DeleteJobTest method deleteSpace.
@Test
public void deleteSpace() throws Throwable {
SpaceReference spaceReference = new SpaceReference("Space", new WikiReference("wiki"));
DocumentReference aliceReference = new DocumentReference("wiki", "Space", "Alice");
DocumentReference bobReference = new DocumentReference("wiki", "Space", "Bob");
when(this.modelBridge.getDocumentReferences(spaceReference)).thenReturn(Arrays.asList(aliceReference, bobReference));
run(createRequest(spaceReference));
// We only verify that the code tries to delete the documents.
verify(this.mocker.getMockedLogger()).warn("Skipping [{}] because it doesn't exist.", aliceReference);
verify(this.mocker.getMockedLogger()).warn("Skipping [{}] because it doesn't exist.", bobReference);
}
Aggregations