james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [26/50] [abbrv] james-project git commit: MAILET-115 Convert buildNewSubject static method to private method
Date Wed, 11 Jan 2017 09:26:14 GMT
MAILET-115 Convert buildNewSubject static method to private method


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

Branch: refs/heads/master
Commit: ab7e33bd74f77c2ff1cf5e2afc0cf57a66e9c988
Parents: 8b1a8c8
Author: Antoine Duprat <aduprat@apache.org>
Authored: Tue Nov 15 12:50:35 2016 +0100
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Wed Jan 11 10:03:30 2017 +0700

----------------------------------------------------------------------
 .../transport/mailets/utils/MimeMessageModifier.java |  3 ++-
 .../mailets/utils/MimeMessageModifierTest.java       | 15 ++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ab7e33bd/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/MimeMessageModifier.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/MimeMessageModifier.java
b/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/MimeMessageModifier.java
index 1d0692f..b253621 100644
--- a/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/MimeMessageModifier.java
+++ b/mailet/standard/src/main/java/org/apache/james/transport/mailets/utils/MimeMessageModifier.java
@@ -24,6 +24,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.mailet.Mail;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Charsets;
 import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
@@ -62,7 +63,7 @@ public class MimeMessageModifier {
         }
     }
 
-    public static Optional<String> buildNewSubject(String subjectPrefix, String originalSubject,
String subject) throws MessagingException {
+    @VisibleForTesting Optional<String> buildNewSubject(String subjectPrefix, String
originalSubject, String subject) throws MessagingException {
         String nullablePrefix = Strings.emptyToNull(subjectPrefix);
         if (nullablePrefix == null && subject == null) {
             return Optional.absent();

http://git-wip-us.apache.org/repos/asf/james-project/blob/ab7e33bd/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
----------------------------------------------------------------------
diff --git a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
index d80fd30..175817a 100644
--- a/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
+++ b/mailet/standard/src/test/java/org/apache/james/transport/mailets/utils/MimeMessageModifierTest.java
@@ -83,49 +83,54 @@ public class MimeMessageModifierTest {
 
     @Test
     public void buildNewSubjectShouldPrefixOriginalSubjectWhenSubjectIsNull() throws Exception
{
+        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         String prefix = "prefix";
         String originalSubject = "original subject";
-        Optional<String> newSubject = MimeMessageModifier.buildNewSubject(prefix, originalSubject,
null);
+        Optional<String> newSubject = new MimeMessageModifier(message).buildNewSubject(prefix,
originalSubject, null);
 
         assertThat(newSubject.get()).isEqualTo(prefix + " " + originalSubject);
     }
 
     @Test
     public void buildNewSubjectShouldPrefixNewSubjectWhenSubjectIsGiven() throws Exception
{
+        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         String prefix = "prefix";
         String originalSubject = "original subject";
         String subject = "new subject";
-        Optional<String> newSubject = MimeMessageModifier.buildNewSubject(prefix, originalSubject,
subject);
+        Optional<String> newSubject = new MimeMessageModifier(message).buildNewSubject(prefix,
originalSubject, subject);
 
         assertThat(newSubject.get()).isEqualTo(prefix + " " + subject);
     }
 
     @Test
     public void buildNewSubjectShouldReplaceSubjectWhenPrefixIsNull() throws Exception {
+        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         String prefix = null;
         String originalSubject = "original subject";
         String subject = "new subject";
-        Optional<String> newSubject = MimeMessageModifier.buildNewSubject(prefix, originalSubject,
subject);
+        Optional<String> newSubject = new MimeMessageModifier(message).buildNewSubject(prefix,
originalSubject, subject);
 
         assertThat(newSubject.get()).isEqualTo(subject);
     }
 
     @Test
     public void buildNewSubjectShouldReplaceSubjectWhenPrefixIsEmpty() throws Exception {
+        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         String prefix = "";
         String originalSubject = "original subject";
         String subject = "new subject";
-        Optional<String> newSubject = MimeMessageModifier.buildNewSubject(prefix, originalSubject,
subject);
+        Optional<String> newSubject = new MimeMessageModifier(message).buildNewSubject(prefix,
originalSubject, subject);
 
         assertThat(newSubject.get()).isEqualTo(subject);
     }
 
     @Test
     public void buildNewSubjectShouldReplaceSubjectWithPrefixWhenSubjectIsEmpty() throws
Exception {
+        MimeMessage message = new MimeMessage(Session.getDefaultInstance(new Properties()));
         String prefix = "prefix";
         String originalSubject = "original subject";
         String subject = "";
-        Optional<String> newSubject = MimeMessageModifier.buildNewSubject(prefix, originalSubject,
subject);
+        Optional<String> newSubject = new MimeMessageModifier(message).buildNewSubject(prefix,
originalSubject, subject);
 
         assertThat(newSubject.get()).isEqualTo(prefix);
     }


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