@Override
   public JwtAuthenticationToken convert(Jwt jwt) {
      Map<String, Map<String, Collection<String>>> resourceAccess = jwt
            .getClaim(KeycloakJwtToken.RESOURCE_ACCESS_TOKEN_CLAIM);

      if (resourceAccess != null) {
         Map<String, Collection<String>> microcksResource = resourceAccess.get(KeycloakJwtToken.MICROCKS_APP_RESOURCE);

         if (microcksResource != null) {
            Collection<String> roles = microcksResource.get("roles");
            log.trace("JWT extracted roles for microcks-app: {}", roles);

            var grantedAuthorities = roles.stream().map(role -> new SimpleGrantedAuthority("ROLE_" + role)).toList();
            return new JwtAuthenticationToken(jwt, grantedAuthorities);
         }
      }
      return new JwtAuthenticationToken(jwt, Collections.emptyList());
   }
@Test
   void testConvert() {
      MicrocksJwtConverter converter = new MicrocksJwtConverter();
      Jwt jwt = null;

      try {
         JWT parsedJwt = JWTParser.parse(jwtBearer);
         jwt = createJwt(jwtBearer, parsedJwt);
      } catch (Exception e) {
         fail("Parsing Jwt bearer should not fail");
      }

      // Convert and assert granted authorities.
      JwtAuthenticationToken authenticationToken = converter.convert(jwt);

      assertTrue(authenticationToken.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_user")));
      assertTrue(authenticationToken.getAuthorities().contains(new SimpleGrantedAuthority("ROLE_manager")));
   }