Gravatar { public static boolean imageExist(String email) { Objects.requireNonNull(email, "email required"); URL url; try { String emailHash = HashUtil.md5Hex(email); url = new URL(GRAVATAR_URL + emailHash + ".jpg?d=404"); } catch (MalformedURLException e) { return false; } try (InputStream stream = url.openStream()) { return stream.available()>0; } catch (IOException e) { return false; } }  static boolean imageExist(String email);  }
@Test public void should_find_image() { assertThat(Gravatar.imageExist("gui.ehret@gmail.com")).isTrue(); }
@Test public void should_not_find_image() { assertThat(Gravatar.imageExist("toto.tutu@gmail.com")).isFalse(); }