@Test void getAttachmentsShouldReturnEmptyByDefault() { AttachmentId attachmentId = AttachmentId.from("1"); AttachmentMetadata attachment = AttachmentMetadata.builder() .attachmentId(attachmentId) .size(11) .type("type") .build(); when(attachmentMapper.getAttachmentsAsMono(attachmentId)) .thenReturn(Mono.just(attachment)); Collection<MessageAttachmentMetadata> attachments = testee.getAttachments(ImmutableList.of()) .block(); assertThat(attachments).isEmpty(); }
@VisibleForTesting Mono<List<MessageAttachmentMetadata>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { return Flux.fromIterable(attachmentRepresentations) .flatMapSequential(attachmentRepresentation -> attachmentMapper.getAttachmentsAsMono(attachmentRepresentation.getAttachmentId()) .map(attachment -> constructMessageAttachment(attachment, attachmentRepresentation))) .collect(Guavate.toImmutableList()); }
AttachmentLoader { @VisibleForTesting Mono<List<MessageAttachmentMetadata>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { return Flux.fromIterable(attachmentRepresentations) .flatMapSequential(attachmentRepresentation -> attachmentMapper.getAttachmentsAsMono(attachmentRepresentation.getAttachmentId()) .map(attachment -> constructMessageAttachment(attachment, attachmentRepresentation))) .collect(Guavate.toImmutableList()); } }
AttachmentLoader { @VisibleForTesting Mono<List<MessageAttachmentMetadata>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { return Flux.fromIterable(attachmentRepresentations) .flatMapSequential(attachmentRepresentation -> attachmentMapper.getAttachmentsAsMono(attachmentRepresentation.getAttachmentId()) .map(attachment -> constructMessageAttachment(attachment, attachmentRepresentation))) .collect(Guavate.toImmutableList()); } AttachmentLoader(CassandraAttachmentMapper attachmentMapper); }
AttachmentLoader { @VisibleForTesting Mono<List<MessageAttachmentMetadata>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { return Flux.fromIterable(attachmentRepresentations) .flatMapSequential(attachmentRepresentation -> attachmentMapper.getAttachmentsAsMono(attachmentRepresentation.getAttachmentId()) .map(attachment -> constructMessageAttachment(attachment, attachmentRepresentation))) .collect(Guavate.toImmutableList()); } AttachmentLoader(CassandraAttachmentMapper attachmentMapper); Mono<MailboxMessage> addAttachmentToMessage(Pair<ComposedMessageIdWithMetaData, MessageRepresentation> messageRepresentation,
                                                       MessageMapper.FetchType fetchType); }
AttachmentLoader { @VisibleForTesting Mono<List<MessageAttachmentMetadata>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { return Flux.fromIterable(attachmentRepresentations) .flatMapSequential(attachmentRepresentation -> attachmentMapper.getAttachmentsAsMono(attachmentRepresentation.getAttachmentId()) .map(attachment -> constructMessageAttachment(attachment, attachmentRepresentation))) .collect(Guavate.toImmutableList()); } AttachmentLoader(CassandraAttachmentMapper attachmentMapper); Mono<MailboxMessage> addAttachmentToMessage(Pair<ComposedMessageIdWithMetaData, MessageRepresentation> messageRepresentation,
                                                       MessageMapper.FetchType fetchType);  }