@Test public void processShouldThrowWhenJmapRequestTypeMismatch() { MailboxSession session = mock(MailboxSession.class); JmapRequest getMailboxesRequest = GetMailboxesRequest.builder().build(); assertThatThrownBy(() -> new SetMailboxesMethod(NO_PROCESSOR, TIME_METRIC_FACTORY).processToStream(getMailboxesRequest, MethodCallId.of("methodCallId"), session)) .isInstanceOf(IllegalArgumentException.class); }
@Override public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) { Preconditions.checkNotNull(request); Preconditions.checkNotNull(methodCallId); Preconditions.checkNotNull(mailboxSession); Preconditions.checkArgument(request instanceof SetMailboxesRequest); SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request; return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "SET_MAILBOXES") .addContext("create", setMailboxesRequest.getCreate()) .addContext("update", setMailboxesRequest.getUpdate()) .addContext("destroy", setMailboxesRequest.getDestroy()) .wrapArround( () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), () -> Stream.of( JmapResponse.builder().methodCallId(methodCallId) .response(setMailboxesResponse(setMailboxesRequest, mailboxSession)) .responseName(RESPONSE_NAME) .build()))) .get(); }
SetMailboxesMethod implements Method { @Override public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) { Preconditions.checkNotNull(request); Preconditions.checkNotNull(methodCallId); Preconditions.checkNotNull(mailboxSession); Preconditions.checkArgument(request instanceof SetMailboxesRequest); SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request; return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "SET_MAILBOXES") .addContext("create", setMailboxesRequest.getCreate()) .addContext("update", setMailboxesRequest.getUpdate()) .addContext("destroy", setMailboxesRequest.getDestroy()) .wrapArround( () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), () -> Stream.of( JmapResponse.builder().methodCallId(methodCallId) .response(setMailboxesResponse(setMailboxesRequest, mailboxSession)) .responseName(RESPONSE_NAME) .build()))) .get(); } }
SetMailboxesMethod implements Method { @Override public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) { Preconditions.checkNotNull(request); Preconditions.checkNotNull(methodCallId); Preconditions.checkNotNull(mailboxSession); Preconditions.checkArgument(request instanceof SetMailboxesRequest); SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request; return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "SET_MAILBOXES") .addContext("create", setMailboxesRequest.getCreate()) .addContext("update", setMailboxesRequest.getUpdate()) .addContext("destroy", setMailboxesRequest.getDestroy()) .wrapArround( () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), () -> Stream.of( JmapResponse.builder().methodCallId(methodCallId) .response(setMailboxesResponse(setMailboxesRequest, mailboxSession)) .responseName(RESPONSE_NAME) .build()))) .get(); } @Inject  SetMailboxesMethod(Set<SetMailboxesProcessor> processors, MetricFactory metricFactory); }
SetMailboxesMethod implements Method { @Override public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) { Preconditions.checkNotNull(request); Preconditions.checkNotNull(methodCallId); Preconditions.checkNotNull(mailboxSession); Preconditions.checkArgument(request instanceof SetMailboxesRequest); SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request; return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "SET_MAILBOXES") .addContext("create", setMailboxesRequest.getCreate()) .addContext("update", setMailboxesRequest.getUpdate()) .addContext("destroy", setMailboxesRequest.getDestroy()) .wrapArround( () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), () -> Stream.of( JmapResponse.builder().methodCallId(methodCallId) .response(setMailboxesResponse(setMailboxesRequest, mailboxSession)) .responseName(RESPONSE_NAME) .build()))) .get(); } @Inject  SetMailboxesMethod(Set<SetMailboxesProcessor> processors, MetricFactory metricFactory); @Override Request.Name requestHandled(); @Override Class<? extends JmapRequest> requestType(); @Override Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession); }
SetMailboxesMethod implements Method { @Override public Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession) { Preconditions.checkNotNull(request); Preconditions.checkNotNull(methodCallId); Preconditions.checkNotNull(mailboxSession); Preconditions.checkArgument(request instanceof SetMailboxesRequest); SetMailboxesRequest setMailboxesRequest = (SetMailboxesRequest) request; return MDCBuilder.create() .addContext(MDCBuilder.ACTION, "SET_MAILBOXES") .addContext("create", setMailboxesRequest.getCreate()) .addContext("update", setMailboxesRequest.getUpdate()) .addContext("destroy", setMailboxesRequest.getDestroy()) .wrapArround( () -> metricFactory.decorateSupplierWithTimerMetricLogP99(JMAP_PREFIX + METHOD_NAME.getName(), () -> Stream.of( JmapResponse.builder().methodCallId(methodCallId) .response(setMailboxesResponse(setMailboxesRequest, mailboxSession)) .responseName(RESPONSE_NAME) .build()))) .get(); } @Inject  SetMailboxesMethod(Set<SetMailboxesProcessor> processors, MetricFactory metricFactory); @Override Request.Name requestHandled(); @Override Class<? extends JmapRequest> requestType(); @Override Stream<JmapResponse> processToStream(JmapRequest request, MethodCallId methodCallId, MailboxSession mailboxSession);  }