james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [21/27] james-project git commit: JAMES-2132 Provide state of the art beans
Date Fri, 01 Sep 2017 01:18:34 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/4020b750/mdn/src/test/java/org/apache/james/mdn/modifier/DispositionModifierTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/modifier/DispositionModifierTest.java
b/mdn/src/test/java/org/apache/james/mdn/modifier/DispositionModifierTest.java
new file mode 100644
index 0000000..a408b51
--- /dev/null
+++ b/mdn/src/test/java/org/apache/james/mdn/modifier/DispositionModifierTest.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.mdn.modifier;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+public class DispositionModifierTest {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @Test
+    public void shouldMatchBeanContract() throws Exception {
+        EqualsVerifier.forClass(DispositionModifier.class)
+            .allFieldsShouldBeUsed()
+            .verify();
+    }
+
+    @Test
+    public void shouldThrowOnNull() {
+        expectedException.expect(NullPointerException.class);
+
+        new DispositionModifier(null);
+    }
+
+    @Test
+    public void shouldThrowOnMultiLine() {
+        expectedException.expect(IllegalArgumentException.class);
+
+        new DispositionModifier("multi\nline");
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/4020b750/mdn/src/test/java/org/apache/james/mdn/sending/mode/DispositionSendingModeTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/sending/mode/DispositionSendingModeTest.java
b/mdn/src/test/java/org/apache/james/mdn/sending/mode/DispositionSendingModeTest.java
new file mode 100644
index 0000000..8b0f185
--- /dev/null
+++ b/mdn/src/test/java/org/apache/james/mdn/sending/mode/DispositionSendingModeTest.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.mdn.sending.mode;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class DispositionSendingModeTest {
+    @Test
+    public void fromStringShouldReturnEmptyWhenUnknown() {
+        assertThat(DispositionSendingMode.fromString("unknown"))
+            .isEmpty();
+    }
+
+    @Test
+    public void fromStringShouldRetrieveAutomatic() {
+        assertThat(DispositionSendingMode.fromString(DispositionSendingMode.Automatic.getValue()))
+            .contains(DispositionSendingMode.Automatic);
+    }
+
+    @Test
+    public void fromStringShouldRetrieveManual() {
+        assertThat(DispositionSendingMode.fromString(DispositionSendingMode.Manual.getValue()))
+            .contains(DispositionSendingMode.Manual);
+    }
+    @Test
+    public void fromStringShouldNotBeCaseSensitive() {
+        assertThat(DispositionSendingMode.fromString("mdn-sent-automatically"))
+            .contains(DispositionSendingMode.Automatic);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/4020b750/mdn/src/test/java/org/apache/james/mdn/type/DispositionTypeTest.java
----------------------------------------------------------------------
diff --git a/mdn/src/test/java/org/apache/james/mdn/type/DispositionTypeTest.java b/mdn/src/test/java/org/apache/james/mdn/type/DispositionTypeTest.java
new file mode 100644
index 0000000..fa8a532
--- /dev/null
+++ b/mdn/src/test/java/org/apache/james/mdn/type/DispositionTypeTest.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.mdn.type;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+public class DispositionTypeTest {
+    @Test
+    public void fromStringShouldReturnEmptyWhenUnknown() {
+        assertThat(DispositionType.fromString("unknown"))
+            .isEmpty();
+    }
+
+    @Test
+    public void fromStringShouldRetrieveDeleted() {
+        assertThat(DispositionType.fromString(DispositionType.Deleted.getValue()))
+            .contains(DispositionType.Deleted);
+    }
+
+    @Test
+    public void fromStringShouldRetrieveDispatched() {
+        assertThat(DispositionType.fromString(DispositionType.Dispatched.getValue()))
+            .contains(DispositionType.Dispatched);
+    }
+
+    @Test
+    public void fromStringShouldRetrieveDisplayed() {
+        assertThat(DispositionType.fromString(DispositionType.Displayed.getValue()))
+            .contains(DispositionType.Displayed);
+    }
+
+    @Test
+    public void fromStringShouldRetrieveProcessed() {
+        assertThat(DispositionType.fromString(DispositionType.Processed.getValue()))
+            .contains(DispositionType.Processed);
+    }
+
+    @Test
+    public void fromStringShouldNotBeCaseSensitive() {
+        assertThat(DispositionType.fromString("Deleted"))
+            .contains(DispositionType.Deleted);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/4020b750/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
index 8cd47ef..2dd88b8 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/jsieve/RejectAction.java
@@ -124,7 +124,7 @@ public class RejectAction implements MailAction {
                 .reportingUserAgentField(
                     new ReportingUserAgent(
                         reporting_UA_name,
-                        Optional.ofNullable(reporting_UA_product)))
+                        reporting_UA_product))
                 .finalRecipientField(new FinalRecipient(Text.fromRawText(final_recipient)))
                 .originalRecipientField(Optional.ofNullable(original_recipient).map(Text::fromRawText).map(OriginalRecipient::new))
                 .originalMessageIdField(new OriginalMessageId(original_message_id))


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