UserTokenService { public String publishToken(final Server server, final SUser user) { UserToken userToken = UserToken.newToken(user.getId(), sessionIdGenerator.generateSessionId(), server.getId()); UserTokenCache.getInstance().put(userToken); String mergedStoreValue = getAndMergeToStoredValue(userToken); customKvStoreService.set(SESSION_STORE, userToken.getUserId(), mergedStoreValue, sessionExpireSec, server); return userToken.toBearerToken(); }  String publishToken(final Server server, final SUser user); void validateToken(UserToken token); public int sessionExpireSec; public int SessionTouchThresholdSec; }
@Test public void publishToken() { String bearer = sut.publishToken(server, new SUser(vutUserId)); UserToken fromBearer = UserToken.fromBearerToken(bearer); assertEquals(vutUserId, fromBearer.getUserId()); }