    @Test
    public void encodeEncodesSomethingThatProperlyDecodes() throws Exception {


        Map<String, Object> expected = new HashMap<>();
        expected.put("jti", "Expected JTI");
        expected.put("iss", ENTITY_IDENTIFIER);
        expected.put("sub", null);
        expected.put("aud", PLATFORM_IDENTIFIER);
        expected.put("iat", Long.valueOf(platformDate.getTime() / 1000));
        expected.put("nbf", Long.valueOf(platformDate.getTime() / 1000));
        expected.put("exp", Long.valueOf(platformDate.getTime() / 1000) + EXPIRE_SECONDS);
        Map<String, String> request = new HashMap<>();
        request.put("func", "S256");
        request.put("hash", "Hash Value");
        request.put("path", "/path/to/resource");
        request.put("meth", "OPTIONS");
        expected.put("request", request);

        String encoded = jwtService.encode(
                "Expected JTI",
                ENTITY_IDENTIFIER,
                null,
                platformDate,
                "OPTIONS",
                "/path/to/resource",
                "S256",
                "Hash Value"
        );
        JwtConsumer jwtConsumer = new JwtConsumerBuilder()
                .setVerificationKey(keyPair.getPublic())
                .setJwsAlgorithmConstraints(new AlgorithmConstraints(
                        AlgorithmConstraints.ConstraintType.WHITELIST,
                        AlgorithmIdentifiers.RSA_USING_SHA256
                ))
                .setSkipAllValidators()
                .build();

        Map<String, Object> actual = jwtConsumer.processToClaims(encoded).getClaimsMap();
        assertEquals(expected, actual);
    }