@Test(expected = UnresolvableKeyException.class)
public void testLoadHttpsJwksNonMathchingKidAndRefreshDeclined() throws Exception {

    JWTAuthContextInfo contextInfo = new JWTAuthContextInfo();
    contextInfo.setDecryptionKeyLocation("https://github.com/my_key.jwks");
    contextInfo.setJwksRefreshInterval(10);
    contextInfo.setForcedJwksRefreshInterval(10);
    DecryptionKeyLocationResolver keyLocationResolver = new DecryptionKeyLocationResolver(contextInfo) {
        protected HttpsJwks initializeHttpsJwks(String loc) {
            return mockedHttpsJwks;
        }
    };
    // token 'kid' is '1'
    when(encryption.getHeaders()).thenReturn(headers);
    when(headers.getStringHeaderValue(JsonWebKey.KEY_ID_PARAMETER)).thenReturn("1");
    RsaJsonWebKey jwk = RsaJwkGenerator.generateJwk(2048);
    // Return JWK Set with a non-matching JWK with 'kid' set to '2' 
    jwk.setKeyId("2");
    when(mockedHttpsJwks.getJsonWebKeys()).thenReturn(Collections.singletonList(jwk));
    // Refresh JWK Set and get a matching JWK with 'kid' set to '1'
    doAnswer((i) -> {
        jwk.setKeyId("1");
        return null;
    }).when(mockedHttpsJwks).refresh();
    keyLocationResolver = Mockito.spy(keyLocationResolver);
    assertEquals(jwk.getPrivateKey(), keyLocationResolver.resolveKey(encryption, emptyList()));
    assertNull(keyLocationResolver.key);
    // Return JWK Set with a non-matching JWK with 'kid' set to '2'
    jwk.setKeyId("2");
    keyLocationResolver.resolveKey(encryption, emptyList());
}