use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method copyAs.
@Test
public void copyAs() throws Exception {
SpaceReference spaceReference = new SpaceReference("Alice", new SpaceReference("Users", new WikiReference("dev")));
getService().copyAs(spaceReference, "Bob");
ArgumentCaptor<MoveRequest> request = ArgumentCaptor.forClass(MoveRequest.class);
// The RENAME job can perform a COPY too.
verify(this.jobExecutor).execute(eq(RefactoringJobs.RENAME), request.capture());
assertEquals(RefactoringJobs.COPY_AS, request.getValue().getJobType());
assertEquals(Arrays.asList(spaceReference), request.getValue().getEntityReferences());
assertEquals(new SpaceReference("Bob", spaceReference.getParent()), request.getValue().getDestination());
assertFalse(request.getValue().isDeleteSource());
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class AbstractMoveJobTest method createRequest.
protected MoveRequest createRequest(EntityReference source, EntityReference destination) {
MoveRequest request = new MoveRequest();
request.setEntityReferences(Arrays.asList(source));
request.setDestination(destination);
return request;
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptService method createMoveRequest.
private MoveRequest createMoveRequest(String type, Collection<EntityReference> sources, EntityReference destination) {
MoveRequest request = new MoveRequest();
initEntityRequest(request, type, sources);
request.setDestination(destination);
request.setUpdateLinks(true);
request.setAutoRedirect(true);
request.setUpdateParentField(true);
return request;
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptService method createCopyRequest.
/**
* Creates a request to copy the specified source entities to the specified destination entity.
*
* @param sources specifies the entities to be copied
* @param destination specifies the place where to copy the entities (becomes the parent of the copies)
* @return the copy request
*/
public MoveRequest createCopyRequest(Collection<EntityReference> sources, EntityReference destination) {
MoveRequest request = createMoveRequest(RefactoringJobs.COPY, sources, destination);
request.setDeleteSource(false);
request.setUpdateParentField(false);
return request;
}
use of org.xwiki.refactoring.job.MoveRequest in project xwiki-platform by xwiki.
the class RefactoringScriptService method createCopyAsRequest.
/**
* Creates a request to copy the specified entity with a different reference.
*
* @param sourceReference the entity to copy
* @param copyReference the reference to use for the copy
* @return the copy-as request
*/
public MoveRequest createCopyAsRequest(EntityReference sourceReference, EntityReference copyReference) {
MoveRequest request = createMoveRequest(RefactoringJobs.COPY_AS, Arrays.asList(sourceReference), copyReference);
request.setDeleteSource(false);
request.setUpdateParentField(false);
return request;
}
Aggregations