JAMES-2082 Extract MessageAttachmentRep and MessageWithoutAttachment to separated model
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/9c7968bd Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/9c7968bd Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/9c7968bd Branch: refs/heads/master Commit: 9c7968bd181fd500983876f9ca251e3fd81e7d71 Parents: ee45bd4 Author: quynhn <qngu...@linagora.com> Authored: Tue Jul 4 18:00:02 2017 +0700 Committer: Antoine Duprat <adup...@linagora.com> Committed: Mon Jul 10 14:23:55 2017 +0200 ---------------------------------------------------------------------- .../cassandra/mail/AttachmentLoader.java | 6 +- .../cassandra/mail/CassandraMessageDAO.java | 168 +------------------ .../mail/CassandraMessageIdMapper.java | 8 +- .../mail/MessageAttachmentRepresentation.java | 142 ++++++++++++++++ .../mail/MessageWithoutAttachment.java | 79 +++++++++ .../cassandra/mail/AttachmentLoaderTest.java | 11 +- .../cassandra/mail/CassandraMessageDAOTest.java | 4 +- ...MessageAttachmentRepresentationByIdTest.java | 15 +- 8 files changed, 245 insertions(+), 188 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoader.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoader.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoader.java index f14982a..cd70e55 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoader.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoader.java @@ -42,10 +42,10 @@ public class AttachmentLoader { this.attachmentMapper = attachmentMapper; } - public CompletableFuture<Collection<MessageAttachment>> getAttachments(List<CassandraMessageDAO.MessageAttachmentRepresentation> attachmentRepresentations) { + public CompletableFuture<Collection<MessageAttachment>> getAttachments(List<MessageAttachmentRepresentation> attachmentRepresentations) { CompletableFuture<Map<AttachmentId, Attachment>> attachmentsByIdFuture = attachmentsById(attachmentRepresentations.stream() - .map(CassandraMessageDAO.MessageAttachmentRepresentation::getAttachmentId) + .map(MessageAttachmentRepresentation::getAttachmentId) .collect(Guavate.toImmutableSet())); return attachmentsByIdFuture.thenApply(attachmentsById -> @@ -54,7 +54,7 @@ public class AttachmentLoader { .collect(Guavate.toImmutableList())); } - private MessageAttachment constructMessageAttachment(Attachment attachment, CassandraMessageDAO.MessageAttachmentRepresentation messageAttachmentRepresentation) { + private MessageAttachment constructMessageAttachment(Attachment attachment, MessageAttachmentRepresentation messageAttachmentRepresentation) { return MessageAttachment.builder() .attachment(attachment) .name(messageAttachmentRepresentation.getName().orElse(null)) http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java index 9c69158..d9d6eaf 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java @@ -42,7 +42,6 @@ import static org.apache.james.mailbox.cassandra.table.CassandraMessageV1Table.T import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; -import java.util.Date; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -51,14 +50,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; -import javax.mail.Flags; import javax.mail.util.SharedByteArrayInputStream; import org.apache.commons.lang3.tuple.Pair; import org.apache.james.backends.cassandra.CassandraConfiguration; import org.apache.james.backends.cassandra.init.CassandraTypesProvider; import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor; -import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.cassandra.CassandraMessageId; import org.apache.james.mailbox.cassandra.table.CassandraMessageV1Table.Attachments; import org.apache.james.mailbox.cassandra.table.CassandraMessageV1Table.Properties; @@ -67,13 +64,9 @@ import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.model.Cid; import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData; -import org.apache.james.mailbox.model.MailboxId; -import org.apache.james.mailbox.model.MessageAttachment; -import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.store.mail.MessageMapper.FetchType; import org.apache.james.mailbox.store.mail.model.MailboxMessage; import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder; -import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage; import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty; import org.apache.james.util.CompletableFutureUtil; import org.apache.james.util.FluentFutureStream; @@ -87,9 +80,6 @@ import com.datastax.driver.core.Session; import com.datastax.driver.core.UDTValue; import com.datastax.driver.core.querybuilder.QueryBuilder; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.Preconditions; import com.google.common.io.ByteStreams; import com.google.common.primitives.Bytes; @@ -224,7 +214,7 @@ public class CassandraMessageDAO { .setUUID(MESSAGE_ID, cassandraMessageId.get())); } - private Pair<MessageWithoutAttachment, Stream<MessageAttachmentRepresentation>> message(Row row,ComposedMessageIdWithMetaData messageIdWithMetaData, FetchType fetchType) { + private Pair<MessageWithoutAttachment, Stream<MessageAttachmentRepresentation>> message(Row row, ComposedMessageIdWithMetaData messageIdWithMetaData, FetchType fetchType) { ComposedMessageId messageId = messageIdWithMetaData.getComposedMessageId(); MessageWithoutAttachment messageWithoutAttachment = @@ -325,160 +315,4 @@ public class CassandraMessageDAO { row.getBytes(field).get(headerContent); return headerContent; } - - public static class MessageAttachmentRepresentation { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private AttachmentId attachmentId; - private Optional<String> name; - private Optional<Cid> cid; - private Optional<Boolean> isInline; - - private Builder() { - name = Optional.empty(); - cid = Optional.empty(); - isInline = Optional.empty(); - } - - public Builder attachmentId(AttachmentId attachmentId) { - Preconditions.checkArgument(attachmentId != null); - this.attachmentId = attachmentId; - return this; - } - - public Builder name(String name) { - this.name = Optional.ofNullable(name); - return this; - } - - public Builder cid(Optional<Cid> cid) { - Preconditions.checkNotNull(cid); - this.cid = cid; - return this; - } - - - public Builder cid(Cid cid) { - this.cid = Optional.ofNullable(cid); - return this; - } - - public Builder isInline(boolean isInline) { - this.isInline = Optional.of(isInline); - return this; - } - - public MessageAttachmentRepresentation build() { - Preconditions.checkState(attachmentId != null, "'attachmentId' is mandatory"); - boolean builtIsInLine = isInline.orElse(false); - return new MessageAttachmentRepresentation(attachmentId, name, cid, builtIsInLine); - } - } - - private final AttachmentId attachmentId; - private final Optional<String> name; - private final Optional<Cid> cid; - private final boolean isInline; - - @VisibleForTesting - MessageAttachmentRepresentation(AttachmentId attachmentId, Optional<String> name, Optional<Cid> cid, boolean isInline) { - this.attachmentId = attachmentId; - this.name = name; - this.cid = cid; - this.isInline = isInline; - } - - public AttachmentId getAttachmentId() { - return attachmentId; - } - - public Optional<String> getName() { - return name; - } - - public Optional<Cid> getCid() { - return cid; - } - - public boolean isInline() { - return isInline; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof MessageAttachmentRepresentation) { - MessageAttachmentRepresentation other = (MessageAttachmentRepresentation) obj; - return Objects.equal(attachmentId, other.attachmentId) - && Objects.equal(name, other.name) - && Objects.equal(cid, other.cid) - && Objects.equal(isInline, other.isInline); - } - return false; - } - - @Override - public int hashCode() { - return Objects.hashCode(attachmentId, name, cid, isInline); - } - - @Override - public String toString() { - return MoreObjects - .toStringHelper(this) - .add("attachmentId", attachmentId) - .add("name", name) - .add("cid", cid) - .add("isInline", isInline) - .toString(); - } - } - - static class MessageWithoutAttachment { - - private final MessageId messageId; - private final Date internalDate; - private final Long size; - private final Integer boduSize; - private final SharedByteArrayInputStream content; - private final Flags flags; - private final PropertyBuilder propertyBuilder; - private final MailboxId mailboxId; - private final MessageUid messageUid; - private final long modSeq; - - public MessageWithoutAttachment(MessageId messageId, Date internalDate, Long size, Integer boduSize, SharedByteArrayInputStream content, - Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId, MessageUid messageUid, long modSeq) { - this.messageId = messageId; - this.internalDate = internalDate; - this.size = size; - this.boduSize = boduSize; - this.content = content; - this.flags = flags; - this.propertyBuilder = propertyBuilder; - this.mailboxId = mailboxId; - this.messageUid = messageUid; - this.modSeq = modSeq; - } - - public SimpleMailboxMessage toMailboxMessage(List<MessageAttachment> attachments) { - SimpleMailboxMessage simpleMailboxMessage = new SimpleMailboxMessage(messageId, internalDate, size, boduSize, - content, flags, propertyBuilder, mailboxId, attachments); - simpleMailboxMessage.setUid(messageUid); - simpleMailboxMessage.setModSeq(modSeq); - return simpleMailboxMessage; - } - - public MailboxId getMailboxId() { - return mailboxId; - } - - public MessageId getMessageId() { - return messageId; - } - } } http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java index 91e7b3a..81d2cf1 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java @@ -113,7 +113,7 @@ public class CassandraMessageIdMapper implements MessageIdMapper { .sorted(Comparator.comparing(MailboxMessage::getUid)); } - private CompletableFuture<Boolean> mailboxExists(CassandraMessageDAO.MessageWithoutAttachment messageWithoutAttachment) { + private CompletableFuture<Boolean> mailboxExists(MessageWithoutAttachment messageWithoutAttachment) { CassandraId cassandraId = (CassandraId) messageWithoutAttachment.getMailboxId(); return mailboxDAO.retrieveMailbox(cassandraId) .thenApply(optional -> { @@ -127,8 +127,8 @@ public class CassandraMessageIdMapper implements MessageIdMapper { }); } - private Function<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>, - CompletableFuture<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<MessageAttachment>>>> + private Function<Pair<MessageWithoutAttachment, Stream<MessageAttachmentRepresentation>>, + CompletableFuture<Pair<MessageWithoutAttachment, Stream<MessageAttachment>>>> loadAttachments(FetchType fetchType) { if (fetchType == FetchType.Full || fetchType == FetchType.Body) { return pair -> attachmentLoader @@ -139,7 +139,7 @@ public class CassandraMessageIdMapper implements MessageIdMapper { } } - private FunctionChainer<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<MessageAttachment>>, SimpleMailboxMessage> toMailboxMessages() { + private FunctionChainer<Pair<MessageWithoutAttachment, Stream<MessageAttachment>>, SimpleMailboxMessage> toMailboxMessages() { return Throwing.function(pair -> pair.getLeft() .toMailboxMessage(pair.getRight() .collect(Guavate.toImmutableList()))); http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentation.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentation.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentation.java new file mode 100644 index 0000000..838ac56 --- /dev/null +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentation.java @@ -0,0 +1,142 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.cassandra.mail; + +import java.util.Optional; + +import org.apache.james.mailbox.model.AttachmentId; +import org.apache.james.mailbox.model.Cid; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.base.Preconditions; + +public class MessageAttachmentRepresentation { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private AttachmentId attachmentId; + private Optional<String> name; + private Optional<Cid> cid; + private Optional<Boolean> isInline; + + private Builder() { + name = Optional.empty(); + cid = Optional.empty(); + isInline = Optional.empty(); + } + + public Builder attachmentId(AttachmentId attachmentId) { + Preconditions.checkArgument(attachmentId != null); + this.attachmentId = attachmentId; + return this; + } + + public Builder name(String name) { + this.name = Optional.ofNullable(name); + return this; + } + + public Builder cid(Optional<Cid> cid) { + Preconditions.checkNotNull(cid); + this.cid = cid; + return this; + } + + + public Builder cid(Cid cid) { + this.cid = Optional.ofNullable(cid); + return this; + } + + public Builder isInline(boolean isInline) { + this.isInline = Optional.of(isInline); + return this; + } + + public MessageAttachmentRepresentation build() { + Preconditions.checkState(attachmentId != null, "'attachmentId' is mandatory"); + boolean builtIsInLine = isInline.orElse(false); + return new MessageAttachmentRepresentation(attachmentId, name, cid, builtIsInLine); + } + } + + private final AttachmentId attachmentId; + private final Optional<String> name; + private final Optional<Cid> cid; + private final boolean isInline; + + @VisibleForTesting + MessageAttachmentRepresentation(AttachmentId attachmentId, Optional<String> name, Optional<Cid> cid, boolean isInline) { + this.attachmentId = attachmentId; + this.name = name; + this.cid = cid; + this.isInline = isInline; + } + + public AttachmentId getAttachmentId() { + return attachmentId; + } + + public Optional<String> getName() { + return name; + } + + public Optional<Cid> getCid() { + return cid; + } + + public boolean isInline() { + return isInline; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof MessageAttachmentRepresentation) { + MessageAttachmentRepresentation other = (MessageAttachmentRepresentation) obj; + return Objects.equal(attachmentId, other.attachmentId) + && Objects.equal(name, other.name) + && Objects.equal(cid, other.cid) + && Objects.equal(isInline, other.isInline); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hashCode(attachmentId, name, cid, isInline); + } + + @Override + public String toString() { + return MoreObjects + .toStringHelper(this) + .add("attachmentId", attachmentId) + .add("name", name) + .add("cid", cid) + .add("isInline", isInline) + .toString(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageWithoutAttachment.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageWithoutAttachment.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageWithoutAttachment.java new file mode 100644 index 0000000..e5bca7b --- /dev/null +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageWithoutAttachment.java @@ -0,0 +1,79 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.mailbox.cassandra.mail; + +import java.util.Date; +import java.util.List; +import javax.mail.Flags; +import javax.mail.util.SharedByteArrayInputStream; + +import org.apache.james.mailbox.MessageUid; +import org.apache.james.mailbox.model.MailboxId; +import org.apache.james.mailbox.model.MessageAttachment; +import org.apache.james.mailbox.model.MessageId; +import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder; +import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage; + +public class MessageWithoutAttachment { + private final MessageId messageId; + private final Date internalDate; + private final Long size; + private final Integer boduSize; + private final SharedByteArrayInputStream content; + private final Flags flags; + private final PropertyBuilder propertyBuilder; + private final MailboxId mailboxId; + private final MessageUid messageUid; + private final long modSeq; + + public MessageWithoutAttachment(MessageId messageId, Date internalDate, Long size, Integer boduSize, SharedByteArrayInputStream content, + Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId, MessageUid messageUid, long modSeq) { + this.messageId = messageId; + this.internalDate = internalDate; + this.size = size; + this.boduSize = boduSize; + this.content = content; + this.flags = flags; + this.propertyBuilder = propertyBuilder; + this.mailboxId = mailboxId; + this.messageUid = messageUid; + this.modSeq = modSeq; + } + + public SimpleMailboxMessage toMailboxMessage(List<MessageAttachment> attachments) { + SimpleMailboxMessage simpleMailboxMessage = new SimpleMailboxMessage(messageId, internalDate, size, boduSize, + content, flags, propertyBuilder, mailboxId, attachments); + simpleMailboxMessage.setUid(messageUid); + simpleMailboxMessage.setModSeq(modSeq); + return simpleMailboxMessage; + } + + public MailboxId getMailboxId() { + return mailboxId; + } + + public MessageId getMessageId() { + return messageId; + } + + public SharedByteArrayInputStream getContent() { + return content; + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoaderTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoaderTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoaderTest.java index a5bb631..048ef7b 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoaderTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/AttachmentLoaderTest.java @@ -33,6 +33,7 @@ import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.model.Cid; import org.apache.james.mailbox.model.MessageAttachment; import org.apache.james.util.OptionalConverter; + import org.assertj.core.data.MapEntry; import org.junit.Before; import org.junit.Test; @@ -67,7 +68,7 @@ public class AttachmentLoaderTest { Optional<String> name = Optional.of("name1"); Optional<Cid> cid = Optional.empty(); boolean isInlined = false; - CassandraMessageDAO.MessageAttachmentRepresentation attachmentRepresentation = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, name, cid, isInlined); + MessageAttachmentRepresentation attachmentRepresentation = new MessageAttachmentRepresentation(attachmentId, name, cid, isInlined); Collection<MessageAttachment> attachments = testee.getAttachments(ImmutableList.of(attachmentRepresentation, attachmentRepresentation)) .join(); @@ -94,8 +95,8 @@ public class AttachmentLoaderTest { Optional<String> name2 = Optional.of("name2"); Optional<Cid> cid = Optional.empty(); boolean isInlined = false; - CassandraMessageDAO.MessageAttachmentRepresentation attachmentRepresentation1 = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, name1, cid, isInlined); - CassandraMessageDAO.MessageAttachmentRepresentation attachmentRepresentation2 = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, name2, cid, isInlined); + MessageAttachmentRepresentation attachmentRepresentation1 = new MessageAttachmentRepresentation(attachmentId, name1, cid, isInlined); + MessageAttachmentRepresentation attachmentRepresentation2 = new MessageAttachmentRepresentation(attachmentId, name2, cid, isInlined); Collection<MessageAttachment> attachments = testee.getAttachments(ImmutableList.of(attachmentRepresentation1, attachmentRepresentation2)) .join(); @@ -128,8 +129,8 @@ public class AttachmentLoaderTest { Optional<String> name2 = Optional.of("name2"); Optional<Cid> cid = Optional.empty(); boolean isInlined = false; - CassandraMessageDAO.MessageAttachmentRepresentation attachmentRepresentation1 = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId1, name1, cid, isInlined); - CassandraMessageDAO.MessageAttachmentRepresentation attachmentRepresentation2 = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId2, name2, cid, isInlined); + MessageAttachmentRepresentation attachmentRepresentation1 = new MessageAttachmentRepresentation(attachmentId1, name1, cid, isInlined); + MessageAttachmentRepresentation attachmentRepresentation2 = new MessageAttachmentRepresentation(attachmentId2, name2, cid, isInlined); Collection<MessageAttachment> attachments = testee.getAttachments(ImmutableList.of(attachmentRepresentation1, attachmentRepresentation2)) .join(); http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java index 2d10872..3f69d26 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOTest.java @@ -106,7 +106,7 @@ public class CassandraMessageDAOTest { testee.save(messageWith1Attachment).join(); - List<Optional<CassandraMessageDAO.MessageAttachmentRepresentation>> attachmentRepresentation = testee.retrieveMessages(messageIds, MessageMapper.FetchType.Body, Optional.empty()) + List<Optional<MessageAttachmentRepresentation>> attachmentRepresentation = testee.retrieveMessages(messageIds, MessageMapper.FetchType.Body, Optional.empty()) .get() .map(pair -> pair.getRight()) .map(streamAttachemnt -> streamAttachemnt.findFirst()) @@ -128,7 +128,7 @@ public class CassandraMessageDAOTest { testee.save(messageWith1Attachment).join(); - List<Optional<CassandraMessageDAO.MessageAttachmentRepresentation>> attachmentRepresentation = testee.retrieveMessages(messageIds, MessageMapper.FetchType.Body, Optional.empty()) + List<Optional<MessageAttachmentRepresentation>> attachmentRepresentation = testee.retrieveMessages(messageIds, MessageMapper.FetchType.Body, Optional.empty()) .get() .map(pair -> pair.getRight()) .map(streamAttachemnt -> streamAttachemnt.findFirst()) http://git-wip-us.apache.org/repos/asf/james-project/blob/9c7968bd/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentationByIdTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentationByIdTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentationByIdTest.java index 1ae585a..5a292ec 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentationByIdTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/MessageAttachmentRepresentationByIdTest.java @@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Optional; +import org.apache.james.mailbox.cassandra.mail.MessageAttachmentRepresentation; import org.apache.james.mailbox.model.AttachmentId; import org.apache.james.mailbox.model.Cid; import org.junit.Test; @@ -45,9 +46,9 @@ public class MessageAttachmentRepresentationByIdTest { @Test public void buildShouldWorkWhenMandatoryAttributesAreGiven() { AttachmentId attachmentId = AttachmentId.from("1"); - CassandraMessageDAO.MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, Optional.empty(), Optional.empty(), false); + MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new MessageAttachmentRepresentation(attachmentId, Optional.empty(), Optional.empty(), false); - CassandraMessageDAO.MessageAttachmentRepresentation messageAttachmentRepresentation = CassandraMessageDAO.MessageAttachmentRepresentation.builder() + MessageAttachmentRepresentation messageAttachmentRepresentation = MessageAttachmentRepresentation.builder() .attachmentId(attachmentId) .build(); @@ -58,7 +59,7 @@ public class MessageAttachmentRepresentationByIdTest { public void buildShouldSetIsInlineDefaultValueWhenNotGiven() { AttachmentId attachmentId = AttachmentId.from("1"); - CassandraMessageDAO.MessageAttachmentRepresentation messageAttachmentRepresentation = CassandraMessageDAO.MessageAttachmentRepresentation.builder() + MessageAttachmentRepresentation messageAttachmentRepresentation = MessageAttachmentRepresentation.builder() .attachmentId(attachmentId) .build(); @@ -68,9 +69,9 @@ public class MessageAttachmentRepresentationByIdTest { @Test public void buildShouldAcceptInlineAndWithoutCid() { AttachmentId attachmentId = AttachmentId.from("1"); - CassandraMessageDAO.MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, Optional.empty(), Optional.empty(), true); + MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new MessageAttachmentRepresentation(attachmentId, Optional.empty(), Optional.empty(), true); - CassandraMessageDAO.MessageAttachmentRepresentation messageAttachmentRepresentation = CassandraMessageDAO.MessageAttachmentRepresentation.builder() + MessageAttachmentRepresentation messageAttachmentRepresentation = MessageAttachmentRepresentation.builder() .attachmentId(attachmentId) .isInline(true) .build(); @@ -81,9 +82,9 @@ public class MessageAttachmentRepresentationByIdTest { @Test public void buildShouldSetAttributesWhenAllAreGiven() { AttachmentId attachmentId = AttachmentId.from("1"); - CassandraMessageDAO.MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new CassandraMessageDAO.MessageAttachmentRepresentation(attachmentId, Optional.of("name"), Optional.of(Cid.from("cid")), true); + MessageAttachmentRepresentation expectedMessageAttachmentRepresentation = new MessageAttachmentRepresentation(attachmentId, Optional.of("name"), Optional.of(Cid.from("cid")), true); - CassandraMessageDAO.MessageAttachmentRepresentation messageAttachmentRepresentation = CassandraMessageDAO.MessageAttachmentRepresentation.builder() + MessageAttachmentRepresentation messageAttachmentRepresentation = MessageAttachmentRepresentation.builder() .attachmentId(attachmentId) .name("name") .cid(Cid.from("cid")) --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org