### Question:
TokenGenerator { public String createOrLoadToken(final HttpSession session) { Object apiTokenFromClient = session.getAttribute(API_TOKEN); if (apiTokenFromClient == null) { apiTokenFromClient = new APIToken().getToken(); session.setAttribute(API_TOKEN, apiTokenFromClient); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Bonita API Token generated: " + apiTokenFromClient); } } return apiTokenFromClient.toString(); }  @Deprecated void setTokenToResponseCookie(HttpServletRequest request, HttpServletResponse res, Object apiTokenFromClient); String createOrLoadToken(final HttpSession session); void setTokenToResponseHeader(final HttpServletResponse res, final String token); static final String API_TOKEN; static final String X_BONITA_API_TOKEN; }### Answer:
@Test public void should_create_token_and_store_it_in_session() throws Exception { final String token = tokenGenerator.createOrLoadToken(session); assertThat(token).isNotEmpty(); assertThat(session.getAttribute(TokenGenerator.API_TOKEN)).isEqualTo(token); }
@Test public void should_load_token_from_session() throws Exception { session.setAttribute(TokenGenerator.API_TOKEN, BONITA_TOKEN_VALUE); final String token = tokenGenerator.createOrLoadToken(session); assertThat(token).isNotEmpty(); assertThat(token).isEqualTo(BONITA_TOKEN_VALUE); }