Package io.ebean.test
Class UserContext
java.lang.Object
io.ebean.test.UserContext
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
Modifier and TypeMethodDescriptionstatic ObjectReturn the current tenantId.static ObjectReturn the current user.static voidreset()Clear both the current userId and tenantId.static voidSet both the current userId and current tenantId.static voidsetTenantId(Object tenantId) Set the current tenantId.static voidSet the current userId - this value is put into 'WhoCreated' and 'WhoModified' properties.
-
Method Details
-
currentUserId
Return the current user. -
currentTenantId
Return the current tenantId. -
setUserId
Set the current userId - this value is put into 'WhoCreated' and 'WhoModified' properties. -
setTenantId
Set the current tenantId. -
reset
Clear both the current userId and tenantId. -
set
Set both the current userId and current tenantId.
-