JAMES-1773 Propose missing tests (handling units)

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

Branch: refs/heads/master
Commit: 7fadba1e6cbf1812babd3e3e942d59783aca8018
Parents: d77682f
Author: Benoit Tellier <[email protected]>
Authored: Wed Aug 17 12:41:17 2016 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Wed Aug 31 00:59:27 2016 +0700

----------------------------------------------------------------------
 .../transport/matchers/SizeGreaterThanTest.java | 37 +++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7fadba1e/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
----------------------------------------------------------------------
diff --git 
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
 
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
index 3f4f805..22ac107 100644
--- 
a/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
+++ 
b/mailet/standard/src/test/java/org/apache/james/transport/matchers/SizeGreaterThanTest.java
@@ -17,7 +17,6 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.james.transport.matchers;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -73,6 +72,42 @@ public class SizeGreaterThanTest {
     }
 
     @Test
+    public void matchShouldNotMatchMailsWithSpecifiedSize() throws 
MessagingException {
+        fakeMail.setMessageSize(1024);
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=1k", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+
+        assertThat(matcher.match(fakeMail)).isNull();
+    }
+
+    @Test
+    public void matchShouldMatchMailsWithSizeSuperiorToSpecifiedSize() throws 
MessagingException {
+        fakeMail.setMessageSize(1025);
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=1k", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+
+        assertThat(matcher.match(fakeMail)).containsExactly(mailAddress);
+    }
+
+    @Test
+    public void matchShouldReturnNullWhenUnderLimitNoUnit() throws 
MessagingException {
+        fakeMail.setMessageSize(4);
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=4", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+
+        assertThat(matcher.match(fakeMail)).isNull();
+    }
+
+    @Test
+    public void matchShouldMatchOverLimitWhenNoUnit() throws 
MessagingException {
+        fakeMail.setMessageSize(5);
+        FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=4", FakeMailContext.defaultContext());
+        matcher.init(matcherConfiguration);
+
+        assertThat(matcher.match(fakeMail)).containsExactly(mailAddress);
+    }
+
+    @Test
     public void initShouldThrowOnInvalidUnits() throws Exception {
         expectedException.expect(MessagingException.class);
         FakeMatcherConfig matcherConfiguration = new 
FakeMatcherConfig("SizeGreaterThan=1mb", FakeMailContext.defaultContext());


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to