@Test
public void verifyThatKeyIsCached() throws InterruptedException, TimeoutException, ExecutionException {

    mockSuccessfulDiscoveryEndpointRequest();
    mockSuccessfulPublicKeysRequest();
    final Optional<PublicKey> publicKeyFromEndpoint =
            underTest.getPublicKey("google.com", KEY_ID).get(LATCH_TIMEOUT, TimeUnit.SECONDS);
    assertThat(publicKeyFromEndpoint).isNotEmpty();
    verify(httpClientMock).createSingleHttpRequest(DISCOVERY_ENDPOINT_REQUEST);
    verify(httpClientMock).createSingleHttpRequest(PUBLIC_KEYS_REQUEST);
    Mockito.clearInvocations(httpClientMock);
    final Optional<PublicKey> publicKeyFromCache =
            underTest.getPublicKey("google.com", KEY_ID).get(LATCH_TIMEOUT, TimeUnit.SECONDS);
    assertThat(publicKeyFromCache).contains(publicKeyFromEndpoint.get());
    assertThat(publicKeyFromCache).isNotEmpty();
    verifyNoMoreInteractions(httpClientMock);
}