@Test public void shouldFailWithSendFailedExceptionBecauseCouldNotConnectToSMTPHost(){ ExceptionHandlingMailSendingTemplate doSendWithSendFailedException = new ExceptionHandlingMailSendingTemplate() { @Override protected boolean doSend(Emailer emailer) throws AddressException, SendFailedException, MessagingException { assertNotNull("emailer was constructed", emailer); MessagingException firstInnerException = new SendFailedException("Could not connect to SMTP host"); throw new SendFailedException(BY_OLAT_UNHANDLED_TEXT, firstInnerException); } @Override protected MailTemplate getMailTemplate() { return emptyMailTemplate; }; @Override protected List<ContactList> getTheToContactLists() { return theContactLists; } @Override protected Identity getFromIdentity() { return theFromIdentity; } }; MessageSendStatus sendStatus = doSendWithSendFailedException.send(); assertEquals(MessageSendStatusCode.SEND_FAILED_DUE_COULD_NOT_CONNECT_TO_SMTP_HOST, sendStatus.getStatusCode()); verifyStatusCodeIndicateSendFailedOnly(sendStatus); verifySendStatusIsError(sendStatus); assertTrue(sendStatus.canProceedWithWorkflow()); }
public MessageSendStatus send(){ final boolean useInstitutionalEmail = false; final Emailer emailer = new Emailer(getFromIdentity(), useInstitutionalEmail, getMailTemplate()); MessageSendStatus messageSendStatus = createSuccessfullSentEmailMessageStatus(); boolean sendEmailSuccess = false; try { sendEmailSuccess = doSend(emailer); } catch (final AddressException e) { messageSendStatus = handleAddressException(sendEmailSuccess); } catch (final SendFailedException e) { messageSendStatus = handleSendFailedException(e); } catch (final MessagingException e) { messageSendStatus = handleMessagingException(); } return messageSendStatus; }
ExceptionHandlingMailSendingTemplate { public MessageSendStatus send(){ final boolean useInstitutionalEmail = false; final Emailer emailer = new Emailer(getFromIdentity(), useInstitutionalEmail, getMailTemplate()); MessageSendStatus messageSendStatus = createSuccessfullSentEmailMessageStatus(); boolean sendEmailSuccess = false; try { sendEmailSuccess = doSend(emailer); } catch (final AddressException e) { messageSendStatus = handleAddressException(sendEmailSuccess); } catch (final SendFailedException e) { messageSendStatus = handleSendFailedException(e); } catch (final MessagingException e) { messageSendStatus = handleMessagingException(); } return messageSendStatus; } }
ExceptionHandlingMailSendingTemplate { public MessageSendStatus send(){ final boolean useInstitutionalEmail = false; final Emailer emailer = new Emailer(getFromIdentity(), useInstitutionalEmail, getMailTemplate()); MessageSendStatus messageSendStatus = createSuccessfullSentEmailMessageStatus(); boolean sendEmailSuccess = false; try { sendEmailSuccess = doSend(emailer); } catch (final AddressException e) { messageSendStatus = handleAddressException(sendEmailSuccess); } catch (final SendFailedException e) { messageSendStatus = handleSendFailedException(e); } catch (final MessagingException e) { messageSendStatus = handleMessagingException(); } return messageSendStatus; }  }
ExceptionHandlingMailSendingTemplate { public MessageSendStatus send(){ final boolean useInstitutionalEmail = false; final Emailer emailer = new Emailer(getFromIdentity(), useInstitutionalEmail, getMailTemplate()); MessageSendStatus messageSendStatus = createSuccessfullSentEmailMessageStatus(); boolean sendEmailSuccess = false; try { sendEmailSuccess = doSend(emailer); } catch (final AddressException e) { messageSendStatus = handleAddressException(sendEmailSuccess); } catch (final SendFailedException e) { messageSendStatus = handleSendFailedException(e); } catch (final MessagingException e) { messageSendStatus = handleMessagingException(); } return messageSendStatus; }  MessageSendStatus send(); }
ExceptionHandlingMailSendingTemplate { public MessageSendStatus send(){ final boolean useInstitutionalEmail = false; final Emailer emailer = new Emailer(getFromIdentity(), useInstitutionalEmail, getMailTemplate()); MessageSendStatus messageSendStatus = createSuccessfullSentEmailMessageStatus(); boolean sendEmailSuccess = false; try { sendEmailSuccess = doSend(emailer); } catch (final AddressException e) { messageSendStatus = handleAddressException(sendEmailSuccess); } catch (final SendFailedException e) { messageSendStatus = handleSendFailedException(e); } catch (final MessagingException e) { messageSendStatus = handleMessagingException(); } return messageSendStatus; }  MessageSendStatus send();  }