use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class RefactoringScriptService method createDeleteRequest.
/**
* Creates a request to delete the specified entities.
*
* @param entityReferences the entities to delete
* @return the delete request
*/
public EntityRequest createDeleteRequest(Collection<EntityReference> entityReferences) {
EntityRequest request = new EntityRequest();
initEntityRequest(request, RefactoringJobs.DELETE, entityReferences);
return request;
}
use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class DeleteJobTest method createRequest.
private EntityRequest createRequest(EntityReference... entityReference) {
EntityRequest request = new EntityRequest();
request.setEntityReferences(Arrays.asList(entityReference));
return request;
}
use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class DeleteJobTest method deleteDocumentWithoutDeleteRight.
@Test
public void deleteDocumentWithoutDeleteRight() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "Page");
when(this.modelBridge.exists(documentReference)).thenReturn(true);
DocumentReference userReference = new DocumentReference("wiki", "Users", "Alice");
when(this.authorization.hasAccess(Right.DELETE, userReference, documentReference)).thenReturn(false);
EntityRequest request = createRequest(documentReference);
request.setCheckRights(true);
request.setUserReference(userReference);
run(request);
verify(this.mocker.getMockedLogger()).error("You are not allowed to delete [{}].", documentReference);
verify(this.modelBridge, never()).delete(any(DocumentReference.class));
}
use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class DeleteJobTest method deleteSpaceHomeDeep.
@Test
public void deleteSpaceHomeDeep() throws Throwable {
DocumentReference documentReference = new DocumentReference("wiki", "Space", "WebHome");
EntityRequest request = createRequest(documentReference);
request.setDeep(true);
run(request);
// We only verify if the job fetches the documents from the space. The rest of the test is in #deleteSpace()
verify(this.modelBridge, atLeastOnce()).getDocumentReferences(documentReference.getLastSpaceReference());
}
use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class EntityJobTest method getGroupPath.
@Test
public void getGroupPath() {
NoopEntityJob job = new NoopEntityJob();
EntityRequest request = new EntityRequest();
DocumentReference aliceReference = new DocumentReference("chess", Arrays.asList("Path", "To"), "Alice");
request.setEntityReferences(aliceReference.getReversedReferenceChain());
initialize(job, request);
assertEquals(new JobGroupPath(Arrays.asList("refactoring", "chess")), job.getGroupPath());
DocumentReference bobReference = new DocumentReference("dev", Arrays.asList("Path", "To"), "Bob");
request.setEntityReferences(Arrays.<EntityReference>asList(aliceReference, bobReference));
initialize(job, request);
assertEquals(new JobGroupPath(Arrays.asList("refactoring")), job.getGroupPath());
DocumentReference carolReference = new DocumentReference("chess", Arrays.asList("Path", "To"), "Carol");
request.setEntityReferences(Arrays.<EntityReference>asList(aliceReference, carolReference));
initialize(job, request);
assertEquals(new JobGroupPath(Arrays.asList("refactoring", "chess", "Path", "To")), job.getGroupPath());
DocumentReference daveReference = new DocumentReference("chess", Arrays.asList("Path", "To2"), "Dave");
request.setEntityReferences(Arrays.<EntityReference>asList(aliceReference, carolReference, daveReference));
initialize(job, request);
assertEquals(new JobGroupPath(Arrays.asList("refactoring", "chess", "Path")), job.getGroupPath());
}
Aggregations