WorkspaceNameResolver { public String getWorkspaceName() { try { SessionInfo sessionInfo = getSessionInfo(); return sessionInfo.getIdentity().getIdentifier(); } catch (Exception e) { String name = WorkspaceContext.get(); if (name == null || name.isEmpty()) { return GLOBAL_WORKSPACE_NAME; } else { return name; } } } WorkspaceNameResolver(); @Inject  WorkspaceNameResolver(BeanManager beanManager); String getWorkspaceName(); static final String GLOBAL_WORKSPACE_NAME; }
@Test public void testGlobalWorkspaceName() { String name = this.resolver.getWorkspaceName(); assertEquals(WorkspaceNameResolver.GLOBAL_WORKSPACE_NAME, name); }
@Test public void testContextWorkspaceName() { final String user = "hendrix"; WorkspaceContext.set(user); String name = this.resolver.getWorkspaceName(); assertEquals(user, name); }