use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createDocumentDeep.
@Test
public void createDocumentDeep() throws Throwable {
DocumentReference spaceHomeReference = new DocumentReference("wiki", "Space", "WebHome");
DocumentReference templateHomeReference = new DocumentReference("wiki", Arrays.asList("Code", "Template"), "WebHome");
DocumentReference templateDocumentReference = new DocumentReference("Index", templateHomeReference.getLastSpaceReference());
when(this.modelBridge.getDocumentReferences(templateHomeReference.getLastSpaceReference())).thenReturn(Arrays.asList(templateDocumentReference));
when(this.modelBridge.exists(templateDocumentReference)).thenReturn(true);
DocumentReference newDocumentReference = new DocumentReference("Index", spaceHomeReference.getLastSpaceReference());
when(this.modelBridge.exists(newDocumentReference)).thenReturn(false);
CreateRequest request = createRequest(spaceHomeReference, templateHomeReference);
request.setCheckRights(false);
request.setDeep(true);
run(request);
verify(this.modelBridge).copy(templateDocumentReference, newDocumentReference);
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method skipDocumentCreation.
@Test
public void skipDocumentCreation() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
CreateRequest request = createRequest(documentReference, null);
request.setSkippedEntities(Arrays.<EntityReference>asList(documentReference));
run(request);
verifyNoCreate();
verify(this.mocker.getMockedLogger()).debug("Skipping creation of document [{}], as specified in the request.", documentReference);
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createDocumentFromTemplate.
@Test
public void createDocumentFromTemplate() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(false);
DocumentReference templateReference = new DocumentReference("wiki", "Code", "Template");
when(this.modelBridge.exists(templateReference)).thenReturn(true);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
CreateRequest request = createRequest(documentReference, templateReference);
request.setUserReference(userReference);
request.setCheckRights(false);
run(request);
verify(this.modelBridge).setContextUserReference(userReference);
verify(this.modelBridge).copy(templateReference, documentReference);
verify(this.modelBridge).removeLock(documentReference);
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createDocumentWithoutTemplate.
@Test
public void createDocumentWithoutTemplate() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(false);
CreateRequest request = createRequest(documentReference, null);
request.setCheckRights(false);
run(request);
verify(this.modelBridge).create(documentReference);
verify(this.modelBridge).removeLock(documentReference);
verify(this.modelBridge, never()).copy(any(DocumentReference.class), any(DocumentReference.class));
}
use of org.xwiki.refactoring.job.CreateRequest in project xwiki-platform by xwiki.
the class CreateJobTest method createDocumentFromMissingTemplate.
@Test
public void createDocumentFromMissingTemplate() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(false);
DocumentReference templateReference = new DocumentReference("wiki", "Code", "Template");
when(this.modelBridge.exists(templateReference)).thenReturn(false);
CreateRequest request = createRequest(documentReference, templateReference);
request.setCheckRights(false);
run(request);
verifyNoCreate();
verify(this.mocker.getMockedLogger()).error("Template document [{}] does not exist.", templateReference);
}
Aggregations