@Test public void textMailsShouldNotBeMatched() throws Exception { mimeMessage.setText("A simple text message"); assertThat(testee.match(mail)).isNull(); }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Exception anException = null; try { MimeMessage message = mail.getMessage(); Object content; if (message.getContentType() == null) { return null; } content = message.getContent(); if (content instanceof Multipart) { Multipart multipart = (Multipart) content; for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); if (isAttachment(part)) { return mail.getRecipients(); } } catch (MessagingException e) { anException = e; } } } else { if (isAttachment(message)) { return mail.getRecipients(); } } } catch (Exception e) { anException = e; } if (anException != null) { throw new MessagingException("Malformed message", anException); } return null; }
HasAttachment extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Exception anException = null; try { MimeMessage message = mail.getMessage(); Object content; if (message.getContentType() == null) { return null; } content = message.getContent(); if (content instanceof Multipart) { Multipart multipart = (Multipart) content; for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); if (isAttachment(part)) { return mail.getRecipients(); } } catch (MessagingException e) { anException = e; } } } else { if (isAttachment(message)) { return mail.getRecipients(); } } } catch (Exception e) { anException = e; } if (anException != null) { throw new MessagingException("Malformed message", anException); } return null; } }
HasAttachment extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Exception anException = null; try { MimeMessage message = mail.getMessage(); Object content; if (message.getContentType() == null) { return null; } content = message.getContent(); if (content instanceof Multipart) { Multipart multipart = (Multipart) content; for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); if (isAttachment(part)) { return mail.getRecipients(); } } catch (MessagingException e) { anException = e; } } } else { if (isAttachment(message)) { return mail.getRecipients(); } } } catch (Exception e) { anException = e; } if (anException != null) { throw new MessagingException("Malformed message", anException); } return null; }  }
HasAttachment extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Exception anException = null; try { MimeMessage message = mail.getMessage(); Object content; if (message.getContentType() == null) { return null; } content = message.getContent(); if (content instanceof Multipart) { Multipart multipart = (Multipart) content; for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); if (isAttachment(part)) { return mail.getRecipients(); } } catch (MessagingException e) { anException = e; } } } else { if (isAttachment(message)) { return mail.getRecipients(); } } } catch (Exception e) { anException = e; } if (anException != null) { throw new MessagingException("Malformed message", anException); } return null; }  @Override Collection<MailAddress> match(Mail mail); }
HasAttachment extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { Exception anException = null; try { MimeMessage message = mail.getMessage(); Object content; if (message.getContentType() == null) { return null; } content = message.getContent(); if (content instanceof Multipart) { Multipart multipart = (Multipart) content; for (int i = 0; i < multipart.getCount(); i++) { try { Part part = multipart.getBodyPart(i); if (isAttachment(part)) { return mail.getRecipients(); } } catch (MessagingException e) { anException = e; } } } else { if (isAttachment(message)) { return mail.getRecipients(); } } } catch (Exception e) { anException = e; } if (anException != null) { throw new MessagingException("Malformed message", anException); } return null; }  @Override Collection<MailAddress> match(Mail mail);  }