@Test void getFilenameShouldReturnRandomFilenameWhenExceptionOccured() throws Exception { BodyPart bodyPart = mock(BodyPart.class); when(bodyPart.getFileName()) .thenThrow(new MessagingException()); StripAttachment mailet = new StripAttachment(); String filename = mailet.getFilename(bodyPart); assertThat(filename).isNotNull(); }
@VisibleForTesting String getFilename(BodyPart bodyPart) { try { String fileName = bodyPart.getFileName(); if (fileName != null) { return renameWithConfigurationPattern(decodeFilename(fileName)); } } catch (Exception e) { LOGGER.warn("Unparsable filename, using a random filename instead.", e); } return randomFilename(); }
StripAttachment extends GenericMailet { @VisibleForTesting String getFilename(BodyPart bodyPart) { try { String fileName = bodyPart.getFileName(); if (fileName != null) { return renameWithConfigurationPattern(decodeFilename(fileName)); } } catch (Exception e) { LOGGER.warn("Unparsable filename, using a random filename instead.", e); } return randomFilename(); } }
StripAttachment extends GenericMailet { @VisibleForTesting String getFilename(BodyPart bodyPart) { try { String fileName = bodyPart.getFileName(); if (fileName != null) { return renameWithConfigurationPattern(decodeFilename(fileName)); } } catch (Exception e) { LOGGER.warn("Unparsable filename, using a random filename instead.", e); } return randomFilename(); }  }
StripAttachment extends GenericMailet { @VisibleForTesting String getFilename(BodyPart bodyPart) { try { String fileName = bodyPart.getFileName(); if (fileName != null) { return renameWithConfigurationPattern(decodeFilename(fileName)); } } catch (Exception e) { LOGGER.warn("Unparsable filename, using a random filename instead.", e); } return randomFilename(); }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo(); }
StripAttachment extends GenericMailet { @VisibleForTesting String getFilename(BodyPart bodyPart) { try { String fileName = bodyPart.getFileName(); if (fileName != null) { return renameWithConfigurationPattern(decodeFilename(fileName)); } } catch (Exception e) { LOGGER.warn("Unparsable filename, using a random filename instead.", e); } return randomFilename(); }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo(); static final String PATTERN_PARAMETER_NAME; static final String NOTPATTERN_PARAMETER_NAME; static final String MIMETYPE_PARAMETER_NAME; static final String ATTRIBUTE_PARAMETER_NAME; static final String DIRECTORY_PARAMETER_NAME; static final String REMOVE_ATTACHMENT_PARAMETER_NAME; static final String DECODE_FILENAME_PARAMETER_NAME; static final String REPLACE_FILENAME_PATTERN_PARAMETER_NAME; static final String REMOVE_NONE; static final String REMOVE_ALL; static final String REMOVE_MATCHED; static final AttributeName REMOVED_ATTACHMENTS; static final AttributeName SAVED_ATTACHMENTS; static final boolean DECODE_FILENAME_DEFAULT_VALUE; }