You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/02/15 00:01:23 UTC

[05/13] james-project git commit: JAMES-1934 add tests to PropertyBuilder

JAMES-1934 add tests to PropertyBuilder


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

Branch: refs/heads/master
Commit: 59cfd844b98cfeeced35234dbcd8c32abff1635e
Parents: 3705c18
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Feb 8 11:48:12 2017 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Feb 15 06:59:45 2017 +0700

----------------------------------------------------------------------
 .../mailbox/store/SimpleMailboxMembership.java  |  8 +++-
 .../mail/model/impl/PropertyBuilderTest.java    | 49 ++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/59cfd844/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
index fd67f05..c69e7aa 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
@@ -44,6 +44,8 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.Property;
 
 import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
 
 public class SimpleMailboxMembership implements MailboxMessage {
     
@@ -233,7 +235,11 @@ public class SimpleMailboxMembership implements MailboxMessage {
     }
 
     public List<Property> getProperties() {
-        return new ArrayList<Property>(properties);
+        if (properties != null) {
+            return ImmutableList.<Property>copyOf(properties);
+        } else {
+            return ImmutableList.of();
+        }
     }
 
     public Long getTextualLineCount() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/59cfd844/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
new file mode 100644
index 0000000..79b1548
--- /dev/null
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.store.mail.model.impl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class PropertyBuilderTest {
+
+    @Test
+    public void emptyPropertyBuilderShouldCreateEmptyProperties() {
+        assertThat(new PropertyBuilder().toProperties()).isEmpty();
+    }
+
+    @Test
+    public void setHasAttachmentShouldAddFalseWhenCalledWithFalse() {
+        PropertyBuilder propertyBuilder = new PropertyBuilder();
+        propertyBuilder.setHasAttachment(false);
+        assertThat(propertyBuilder.toProperties())
+            .containsOnly(new SimpleProperty(PropertyBuilder.JAMES_INTERNALS, PropertyBuilder.HAS_ATTACHMENT, "false"));
+    }
+
+    @Test
+    public void setHasAttachmentShouldAddTrueWhenCalledWithTrue() {
+        PropertyBuilder propertyBuilder = new PropertyBuilder();
+        propertyBuilder.setHasAttachment(true);
+        assertThat(propertyBuilder.toProperties())
+            .containsOnly(new SimpleProperty(PropertyBuilder.JAMES_INTERNALS, PropertyBuilder.HAS_ATTACHMENT, "true"));
+    }
+
+}


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