public static <T> T checkFoundWithOptional(java.util.Optional<T> value, String message, Object... messageArguments) {
    if (!value.isPresent()) {
      throw new NotFoundException(format(message, messageArguments));
    }

    return value.get();
  }
@Test
  public void checkFoundWithOptional_throws_NotFoundException_if_empty_and_formats_message() {
    String message = "foo %s";
    assertThatExceptionOfType(NotFoundException.class)
      .isThrownBy(() -> checkFoundWithOptional(Optional.empty(), message, "bar"))
      .withMessage("foo bar");
  }