### Question:
AuthenticationService { public String createJwtToken(String username, String domain, String ltpaToken) { long now = System.currentTimeMillis(); long expiration = calculateExpiration(now, username); return Jwts.builder() .setSubject(username) .claim(DOMAIN_CLAIM_NAME, domain) .claim(LTPA_CLAIM_NAME, ltpaToken) .setIssuedAt(new Date(now)) .setExpiration(new Date(expiration)) .setIssuer(authConfigurationProperties.getTokenProperties().getIssuer()) .setId(UUID.randomUUID().toString()) .signWith(jwtSecurityInitializer.getJwtSecret(), jwtSecurityInitializer.getSignatureAlgorithm()) .compact(); }  @PostConstruct void afterPropertiesSet(); String createJwtToken(String username, String domain, String ltpaToken); @CacheEvict(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken") @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, key = "#jwtToken", condition = "#jwtToken != null") Boolean invalidateJwtToken(String jwtToken, boolean distribute); @Cacheable(value = CACHE_INVALIDATED_JWT_TOKENS, unless = "true", key = "#jwtToken", condition = "#jwtToken != null") Boolean isInvalidated(String jwtToken); @Cacheable(value = CACHE_VALIDATION_JWT_TOKEN, key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication validateJwtToken(String jwtToken); @CachePut(value = "validationJwtToken", key = "#jwtToken", condition = "#jwtToken != null") TokenAuthentication createTokenAuthentication(String user, String jwtToken); boolean distributeInvalidate(String toInstanceId); TokenAuthentication validateJwtToken(TokenAuthentication token); QueryResponse parseJwtToken(String jwtToken); Optional<String> getJwtTokenFromRequest(HttpServletRequest request); String getLtpaTokenWithValidation(String jwtToken); String getLtpaToken(String jwtToken);  }### Answer:
@Test void shouldCreateJwtToken() { String jwtToken = authService.createJwtToken(USER, DOMAIN, LTPA); assertFalse(jwtToken.isEmpty()); assertEquals("java.lang.String", jwtToken.getClass().getName()); }
@Test void shouldThrowExceptionWithNullSecret() { when(jwtSecurityInitializer.getJwtSecret()).thenReturn(null); assertThrows( IllegalArgumentException.class, () -> authService.createJwtToken(USER, DOMAIN, LTPA) ); }