use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class CreateJobTest method createExistingDocument.
@Test
public void createExistingDocument() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(true);
run(createRequest(documentReference, null));
verifyNoCreate();
verify(this.mocker.getMockedLogger()).warn("Skipping creation of document [{}] because it already exists.", documentReference);
}
use of org.xwiki.model.reference.DocumentReference 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.DocumentReference in project xwiki-platform by xwiki.
the class DeleteJobTest method deleteDocument.
@Test
public void deleteDocument() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(true);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
EntityRequest request = createRequest(documentReference);
request.setCheckRights(false);
request.setUserReference(userReference);
run(request);
verify(this.modelBridge).setContextUserReference(userReference);
verify(this.modelBridge).delete(documentReference);
}
use of org.xwiki.model.reference.DocumentReference 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);
}
use of org.xwiki.model.reference.DocumentReference in project xwiki-platform by xwiki.
the class EntityJobTest method processEachEntity.
@Test
public void processEachEntity() {
final List<EntityReference> references = new ArrayList<>();
NoopEntityJob job = new NoopEntityJob() {
@Override
protected void process(EntityReference entityReference) {
references.add(entityReference);
}
};
DocumentReference documentReference = new DocumentReference("chess", Arrays.asList("Path", "To"), "Success");
EntityRequest request = new EntityRequest();
request.setEntityReferences(documentReference.getReversedReferenceChain());
initialize(job, request);
job.run();
assertEquals(request.getEntityReferences(), references);
}
Aggregations