use of example.UpdateAndCreate in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionOverwrittenForAttributeFailureCase.
@Test
public void createPermissionOverwrittenForAttributeFailureCase() {
com.yahoo.elide.core.RequestScope userFourScope = new TestRequestScope(tx, userFour, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userFourScope)).thenReturn(updateAndCreateNewObject);
assertThrows(ForbiddenAccessException.class, () -> {
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userFourScope, Optional.of("7"));
created.updateAttribute("alias", "");
});
}
use of example.UpdateAndCreate in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionCheckFieldAnnotationForCreatingAnEntitySuccessCase.
// Create allowed based on field level expression
@Test
public void createPermissionCheckFieldAnnotationForCreatingAnEntitySuccessCase() {
com.yahoo.elide.core.RequestScope userThreeScope = new TestRequestScope(tx, userThree, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userThreeScope)).thenReturn(updateAndCreateNewObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userThreeScope, Optional.of("2"));
created.getRequestScope().getPermissionExecutor().executeCommitChecks();
}
use of example.UpdateAndCreate in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionCheckFieldAnnotationForCreatingAnEntityFailureCase.
// Create denied based on field level expression
@Test
public void createPermissionCheckFieldAnnotationForCreatingAnEntityFailureCase() {
com.yahoo.elide.core.RequestScope userFourScope = new TestRequestScope(tx, userFour, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userFourScope)).thenReturn(updateAndCreateNewObject);
assertThrows(ForbiddenAccessException.class, () -> com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userFourScope, Optional.of("3")));
}
use of example.UpdateAndCreate in project elide by yahoo.
the class UpdateOnCreateTest method createPermissionCheckClassAnnotationForCreatingAnEntitySuccessCase.
// ----------------------------------------- ** Entity Creation ** -------------------------------------------------
// Create allowed based on class level expression
@Test
public void createPermissionCheckClassAnnotationForCreatingAnEntitySuccessCase() {
com.yahoo.elide.core.RequestScope userOneScope = new TestRequestScope(tx, userOne, dictionary);
UpdateAndCreate updateAndCreateNewObject = new UpdateAndCreate();
when(tx.createNewObject(ClassType.of(UpdateAndCreate.class), userOneScope)).thenReturn(updateAndCreateNewObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> created = com.yahoo.elide.core.PersistentResource.createObject(ClassType.of(UpdateAndCreate.class), userOneScope, Optional.of("1"));
created.getRequestScope().getPermissionExecutor().executeCommitChecks();
}
use of example.UpdateAndCreate in project elide by yahoo.
the class UpdateOnCreateTest method updatePermissionOverwrittenForAttributeSuccessCase.
// Class level expression overwritten by field level expression
@Test
public void updatePermissionOverwrittenForAttributeSuccessCase() {
com.yahoo.elide.core.RequestScope userFourScope = new TestRequestScope(tx, userFour, dictionary);
UpdateAndCreate updateAndCreateExistingObject = new UpdateAndCreate();
when(tx.loadObject(any(), eq(1L), any(com.yahoo.elide.core.RequestScope.class))).thenReturn(updateAndCreateExistingObject);
com.yahoo.elide.core.PersistentResource<UpdateAndCreate> loaded = com.yahoo.elide.core.PersistentResource.loadRecord(EntityProjection.builder().type(UpdateAndCreate.class).build(), "1", userFourScope);
loaded.updateAttribute("alias", "");
loaded.getRequestScope().getPermissionExecutor().executeCommitChecks();
}
Aggregations