PDDocumentAccessPermission { public void ensureOwnerPermissions() throws TaskPermissionsException { if (!Boolean.getBoolean(Sejda.UNETHICAL_READ_PROPERTY_NAME) && !permissions.isOwnerPermission()) { throw new TaskPermissionsException("Owner permission is required."); } } PDDocumentAccessPermission(PDDocument document); void ensureOwnerPermissions(); void ensurePermission(PdfAccessPermission required);  }
@Test(expected = TaskPermissionsException.class) public void testNotOwner() throws TaskPermissionsException { when(permission.isOwnerPermission()).thenReturn(Boolean.FALSE); victim.ensureOwnerPermissions(); }
@Test public void testOwner() throws TaskPermissionsException { when(permission.isOwnerPermission()).thenReturn(Boolean.TRUE); victim.ensureOwnerPermissions(); }
@Test public void testOwnerUnethical() throws TaskPermissionsException { when(permission.isOwnerPermission()).thenReturn(Boolean.FALSE); System.setProperty(Sejda.UNETHICAL_READ_PROPERTY_NAME, "true"); victim.ensureOwnerPermissions(); System.setProperty(Sejda.UNETHICAL_READ_PROPERTY_NAME, "false"); }