@Test public void getMessageInternalSizeShouldReturnSizeWhenAvailable() throws MessagingException { long size = 42L; Mail mail = mock(Mail.class); when(mail.getMessageSize()).thenReturn(size); assertThat(NotifyMailetsMessage.getMessageSizeEstimation(mail)) .isEqualTo(Optional.of(size)); }
@VisibleForTesting static Optional<Long> getMessageSizeEstimation(Mail mail) { try { return Optional.of(mail.getMessageSize()) .filter(size -> size > 0); } catch (MessagingException e) { LOGGER.debug("Could not estimate mail size", e); return Optional.empty(); } }
NotifyMailetsMessage { @VisibleForTesting static Optional<Long> getMessageSizeEstimation(Mail mail) { try { return Optional.of(mail.getMessageSize()) .filter(size -> size > 0); } catch (MessagingException e) { LOGGER.debug("Could not estimate mail size", e); return Optional.empty(); } } }
NotifyMailetsMessage { @VisibleForTesting static Optional<Long> getMessageSizeEstimation(Mail mail) { try { return Optional.of(mail.getMessageSize()) .filter(size -> size > 0); } catch (MessagingException e) { LOGGER.debug("Could not estimate mail size", e); return Optional.empty(); } }  }
NotifyMailetsMessage { @VisibleForTesting static Optional<Long> getMessageSizeEstimation(Mail mail) { try { return Optional.of(mail.getMessageSize()) .filter(size -> size > 0); } catch (MessagingException e) { LOGGER.debug("Could not estimate mail size", e); return Optional.empty(); } }  String generateMessage(String parameterMessage, Mail originalMail); }
NotifyMailetsMessage { @VisibleForTesting static Optional<Long> getMessageSizeEstimation(Mail mail) { try { return Optional.of(mail.getMessageSize()) .filter(size -> size > 0); } catch (MessagingException e) { LOGGER.debug("Could not estimate mail size", e); return Optional.empty(); } }  String generateMessage(String parameterMessage, Mail originalMail);  }