@Test public void onSendMessageSuccess() throws Exception { MailStatusStore mailStatusStore = this.mocker.getInstance(MailStatusStore.class, "database"); MailStatus status = new MailStatus(this.batchId, this.message, MailState.PREPARE_SUCCESS); status.setWiki("otherwiki"); when(mailStatusStore.load(this.messageId)).thenReturn(status); MailListener listener = this.mocker.getComponentUnderTest(); listener.onPrepareBegin(batchId, Collections.<String, Object>emptyMap()); listener.onSendMessageSuccess(this.message, Collections.<String, Object>emptyMap()); verify(mailStatusStore).load(this.messageId); verify(mailStatusStore).save(argThat(new isSameMailStatus(MailState.SEND_SUCCESS, "otherwiki")), anyMap()); MailContentStore mailContentStore = this.mocker.getInstance(MailContentStore.class, "filesystem"); verify(mailContentStore).delete(this.batchId, this.messageId); }
@Override public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) { super.onSendMessageSuccess(message, parameters); String uniqueMessageId = message.getUniqueMessageId(); MailStatus status = retrieveExistingMailStatus(uniqueMessageId, MailState.SEND_SUCCESS); if (status != null) { status.setState(MailState.SEND_SUCCESS); } else { this.logger.warn("Forcing a new mail status for message [{}] of batch [{}] to send_success state.", uniqueMessageId, getBatchId()); status = new MailStatus(getBatchId(), message, MailState.SEND_SUCCESS); } deleteMailContent(status); if (configuration.discardSuccessStatuses()) { deleteStatus(status, parameters); } else { saveStatus(status, parameters); } mailStatusResult.incrementCurrentSize(); }
DatabaseMailListener extends AbstractMailListener implements Initializable { @Override public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) { super.onSendMessageSuccess(message, parameters); String uniqueMessageId = message.getUniqueMessageId(); MailStatus status = retrieveExistingMailStatus(uniqueMessageId, MailState.SEND_SUCCESS); if (status != null) { status.setState(MailState.SEND_SUCCESS); } else { this.logger.warn("Forcing a new mail status for message [{}] of batch [{}] to send_success state.", uniqueMessageId, getBatchId()); status = new MailStatus(getBatchId(), message, MailState.SEND_SUCCESS); } deleteMailContent(status); if (configuration.discardSuccessStatuses()) { deleteStatus(status, parameters); } else { saveStatus(status, parameters); } mailStatusResult.incrementCurrentSize(); } }
DatabaseMailListener extends AbstractMailListener implements Initializable { @Override public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) { super.onSendMessageSuccess(message, parameters); String uniqueMessageId = message.getUniqueMessageId(); MailStatus status = retrieveExistingMailStatus(uniqueMessageId, MailState.SEND_SUCCESS); if (status != null) { status.setState(MailState.SEND_SUCCESS); } else { this.logger.warn("Forcing a new mail status for message [{}] of batch [{}] to send_success state.", uniqueMessageId, getBatchId()); status = new MailStatus(getBatchId(), message, MailState.SEND_SUCCESS); } deleteMailContent(status); if (configuration.discardSuccessStatuses()) { deleteStatus(status, parameters); } else { saveStatus(status, parameters); } mailStatusResult.incrementCurrentSize(); }  }
DatabaseMailListener extends AbstractMailListener implements Initializable { @Override public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) { super.onSendMessageSuccess(message, parameters); String uniqueMessageId = message.getUniqueMessageId(); MailStatus status = retrieveExistingMailStatus(uniqueMessageId, MailState.SEND_SUCCESS); if (status != null) { status.setState(MailState.SEND_SUCCESS); } else { this.logger.warn("Forcing a new mail status for message [{}] of batch [{}] to send_success state.", uniqueMessageId, getBatchId()); status = new MailStatus(getBatchId(), message, MailState.SEND_SUCCESS); } deleteMailContent(status); if (configuration.discardSuccessStatuses()) { deleteStatus(status, parameters); } else { saveStatus(status, parameters); } mailStatusResult.incrementCurrentSize(); }  @Override void initialize(); @Override void onPrepareBegin(String batchId, Map<String, Object> parameters); @Override void onPrepareMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters); @Override void onPrepareMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters); @Override void onPrepareFatalError(Exception exception, Map<String, Object> parameters); @Override void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters); @Override void onSendMessageFatalError(String uniqueMessageId, Exception exception, Map<String, Object> parameters); @Override void onSendMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters); @Override MailStatusResult getMailStatusResult(); }
DatabaseMailListener extends AbstractMailListener implements Initializable { @Override public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) { super.onSendMessageSuccess(message, parameters); String uniqueMessageId = message.getUniqueMessageId(); MailStatus status = retrieveExistingMailStatus(uniqueMessageId, MailState.SEND_SUCCESS); if (status != null) { status.setState(MailState.SEND_SUCCESS); } else { this.logger.warn("Forcing a new mail status for message [{}] of batch [{}] to send_success state.", uniqueMessageId, getBatchId()); status = new MailStatus(getBatchId(), message, MailState.SEND_SUCCESS); } deleteMailContent(status); if (configuration.discardSuccessStatuses()) { deleteStatus(status, parameters); } else { saveStatus(status, parameters); } mailStatusResult.incrementCurrentSize(); }  @Override void initialize(); @Override void onPrepareBegin(String batchId, Map<String, Object> parameters); @Override void onPrepareMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters); @Override void onPrepareMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters); @Override void onPrepareFatalError(Exception exception, Map<String, Object> parameters); @Override void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters); @Override void onSendMessageFatalError(String uniqueMessageId, Exception exception, Map<String, Object> parameters); @Override void onSendMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters); @Override MailStatusResult getMailStatusResult();  }