@Test public void processShouldReturnEmptyUpdatedWhenRequestHasEmptyUpdate() { SetMessagesRequest requestWithEmptyUpdate = SetMessagesRequest.builder().build(); SetMessagesResponse result = sut.process(requestWithEmptyUpdate, null); assertThat(result.getUpdated()).isEmpty(); assertThat(result.getNotUpdated()).isEmpty(); }
@Override public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) { TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor"); SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder(); Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX)) .map(outboxes -> { prepareResponse(request, mailboxSession, responseBuilder, outboxes); return null; }) .onFailure(e -> request.buildUpdatePatches(updatePatchConverter) .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch))); timeMetric.stopAndPublish(); return responseBuilder.build(); }
SetMessagesUpdateProcessor implements SetMessagesProcessor { @Override public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) { TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor"); SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder(); Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX)) .map(outboxes -> { prepareResponse(request, mailboxSession, responseBuilder, outboxes); return null; }) .onFailure(e -> request.buildUpdatePatches(updatePatchConverter) .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch))); timeMetric.stopAndPublish(); return responseBuilder.build(); } }
SetMessagesUpdateProcessor implements SetMessagesProcessor { @Override public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) { TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor"); SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder(); Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX)) .map(outboxes -> { prepareResponse(request, mailboxSession, responseBuilder, outboxes); return null; }) .onFailure(e -> request.buildUpdatePatches(updatePatchConverter) .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch))); timeMetric.stopAndPublish(); return responseBuilder.build(); } @Inject @VisibleForTesting  SetMessagesUpdateProcessor(
            UpdateMessagePatchConverter updatePatchConverter,
            MessageIdManager messageIdManager,
            SystemMailboxesProvider systemMailboxesProvider,
            Factory mailboxIdFactory,
            MessageSender messageSender,
            MetricFactory metricFactory,
            ReferenceUpdater referenceUpdater,
            CanSendFrom canSendFrom); }
SetMessagesUpdateProcessor implements SetMessagesProcessor { @Override public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) { TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor"); SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder(); Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX)) .map(outboxes -> { prepareResponse(request, mailboxSession, responseBuilder, outboxes); return null; }) .onFailure(e -> request.buildUpdatePatches(updatePatchConverter) .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch))); timeMetric.stopAndPublish(); return responseBuilder.build(); } @Inject @VisibleForTesting  SetMessagesUpdateProcessor(
            UpdateMessagePatchConverter updatePatchConverter,
            MessageIdManager messageIdManager,
            SystemMailboxesProvider systemMailboxesProvider,
            Factory mailboxIdFactory,
            MessageSender messageSender,
            MetricFactory metricFactory,
            ReferenceUpdater referenceUpdater,
            CanSendFrom canSendFrom); @Override SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession); }
SetMessagesUpdateProcessor implements SetMessagesProcessor { @Override public SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession) { TimeMetric timeMetric = metricFactory.timer(JMAP_PREFIX + "SetMessagesUpdateProcessor"); SetMessagesResponse.Builder responseBuilder = SetMessagesResponse.builder(); Try.ofCallable(() -> listMailboxIdsForRole(mailboxSession, Role.OUTBOX)) .map(outboxes -> { prepareResponse(request, mailboxSession, responseBuilder, outboxes); return null; }) .onFailure(e -> request.buildUpdatePatches(updatePatchConverter) .forEach((id, patch) -> prepareResponseIfCantReadOutboxes(responseBuilder, e, id, patch))); timeMetric.stopAndPublish(); return responseBuilder.build(); } @Inject @VisibleForTesting  SetMessagesUpdateProcessor(
            UpdateMessagePatchConverter updatePatchConverter,
            MessageIdManager messageIdManager,
            SystemMailboxesProvider systemMailboxesProvider,
            Factory mailboxIdFactory,
            MessageSender messageSender,
            MetricFactory metricFactory,
            ReferenceUpdater referenceUpdater,
            CanSendFrom canSendFrom); @Override SetMessagesResponse process(SetMessagesRequest request, MailboxSession mailboxSession);  }