@Test
public void testGenerateToken() throws Exception {

	// GIVEN
	Instant start = Instant.now().minusSeconds(1);
	User userDetails = new User("username", "", asList(new SimpleGrantedAuthority("USER"), new SimpleGrantedAuthority("ADMIN")));
	Duration expiration = Duration.ofMinutes(30);
	
	// WHEN
	String token = jwtTokenUtil.generateToken(userDetails);
	
	
	// THEN
	assertThat(jwtTokenUtil.getUsernameFromToken(token)).isEqualTo("username");
	assertThat(jwtTokenUtil.getIssuedAtDateFromToken(token)).isBetween(start, Instant.now());
	assertThat(jwtTokenUtil.getExpirationDateFromToken(token)).isBetween(start.plus(expiration), Instant.now().plus(expiration));

	String[] roles = jwtTokenUtil.getClaimFromToken(token, c -> c.get(JwtTokenUtil.CLAIM_KEY_ROLES, String.class)).split(JwtTokenUtil.ROLES_CLAIM_DELIMITER);
	
	assertThat(roles).containsExactlyInAnyOrder("ADMIN", "USER");	
}