james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [7/9] james-project git commit: JAMES-2578 Add tests for Deprecated attribute* methods
Date Mon, 05 Nov 2018 14:26:54 GMT
JAMES-2578 Add tests for Deprecated attribute* methods


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

Branch: refs/heads/master
Commit: 5b98f733fe4071a7ce7f1962d6ccba026b64aeb0
Parents: f1517bd
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Nov 2 15:18:49 2018 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Nov 5 11:58:06 2018 +0100

----------------------------------------------------------------------
 .../org/apache/mailet/ContractMailTest.java     | 109 ++++++++++++++++++-
 1 file changed, 108 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5b98f733/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
----------------------------------------------------------------------
diff --git a/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java b/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
index 7dda0b9..77da3bc 100644
--- a/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
+++ b/mailet/api/src/test/java/org/apache/mailet/ContractMailTest.java
@@ -22,10 +22,12 @@ package org.apache.mailet;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.io.Serializable;
+
 import org.assertj.core.api.SoftAssertions;
-import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
 
 import com.google.common.collect.ImmutableMap;
 
@@ -35,6 +37,9 @@ public abstract class ContractMailTest {
     private final static Attribute ATTRIBUTE_1 = new Attribute(ATTRIBUTE_NAME_1, AttributeValue.of(true));
     private final static Attribute ATTRIBUTE_2 = new Attribute(ATTRIBUTE_NAME_2, AttributeValue.of("value2"));
     private final static Attribute ATTRIBUTE_1_BIS = new Attribute(ATTRIBUTE_NAME_1, AttributeValue.of("value1"));
+    private static final String VALUE = "value";
+    private static final String KEY = "key";
+    private static final String NEW_VALUE = "newValue";
 
     public abstract Mail newMail();
 
@@ -145,4 +150,106 @@ public abstract class ContractMailTest {
             assertThat(mail.attributesMap()).isEqualTo(ImmutableMap.of(ATTRIBUTE_NAME_1,
ATTRIBUTE_1, ATTRIBUTE_NAME_2, ATTRIBUTE_2));
         }
     }
+
+    @SuppressWarnings("deprecated")
+    @Nested
+    public class DeprecatedtedAttributes {
+        @Test
+        void setAttributeShouldReturnNullWhenNoPreviousValue() {
+            Mail mail = newMail();
+
+            Serializable previous = mail.setAttribute(KEY, VALUE);
+
+            assertThat(previous).isNull();
+        }
+
+        @Test
+        void setAttributeShouldReturnPreviousValue() {
+            Mail mail = newMail();
+
+            mail.setAttribute(KEY, VALUE);
+            Serializable previous = mail.setAttribute(KEY, NEW_VALUE);
+
+            assertThat(previous).isEqualTo(VALUE);
+        }
+
+        @Test
+        void getAttributeShouldReturnNullWhenNoAssociatedValue() {
+            Mail mail = newMail();
+
+            assertThat(mail.getAttribute(KEY)).isNull();
+        }
+
+        @Test
+        void setAttributeShouldReturnValue() {
+            Mail mail = newMail();
+
+            mail.setAttribute(KEY, VALUE);
+
+            assertThat(mail.getAttribute(KEY)).isEqualTo(VALUE);
+        }
+
+        @Test
+        void setAttributeShouldReturnLatestValue() {
+            Mail mail = newMail();
+            mail.setAttribute(KEY, VALUE);
+
+            mail.setAttribute(KEY, NEW_VALUE);
+
+            assertThat(mail.getAttribute(KEY)).isEqualTo(NEW_VALUE);
+        }
+
+        @Test
+        void getAttributeShouldNotReturnedNotStoreRemovedItems() {
+            Mail mail = newMail();
+
+            mail.removeAttribute(KEY);
+
+            assertThat(mail.getAttribute(KEY)).isNull();
+        }
+
+        @Test
+        void getAttributeShouldNotReturnDeletedElements() {
+            Mail mail = newMail();
+            mail.setAttribute(KEY, VALUE);
+
+            mail.removeAttribute(KEY);
+
+            assertThat(mail.getAttribute(KEY)).isNull();
+        }
+
+        @Test
+        void removeAttributeShouldReturnNullWhenNoPreviousValue() {
+            Mail mail = newMail();
+
+            Serializable previous = mail.removeAttribute(KEY);
+
+            assertThat(previous).isNull();
+        }
+
+        @Test
+        void removeAttributeShouldReturnPreviousValue() {
+            Mail mail = newMail();
+            mail.setAttribute(KEY, VALUE);
+
+            Serializable previous = mail.removeAttribute(KEY);
+
+            assertThat(previous).isEqualTo(VALUE);
+        }
+
+        @Test
+        void getAttributeNamesShouldReturnEmptyByDefault() {
+            Mail mail = newMail();
+
+            assertThat(mail.getAttributeNames()).isEmpty();
+        }
+
+        @Test
+        void getAttributeNamesShouldReturnAttributeNames() {
+            Mail mail = newMail();
+            mail.setAttribute(KEY, VALUE);
+
+            assertThat(mail.getAttributeNames()).containsOnly(KEY);
+        }
+    }
 }


---------------------------------------------------------------------
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