String encode(JwtSession jwtSession) {
    checkIsStarted();
    return Jwts.builder()
      .claims(jwtSession.getProperties())
      .claim(LAST_REFRESH_TIME_PARAM, system2.now())
      .id(jwtSession.getSessionTokenUuid())
      .subject(jwtSession.getUserLogin())
      .issuedAt(new Date(system2.now()))
      .expiration(new Date(jwtSession.getExpirationTime()))
      .signWith(secretKey, SIGNATURE_ALGORITHM)
      .compact();
  }
@Test
  public void encode_fail_when_not_started() {
    JwtSession jwtSession = new JwtSession(USER_LOGIN, SESSION_TOKEN_UUID, addMinutes(new Date(), 10).getTime());
    assertThatThrownBy(() -> underTest.encode(jwtSession))
      .isInstanceOf(NullPointerException.class)
      .hasMessage("org.sonar.server.authentication.JwtSerializer not started");
  }