@Test
public void badJson() {

    stubFor(any(urlPathEqualTo("/latest/api/token")).willReturn(notFound()));
    stubFor(any(urlPathEqualTo("/latest/dynamic/instance-identity/document"))
                .willReturn(okJson("I'm not JSON")));
    Map<EC2MetadataFetcher.EC2Metadata, String> metadata = fetcher.fetch();
    assertThat(metadata).isEmpty();
    verify(putRequestedFor(urlEqualTo("/latest/api/token"))
               .withHeader("X-aws-ec2-metadata-token-ttl-seconds", equalTo("60")));
    verify(getRequestedFor(urlEqualTo("/latest/dynamic/instance-identity/document"))
               .withoutHeader("X-aws-ec2-metadata-token"));
}