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.
This is not automatically available. If you wish to use this class in your Tenant testing, you must set the application.properties setting to:
ebean.test.registerTestTenantProvider=trueor application-test.yaml:
ebean:
test:
registerTestTenantProvider: true
.
If set to true, the ebean-test-config plugin will check if there is 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
public static void reset()Clear both the current userId and tenantId. -
set
Set both the current userId and current tenantId.
-