james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [03/14] james-project git commit: JAMES-2540 rename MailDTO to MailReferenceDTO
Date Mon, 17 Sep 2018 06:33:13 GMT
JAMES-2540 rename MailDTO to MailReferenceDTO


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/47eb3bfb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/47eb3bfb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/47eb3bfb

Branch: refs/heads/master
Commit: 47eb3bfb3838067f2aed5748b617bbb08e16fea6
Parents: 60fcc28
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Tue Sep 11 16:08:53 2018 +0200
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Sep 14 11:05:43 2018 +0700

----------------------------------------------------------------------
 .../apache/james/queue/rabbitmq/Dequeuer.java   |   8 +-
 .../apache/james/queue/rabbitmq/Enqueuer.java   |   4 +-
 .../apache/james/queue/rabbitmq/MailDTO.java    | 248 -------------------
 .../james/queue/rabbitmq/MailReferenceDTO.java  | 248 +++++++++++++++++++
 .../james/queue/rabbitmq/MailDTOTest.java       |  12 +-
 5 files changed, 260 insertions(+), 260 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/47eb3bfb/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
index 4cc11b5..eeb2ef8 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Dequeuer.java
@@ -90,15 +90,15 @@ class Dequeuer {
 
     MailQueue.MailQueueItem deQueue() throws MailQueue.MailQueueException {
         GetResponse getResponse = pollChannel();
-        MailDTO mailDTO = toDTO(getResponse);
+        MailReferenceDTO mailDTO = toDTO(getResponse);
         Mail mail = toMail(mailDTO);
         dequeueMetric.increment();
         return new RabbitMQMailQueueItem(rabbitClient, getResponse.getEnvelope().getDeliveryTag(),
mail);
     }
 
-    private MailDTO toDTO(GetResponse getResponse) throws MailQueue.MailQueueException {
+    private MailReferenceDTO toDTO(GetResponse getResponse) throws MailQueue.MailQueueException
{
         try {
-            return objectMapper.readValue(getResponse.getBody(), MailDTO.class);
+            return objectMapper.readValue(getResponse.getBody(), MailReferenceDTO.class);
         } catch (IOException e) {
             throw new MailQueue.MailQueueException("Failed to parse DTO", e);
         }
@@ -119,7 +119,7 @@ class Dequeuer {
             .orElseThrow(NoMailYetException::new);
     }
 
-    private Mail toMail(MailDTO dto) throws MailQueue.MailQueueException {
+    private Mail toMail(MailReferenceDTO dto) throws MailQueue.MailQueueException {
         try {
             MimeMessage mimeMessage = mimeMessageStore.read(
                 MimeMessagePartsId.builder()

http://git-wip-us.apache.org/repos/asf/james-project/blob/47eb3bfb/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
index ba655f8..30ec819 100644
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/Enqueuer.java
@@ -54,7 +54,7 @@ class Enqueuer {
 
     void enQueue(Mail mail) throws MailQueue.MailQueueException {
         MimeMessagePartsId partsId = saveBlobs(mail).join();
-        MailDTO mailDTO = MailDTO.fromMail(mail, partsId);
+        MailReferenceDTO mailDTO = MailReferenceDTO.fromMail(mail, partsId);
         byte[] message = getMessageBytes(mailDTO);
         rabbitClient.publish(name, message);
 
@@ -69,7 +69,7 @@ class Enqueuer {
         }
     }
 
-    private byte[] getMessageBytes(MailDTO mailDTO) throws MailQueue.MailQueueException {
+    private byte[] getMessageBytes(MailReferenceDTO mailDTO) throws MailQueue.MailQueueException
{
         try {
             return objectMapper.writeValueAsBytes(mailDTO);
         } catch (JsonProcessingException e) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/47eb3bfb/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailDTO.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailDTO.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailDTO.java
deleted file mode 100644
index 628d76f..0000000
--- a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailDTO.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************
- * 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.queue.rabbitmq;
-
-import java.io.Serializable;
-import java.time.Instant;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.stream.Stream;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
-
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.james.blob.mail.MimeMessagePartsId;
-import org.apache.james.core.MailAddress;
-import org.apache.james.server.core.MailImpl;
-import org.apache.james.util.SerializationUtil;
-import org.apache.james.util.streams.Iterators;
-import org.apache.mailet.Mail;
-import org.apache.mailet.PerRecipientHeaders;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.github.fge.lambdas.Throwing;
-import com.github.steveash.guavate.Guavate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-class MailDTO {
-
-    static MailDTO fromMail(Mail mail, MimeMessagePartsId partsId) {
-        return new MailDTO(
-            Optional.ofNullable(mail.getRecipients()).map(Collection::stream)
-                .orElse(Stream.empty())
-                .map(MailAddress::asString)
-                .collect(Guavate.toImmutableList()),
-            mail.getName(),
-            Optional.ofNullable(mail.getSender()).map(MailAddress::asString),
-            mail.getState(),
-            mail.getErrorMessage(),
-            Optional.ofNullable(mail.getLastUpdated()).map(Date::toInstant),
-            serializedAttributes(mail),
-            mail.getRemoteAddr(),
-            mail.getRemoteHost(),
-            fromPerRecipientHeaders(mail.getPerRecipientSpecificHeaders()),
-            partsId.getHeaderBlobId().asString(),
-            partsId.getBodyBlobId().asString());
-    }
-
-    private static Map<String, HeadersDto> fromPerRecipientHeaders(PerRecipientHeaders
perRecipientHeaders) {
-        return perRecipientHeaders.getHeadersByRecipient()
-            .asMap()
-            .entrySet()
-            .stream()
-            .collect(ImmutableMap.toImmutableMap(
-                entry -> entry.getKey().asString(),
-                entry -> HeadersDto.from(entry.getValue())));
-    }
-
-    private static ImmutableMap<String, String> serializedAttributes(Mail mail) {
-        return Iterators.toStream(mail.getAttributeNames())
-            .collect(Guavate.toImmutableMap(
-                name -> name,
-                name -> SerializationUtil.serialize(mail.getAttribute(name))));
-    }
-
-    private final ImmutableList<String> recipients;
-    private final String name;
-    private final Optional<String> sender;
-    private final String state;
-    private final String errorMessage;
-    private final Optional<Instant> lastUpdated;
-    private final ImmutableMap<String, String> attributes;
-    private final String remoteAddr;
-    private final String remoteHost;
-    private final Map<String, HeadersDto> perRecipientHeaders;
-    private final String headerBlobId;
-    private final String bodyBlobId;
-
-    @JsonCreator
-    private MailDTO(@JsonProperty("recipients") ImmutableList<String> recipients,
-                    @JsonProperty("name") String name,
-                    @JsonProperty("sender") Optional<String> sender,
-                    @JsonProperty("state") String state,
-                    @JsonProperty("errorMessage") String errorMessage,
-                    @JsonProperty("lastUpdated") Optional<Instant> lastUpdated,
-                    @JsonProperty("attributes") ImmutableMap<String, String> attributes,
-                    @JsonProperty("remoteAddr") String remoteAddr,
-                    @JsonProperty("remoteHost") String remoteHost,
-                    @JsonProperty("perRecipientHeaders") Map<String, HeadersDto>  perRecipientHeaders,
-                    @JsonProperty("headerBlobId") String headerBlobId,
-                    @JsonProperty("bodyBlobId") String bodyBlobId) {
-        this.recipients = recipients;
-        this.name = name;
-        this.sender = sender;
-        this.state = state;
-        this.errorMessage = errorMessage;
-        this.lastUpdated = lastUpdated;
-        this.attributes = attributes;
-        this.remoteAddr = remoteAddr;
-        this.remoteHost = remoteHost;
-        this.perRecipientHeaders = perRecipientHeaders;
-        this.headerBlobId = headerBlobId;
-        this.bodyBlobId = bodyBlobId;
-    }
-
-    @JsonProperty("recipients")
-    Collection<String> getRecipients() {
-        return recipients;
-    }
-
-    @JsonProperty("name")
-    String getName() {
-        return name;
-    }
-
-    @JsonProperty("sender")
-    Optional<String> getSender() {
-        return sender;
-    }
-
-    @JsonProperty("state")
-    String getState() {
-        return state;
-    }
-
-    @JsonProperty("errorMessage")
-    String getErrorMessage() {
-        return errorMessage;
-    }
-
-    @JsonProperty("lastUpdated")
-    Optional<Instant> getLastUpdated() {
-        return lastUpdated;
-    }
-
-    @JsonProperty("attributes")
-    Map<String, String> getAttributes() {
-        return attributes;
-    }
-
-    @JsonProperty("remoteAddr")
-    String getRemoteAddr() {
-        return remoteAddr;
-    }
-
-    @JsonProperty("remoteHost")
-    String getRemoteHost() {
-        return remoteHost;
-    }
-
-    @JsonProperty("perRecipientHeaders")
-    Map<String, HeadersDto>  getPerRecipientHeaders() {
-        return perRecipientHeaders;
-    }
-
-    @JsonProperty("headerBlobId")
-    String getHeaderBlobId() {
-        return headerBlobId;
-    }
-
-    @JsonProperty("bodyBlobId")
-    String getBodyBlobId() {
-        return bodyBlobId;
-    }
-
-    MailImpl toMailWithMimeMessage(MimeMessage mimeMessage) throws MessagingException {
-        MailImpl mail = new MailImpl(name,
-            sender.map(MailAddress::getMailSender).orElse(null),
-            recipients.stream()
-                .map(Throwing.<String, MailAddress>function(MailAddress::new).sneakyThrow())
-                .collect(Guavate.toImmutableList()),
-            mimeMessage);
-
-        mail.setErrorMessage(errorMessage);
-        mail.setRemoteAddr(remoteAddr);
-        mail.setRemoteHost(remoteHost);
-        mail.setState(state);
-        lastUpdated
-            .map(Instant::toEpochMilli)
-            .map(Date::new)
-            .ifPresent(mail::setLastUpdated);
-
-        attributes
-            .forEach((name, value) -> mail.setAttribute(name, SerializationUtil.<Serializable>deserialize(value)));
-
-        mail.addAllSpecificHeaderForRecipient(retrievePerRecipientHeaders());
-
-        return mail;
-    }
-
-    private PerRecipientHeaders retrievePerRecipientHeaders() {
-        PerRecipientHeaders perRecipientHeaders = new PerRecipientHeaders();
-        this.perRecipientHeaders.entrySet()
-            .stream()
-            .flatMap(entry -> entry.getValue().toHeaders().stream()
-                .map(Throwing.function(header -> Pair.of(new MailAddress(entry.getKey()),
header))))
-            .forEach(pair -> perRecipientHeaders.addHeaderForRecipient(pair.getValue(),
pair.getKey()));
-        return perRecipientHeaders;
-    }
-
-    @Override
-    public final boolean equals(Object o) {
-        if (o instanceof MailDTO) {
-            MailDTO mailDTO = (MailDTO) o;
-
-            return Objects.equals(this.recipients, mailDTO.recipients)
-                && Objects.equals(this.name, mailDTO.name)
-                && Objects.equals(this.sender, mailDTO.sender)
-                && Objects.equals(this.state, mailDTO.state)
-                && Objects.equals(this.errorMessage, mailDTO.errorMessage)
-                && Objects.equals(this.lastUpdated, mailDTO.lastUpdated)
-                && Objects.equals(this.attributes, mailDTO.attributes)
-                && Objects.equals(this.remoteAddr, mailDTO.remoteAddr)
-                && Objects.equals(this.remoteHost, mailDTO.remoteHost)
-                && Objects.equals(this.perRecipientHeaders, mailDTO.perRecipientHeaders)
-                && Objects.equals(this.headerBlobId, mailDTO.headerBlobId)
-                && Objects.equals(this.bodyBlobId, mailDTO.bodyBlobId);
-        }
-        return false;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hash(recipients, name, sender, state, errorMessage, lastUpdated, attributes,
remoteAddr, remoteHost, perRecipientHeaders, headerBlobId, bodyBlobId);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/47eb3bfb/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailReferenceDTO.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailReferenceDTO.java
b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailReferenceDTO.java
new file mode 100644
index 0000000..1c25f09
--- /dev/null
+++ b/server/queue/queue-rabbitmq/src/main/java/org/apache/james/queue/rabbitmq/MailReferenceDTO.java
@@ -0,0 +1,248 @@
+/****************************************************************
+ * 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.queue.rabbitmq;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.james.blob.mail.MimeMessagePartsId;
+import org.apache.james.core.MailAddress;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.util.SerializationUtil;
+import org.apache.james.util.streams.Iterators;
+import org.apache.mailet.Mail;
+import org.apache.mailet.PerRecipientHeaders;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.github.fge.lambdas.Throwing;
+import com.github.steveash.guavate.Guavate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+class MailReferenceDTO {
+
+    static MailReferenceDTO fromMail(Mail mail, MimeMessagePartsId partsId) {
+        return new MailReferenceDTO(
+            Optional.ofNullable(mail.getRecipients()).map(Collection::stream)
+                .orElse(Stream.empty())
+                .map(MailAddress::asString)
+                .collect(Guavate.toImmutableList()),
+            mail.getName(),
+            Optional.ofNullable(mail.getSender()).map(MailAddress::asString),
+            mail.getState(),
+            mail.getErrorMessage(),
+            Optional.ofNullable(mail.getLastUpdated()).map(Date::toInstant),
+            serializedAttributes(mail),
+            mail.getRemoteAddr(),
+            mail.getRemoteHost(),
+            fromPerRecipientHeaders(mail.getPerRecipientSpecificHeaders()),
+            partsId.getHeaderBlobId().asString(),
+            partsId.getBodyBlobId().asString());
+    }
+
+    private static Map<String, HeadersDto> fromPerRecipientHeaders(PerRecipientHeaders
perRecipientHeaders) {
+        return perRecipientHeaders.getHeadersByRecipient()
+            .asMap()
+            .entrySet()
+            .stream()
+            .collect(ImmutableMap.toImmutableMap(
+                entry -> entry.getKey().asString(),
+                entry -> HeadersDto.from(entry.getValue())));
+    }
+
+    private static ImmutableMap<String, String> serializedAttributes(Mail mail) {
+        return Iterators.toStream(mail.getAttributeNames())
+            .collect(Guavate.toImmutableMap(
+                name -> name,
+                name -> SerializationUtil.serialize(mail.getAttribute(name))));
+    }
+
+    private final ImmutableList<String> recipients;
+    private final String name;
+    private final Optional<String> sender;
+    private final String state;
+    private final String errorMessage;
+    private final Optional<Instant> lastUpdated;
+    private final ImmutableMap<String, String> attributes;
+    private final String remoteAddr;
+    private final String remoteHost;
+    private final Map<String, HeadersDto> perRecipientHeaders;
+    private final String headerBlobId;
+    private final String bodyBlobId;
+
+    @JsonCreator
+    private MailReferenceDTO(@JsonProperty("recipients") ImmutableList<String> recipients,
+                             @JsonProperty("name") String name,
+                             @JsonProperty("sender") Optional<String> sender,
+                             @JsonProperty("state") String state,
+                             @JsonProperty("errorMessage") String errorMessage,
+                             @JsonProperty("lastUpdated") Optional<Instant> lastUpdated,
+                             @JsonProperty("attributes") ImmutableMap<String, String>
attributes,
+                             @JsonProperty("remoteAddr") String remoteAddr,
+                             @JsonProperty("remoteHost") String remoteHost,
+                             @JsonProperty("perRecipientHeaders") Map<String, HeadersDto>
 perRecipientHeaders,
+                             @JsonProperty("headerBlobId") String headerBlobId,
+                             @JsonProperty("bodyBlobId") String bodyBlobId) {
+        this.recipients = recipients;
+        this.name = name;
+        this.sender = sender;
+        this.state = state;
+        this.errorMessage = errorMessage;
+        this.lastUpdated = lastUpdated;
+        this.attributes = attributes;
+        this.remoteAddr = remoteAddr;
+        this.remoteHost = remoteHost;
+        this.perRecipientHeaders = perRecipientHeaders;
+        this.headerBlobId = headerBlobId;
+        this.bodyBlobId = bodyBlobId;
+    }
+
+    @JsonProperty("recipients")
+    Collection<String> getRecipients() {
+        return recipients;
+    }
+
+    @JsonProperty("name")
+    String getName() {
+        return name;
+    }
+
+    @JsonProperty("sender")
+    Optional<String> getSender() {
+        return sender;
+    }
+
+    @JsonProperty("state")
+    String getState() {
+        return state;
+    }
+
+    @JsonProperty("errorMessage")
+    String getErrorMessage() {
+        return errorMessage;
+    }
+
+    @JsonProperty("lastUpdated")
+    Optional<Instant> getLastUpdated() {
+        return lastUpdated;
+    }
+
+    @JsonProperty("attributes")
+    Map<String, String> getAttributes() {
+        return attributes;
+    }
+
+    @JsonProperty("remoteAddr")
+    String getRemoteAddr() {
+        return remoteAddr;
+    }
+
+    @JsonProperty("remoteHost")
+    String getRemoteHost() {
+        return remoteHost;
+    }
+
+    @JsonProperty("perRecipientHeaders")
+    Map<String, HeadersDto>  getPerRecipientHeaders() {
+        return perRecipientHeaders;
+    }
+
+    @JsonProperty("headerBlobId")
+    String getHeaderBlobId() {
+        return headerBlobId;
+    }
+
+    @JsonProperty("bodyBlobId")
+    String getBodyBlobId() {
+        return bodyBlobId;
+    }
+
+    MailImpl toMailWithMimeMessage(MimeMessage mimeMessage) throws MessagingException {
+        MailImpl mail = new MailImpl(name,
+            sender.map(MailAddress::getMailSender).orElse(null),
+            recipients.stream()
+                .map(Throwing.<String, MailAddress>function(MailAddress::new).sneakyThrow())
+                .collect(Guavate.toImmutableList()),
+            mimeMessage);
+
+        mail.setErrorMessage(errorMessage);
+        mail.setRemoteAddr(remoteAddr);
+        mail.setRemoteHost(remoteHost);
+        mail.setState(state);
+        lastUpdated
+            .map(Instant::toEpochMilli)
+            .map(Date::new)
+            .ifPresent(mail::setLastUpdated);
+
+        attributes
+            .forEach((name, value) -> mail.setAttribute(name, SerializationUtil.<Serializable>deserialize(value)));
+
+        mail.addAllSpecificHeaderForRecipient(retrievePerRecipientHeaders());
+
+        return mail;
+    }
+
+    private PerRecipientHeaders retrievePerRecipientHeaders() {
+        PerRecipientHeaders perRecipientHeaders = new PerRecipientHeaders();
+        this.perRecipientHeaders.entrySet()
+            .stream()
+            .flatMap(entry -> entry.getValue().toHeaders().stream()
+                .map(Throwing.function(header -> Pair.of(new MailAddress(entry.getKey()),
header))))
+            .forEach(pair -> perRecipientHeaders.addHeaderForRecipient(pair.getValue(),
pair.getKey()));
+        return perRecipientHeaders;
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof MailReferenceDTO) {
+            MailReferenceDTO mailDTO = (MailReferenceDTO) o;
+
+            return Objects.equals(this.recipients, mailDTO.recipients)
+                && Objects.equals(this.name, mailDTO.name)
+                && Objects.equals(this.sender, mailDTO.sender)
+                && Objects.equals(this.state, mailDTO.state)
+                && Objects.equals(this.errorMessage, mailDTO.errorMessage)
+                && Objects.equals(this.lastUpdated, mailDTO.lastUpdated)
+                && Objects.equals(this.attributes, mailDTO.attributes)
+                && Objects.equals(this.remoteAddr, mailDTO.remoteAddr)
+                && Objects.equals(this.remoteHost, mailDTO.remoteHost)
+                && Objects.equals(this.perRecipientHeaders, mailDTO.perRecipientHeaders)
+                && Objects.equals(this.headerBlobId, mailDTO.headerBlobId)
+                && Objects.equals(this.bodyBlobId, mailDTO.bodyBlobId);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(recipients, name, sender, state, errorMessage, lastUpdated, attributes,
remoteAddr, remoteHost, perRecipientHeaders, headerBlobId, bodyBlobId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/47eb3bfb/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/MailDTOTest.java
----------------------------------------------------------------------
diff --git a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/MailDTOTest.java
b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/MailDTOTest.java
index 695e978..5da5655 100644
--- a/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/MailDTOTest.java
+++ b/server/queue/queue-rabbitmq/src/test/java/org/apache/james/queue/rabbitmq/MailDTOTest.java
@@ -64,7 +64,7 @@ class MailDTOTest {
 
     @Test
     void mailDtoShouldBeDeserializedFromTheRightFormat() throws Exception {
-        assertThat(objectMapper.readValue(getSystemResourceAsString("json/mail1.json"), MailDTO.class))
+        assertThat(objectMapper.readValue(getSystemResourceAsString("json/mail1.json"), MailReferenceDTO.class))
             .isEqualTo(mailDTO1());
     }
 
@@ -76,12 +76,12 @@ class MailDTOTest {
 
     @Test
     void mailDtoShouldBeDeserializedWhenOnlyNameAndBlob() throws Exception {
-        assertThat(objectMapper.readValue(getSystemResourceAsString("json/mail_min.json"),
MailDTO.class))
+        assertThat(objectMapper.readValue(getSystemResourceAsString("json/mail_min.json"),
MailReferenceDTO.class))
             .isEqualTo(mailDTOMin());
     }
 
-    private MailDTO mailDTO1() throws MessagingException {
-        return MailDTO.fromMail(
+    private MailReferenceDTO mailDTO1() throws MessagingException {
+        return MailReferenceDTO.fromMail(
             FakeMail.builder()
                 .recipients(MailAddressFixture.RECIPIENT1, MailAddressFixture.RECIPIENT2)
                 .sender(MailAddressFixture.SENDER)
@@ -107,12 +107,12 @@ class MailDTOTest {
                 .build());
     }
 
-    private MailDTO mailDTOMin() throws MessagingException {
+    private MailReferenceDTO mailDTOMin() throws MessagingException {
         MailImpl mail = new MailImpl();
         mail.setState(null);
         mail.setName("mail-name-558");
         mail.setLastUpdated(null);
-        return MailDTO.fromMail(
+        return MailReferenceDTO.fromMail(
             mail,
             MimeMessagePartsId.builder()
                 .headerBlobId(BLOB_ID_FACTORY.from("210e7136-ede3-44eb-9495-3ed816d6e23b"))


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message