Search in sources :

Example 1 with DeletePermission

use of com.yahoo.elide.annotation.DeletePermission in project elide by yahoo.

the class PermissionExecutorTest method testDeleteCheckExpressionForNewlyCreatedObject.

@Test
public void testDeleteCheckExpressionForNewlyCreatedObject() {
    @Entity
    @Include(rootLevel = false)
    @DeletePermission(expression = "FailOp")
    class Model {
    }
    PersistentResource resource = newResource(new Model(), Model.class, true);
    RequestScope requestScope = resource.getRequestScope();
    requestScope.getDictionary().bindEntity(Model.class);
    assertEquals(ExpressionResult.DEFERRED, requestScope.getPermissionExecutor().checkPermission(DeletePermission.class, resource));
    assertThrows(ForbiddenAccessException.class, () -> requestScope.getPermissionExecutor().executeCommitChecks());
}
Also used : Entity(javax.persistence.Entity) PersistentResource(com.yahoo.elide.core.PersistentResource) Include(com.yahoo.elide.annotation.Include) DeletePermission(com.yahoo.elide.annotation.DeletePermission) RequestScope(com.yahoo.elide.core.RequestScope) Test(org.junit.jupiter.api.Test)

Aggregations

DeletePermission (com.yahoo.elide.annotation.DeletePermission)1 Include (com.yahoo.elide.annotation.Include)1 PersistentResource (com.yahoo.elide.core.PersistentResource)1 RequestScope (com.yahoo.elide.core.RequestScope)1 Entity (javax.persistence.Entity)1 Test (org.junit.jupiter.api.Test)1