Package io.ebean.test
Class UserContext
- java.lang.Object
-
- io.ebean.test.UserContext
-
public class UserContext extends Object
Use in test code when the CurrentUserProvider and/or CurrentTenantProvider were configured by this ebean-test-config plugin.That is, the ebean-test-config plugin will check if there ia a CurrentUserProvider and if not automatically set one and that provider reads the 'current user' from this UserContext.
// set the current userId which will be put // into 'WhoCreated' and 'WhoModified' properties UserContext.setUserId("U1"); // persist bean that has ... a 'WhoModified' property Content content = new Content(); content.setName("hello"); content.save();
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectcurrentTenantId()Return the current tenantId.static ObjectcurrentUserId()Return the current user.static voidreset()Clear both the current userId and tenantId.static voidset(Object userId, String tenantId)Set both the current userId and current tenantId.static voidsetTenantId(Object tenantId)Set the current tenantId.static voidsetUserId(Object userId)Set the current userId - this value is put into 'WhoCreated' and 'WhoModified' properties.
-
-
-
Method Detail
-
currentUserId
public static Object currentUserId()
Return the current user.
-
currentTenantId
public static Object currentTenantId()
Return the current tenantId.
-
setUserId
public static void setUserId(Object userId)
Set the current userId - this value is put into 'WhoCreated' and 'WhoModified' properties.
-
setTenantId
public static void setTenantId(Object tenantId)
Set the current tenantId.
-
reset
public static void reset()
Clear both the current userId and tenantId.
-
-