use of org.xwiki.refactoring.job.EntityRequest in project xwiki-platform by xwiki.
the class EntityJobTest method hasAccess.
@Test
public void hasAccess() {
EntityRequest request = mock(EntityRequest.class);
when(request.isCheckRights()).thenReturn(true, true, false);
DocumentReference userReference = new DocumentReference("foo", "Users", "Alice");
when(request.getUserReference()).thenReturn(userReference);
DocumentReference documentReference = new DocumentReference("math", "Space", "Page");
when(this.authorization.hasAccess(Right.EDIT, userReference, documentReference.getLastSpaceReference())).thenReturn(true);
when(this.authorization.hasAccess(Right.DELETE, userReference, documentReference)).thenReturn(false);
NoopEntityJob job = new NoopEntityJob();
initialize(job, request);
// checkRights = true
assertTrue(job.hasAccess(Right.EDIT, documentReference.getLastSpaceReference()));
assertFalse(job.hasAccess(Right.DELETE, documentReference));
// checkRights = false
assertTrue(job.hasAccess(Right.DELETE, documentReference));
}
Aggregations