@Test void deliveryTemporaryFailureShouldRetryDelivery() throws Exception { FakeMail fakeMail = FakeMail.builder().name("name").state(Mail.DEFAULT).build(); Exception exception = new Exception(); when(mailDelivrer.deliver(fakeMail)).thenReturn(ExecutionResult.temporaryFailure(exception)); testee.attemptDelivery(fakeMail); verify(mailQueue).enQueue(FakeMail.builder() .name("name") .attribute(DeliveryRetriesHelper.makeAttribute(1)) .attribute(new Attribute(IS_DELIVERY_PERMANENT_ERROR, AttributeValue.of(false))) .state(Mail.ERROR) .lastUpdated(FIXED_DATE) .build(), Duration.ofSeconds(1)); verifyNoMoreInteractions(mailQueue); }
@VisibleForTesting void attemptDelivery(Mail mail) throws MailQueue.MailQueueException { ExecutionResult executionResult = mailDelivrer.deliver(mail); switch (executionResult.getExecutionState()) { case SUCCESS: outgoingMailsMetric.increment(); break; case TEMPORARY_FAILURE: handleTemporaryFailure(mail, executionResult); break; case PERMANENT_FAILURE: handlePermanentFailure(mail, executionResult); break; } }
DeliveryRunnable implements Disposable { @VisibleForTesting void attemptDelivery(Mail mail) throws MailQueue.MailQueueException { ExecutionResult executionResult = mailDelivrer.deliver(mail); switch (executionResult.getExecutionState()) { case SUCCESS: outgoingMailsMetric.increment(); break; case TEMPORARY_FAILURE: handleTemporaryFailure(mail, executionResult); break; case PERMANENT_FAILURE: handlePermanentFailure(mail, executionResult); break; } } }
DeliveryRunnable implements Disposable { @VisibleForTesting void attemptDelivery(Mail mail) throws MailQueue.MailQueueException { ExecutionResult executionResult = mailDelivrer.deliver(mail); switch (executionResult.getExecutionState()) { case SUCCESS: outgoingMailsMetric.increment(); break; case TEMPORARY_FAILURE: handleTemporaryFailure(mail, executionResult); break; case PERMANENT_FAILURE: handlePermanentFailure(mail, executionResult); break; } } DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, DNSService dnsServer, MetricFactory metricFactory,
                            MailetContext mailetContext, Bouncer bouncer); @VisibleForTesting  DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, MetricFactory metricFactory, Bouncer bouncer,
                     MailDelivrer mailDelivrer, Supplier<Date> dateSupplier); }
DeliveryRunnable implements Disposable { @VisibleForTesting void attemptDelivery(Mail mail) throws MailQueue.MailQueueException { ExecutionResult executionResult = mailDelivrer.deliver(mail); switch (executionResult.getExecutionState()) { case SUCCESS: outgoingMailsMetric.increment(); break; case TEMPORARY_FAILURE: handleTemporaryFailure(mail, executionResult); break; case PERMANENT_FAILURE: handlePermanentFailure(mail, executionResult); break; } } DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, DNSService dnsServer, MetricFactory metricFactory,
                            MailetContext mailetContext, Bouncer bouncer); @VisibleForTesting  DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, MetricFactory metricFactory, Bouncer bouncer,
                     MailDelivrer mailDelivrer, Supplier<Date> dateSupplier); void start(); @Override void dispose(); }
DeliveryRunnable implements Disposable { @VisibleForTesting void attemptDelivery(Mail mail) throws MailQueue.MailQueueException { ExecutionResult executionResult = mailDelivrer.deliver(mail); switch (executionResult.getExecutionState()) { case SUCCESS: outgoingMailsMetric.increment(); break; case TEMPORARY_FAILURE: handleTemporaryFailure(mail, executionResult); break; case PERMANENT_FAILURE: handlePermanentFailure(mail, executionResult); break; } } DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, DNSService dnsServer, MetricFactory metricFactory,
                            MailetContext mailetContext, Bouncer bouncer); @VisibleForTesting  DeliveryRunnable(MailQueue queue, RemoteDeliveryConfiguration configuration, MetricFactory metricFactory, Bouncer bouncer,
                     MailDelivrer mailDelivrer, Supplier<Date> dateSupplier); void start(); @Override void dispose(); static final Supplier<Date> CURRENT_DATE_SUPPLIER; static final String OUTGOING_MAILS; static final String REMOTE_DELIVERY_TRIAL; }