james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [03/24] james-project git commit: JAMES-2366 User strong type for mapping prefix
Date Tue, 03 Apr 2018 10:02:49 GMT
JAMES-2366 User strong type for mapping prefix


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

Branch: refs/heads/master
Commit: e2cc20f3a611d76c0a3fe95cb5f4835148cfc9fe
Parents: 7b8f50a
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Tue Mar 27 14:51:32 2018 +0200
Committer: benwa <btellier@linagora.com>
Committed: Tue Apr 3 16:58:07 2018 +0700

----------------------------------------------------------------------
 .../james/rrt/api/RecipientRewriteTable.java    | 24 ------
 .../java/org/apache/james/rrt/lib/Mapping.java  | 17 +++-
 .../CassandraRecipientRewriteTableTest.java     | 21 ++---
 .../rrt/file/XMLRecipientRewriteTableTest.java  | 26 ++----
 .../hbase/HBaseRecipientRewriteTableTest.java   | 21 ++---
 .../rrt/jdbc/JDBCRecipientRewriteTableTest.java | 21 ++---
 .../rrt/jpa/JPARecipientRewriteTableTest.java   | 21 ++---
 server/data/data-library/pom.xml                |  5 ++
 .../rrt/lib/AbstractRecipientRewriteTable.java  | 30 +++----
 .../org/apache/james/rrt/lib/MappingImpl.java   | 56 +++++++------
 .../rrt/lib/RecipientRewriteTableUtil.java      |  6 +-
 .../lib/AbstractRecipientRewriteTableTest.java  | 86 ++++++++++----------
 .../apache/james/rrt/lib/MappingImplTest.java   | 13 +--
 .../memory/MemoryRecipientRewriteTableTest.java | 21 ++---
 14 files changed, 181 insertions(+), 187 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
index b747c71..f07fd69 100644
--- a/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
+++ b/server/data/data-api/src/main/java/org/apache/james/rrt/api/RecipientRewriteTable.java
@@ -45,30 +45,6 @@ public interface RecipientRewriteTable {
     }
 
     /**
-     * 
-     * Prefixes used for:
-     *  - error mappings
-     *  - regex mappings
-     *  - alias domain mappings
-     *
-     */
-    public enum Prefix {
-        ERROR("error:"),
-        REGEX("regex:"),
-        ALIASDOMAIN("domain:");
-
-        private final String asString;
-
-        private Prefix(String asString) {
-            this.asString = asString;
-        }
-
-        public String asString() {
-            return asString;
-        }
-    }
-
-    /**
      * The wildcard used for alias domain mappings
      */
     String WILDCARD = "*";

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
index 6f00c70..51645d0 100644
--- a/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
+++ b/server/data/data-api/src/main/java/org/apache/james/rrt/lib/Mapping.java
@@ -26,7 +26,22 @@ public interface Mapping {
 
     String getAddress();
 
-    enum Type { Regex, Domain, Error, Address }
+    enum Type { 
+        Regex("regex:"), 
+        Domain("domain:"), 
+        Error("error:"), 
+        Address(""); 
+
+        private final String asPrefix;
+
+        private Type(String asPrefix) {
+            this.asPrefix = asPrefix;
+        }
+
+        public String asPrefix() {
+            return asPrefix;
+        }
+    }
 
     Type getType();
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
index a82e94f..b57aceb 100644
--- a/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
+++ b/server/data/data-cassandra/src/test/java/org/apache/james/rrt/cassandra/CassandraRecipientRewriteTableTest.java
@@ -26,6 +26,7 @@ import org.apache.james.core.Domain;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
@@ -59,18 +60,18 @@ public class CassandraRecipientRewriteTableTest extends AbstractRecipientRewrite
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.addErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.addRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.addAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:
@@ -79,18 +80,18 @@ public class CassandraRecipientRewriteTableTest extends AbstractRecipientRewrite
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.removeErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.removeRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.removeAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java b/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
index c683c60..d4dd938 100644
--- a/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
+++ b/server/data/data-file/src/test/java/org/apache/james/rrt/file/XMLRecipientRewriteTableTest.java
@@ -24,10 +24,10 @@ import java.util.Optional;
 
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.apache.james.rrt.lib.MappingImpl;
 import org.apache.james.rrt.lib.Mappings;
 import org.apache.james.rrt.lib.MappingsImpl;
@@ -70,7 +70,7 @@ public class XMLRecipientRewriteTableTest extends AbstractRecipientRewriteTableT
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws
             RecipientRewriteTableException {
 
         Mappings mappings = virtualUserTable.getUserDomainMappings(user, domain);
@@ -80,16 +80,8 @@ public class XMLRecipientRewriteTableTest extends AbstractRecipientRewriteTableT
         }
 
         Builder builder = MappingsImpl.from(Optional.ofNullable(mappings).orElse(MappingsImpl.empty()));
-        
-        if (type == ERROR_TYPE) {
-            builder.add(RecipientRewriteTable.ERROR_PREFIX + mapping);
-        } else if (type == REGEX_TYPE) {
-            builder.add(RecipientRewriteTable.REGEX_PREFIX + mapping);
-        } else if (type == ADDRESS_TYPE) {
-            builder.add(mapping);
-        } else if (type == ALIASDOMAIN_TYPE) {
-            builder.add(RecipientRewriteTable.ALIASDOMAIN_PREFIX + mapping);
-        }
+
+        builder.add(type.asPrefix() + mapping);
 
         Mappings updatedMappings = builder.build();
         
@@ -108,7 +100,7 @@ public class XMLRecipientRewriteTableTest extends AbstractRecipientRewriteTableT
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws
             RecipientRewriteTableException {
 
         Mappings mappings = virtualUserTable.getUserDomainMappings(user, domain);
@@ -119,13 +111,13 @@ public class XMLRecipientRewriteTableTest extends AbstractRecipientRewriteTableT
 
         removeMappingsFromConfig(user, domain, mappings);
 
-        if (type == ERROR_TYPE) {
+        if (type == Type.Error) {
             mappings = mappings.remove(MappingImpl.error(mapping));
-        } else if (type == REGEX_TYPE) {
+        } else if (type == Type.Regex) {
             mappings = mappings.remove(MappingImpl.regex(mapping));
-        } else if (type == ADDRESS_TYPE) {
+        } else if (type == Type.Address) {
             mappings = mappings.remove(MappingImpl.address(mapping));
-        } else if (type == ALIASDOMAIN_TYPE) {
+        } else if (type == Type.Domain) {
             mappings = mappings.remove(MappingImpl.domain(Domain.of(mapping)));
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
index 116bc63..9e9ce74 100644
--- a/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
+++ b/server/data/data-hbase/src/test/java/org/apache/james/rrt/hbase/HBaseRecipientRewriteTableTest.java
@@ -24,6 +24,7 @@ import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.apache.james.system.hbase.TablePool;
 import org.junit.After;
 import org.junit.Before;
@@ -58,18 +59,18 @@ public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTabl
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.addErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.addRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.addAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:
@@ -78,18 +79,18 @@ public class HBaseRecipientRewriteTableTest extends AbstractRecipientRewriteTabl
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.removeErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.removeRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.removeAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
index eb7a734..4ad97d4 100644
--- a/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
+++ b/server/data/data-jdbc/src/test/java/org/apache/james/rrt/jdbc/JDBCRecipientRewriteTableTest.java
@@ -26,6 +26,7 @@ import org.apache.james.filesystem.api.mock.MockFileSystem;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -70,18 +71,18 @@ public class JDBCRecipientRewriteTableTest extends AbstractRecipientRewriteTable
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.addErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.addRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.addAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:
@@ -90,18 +91,18 @@ public class JDBCRecipientRewriteTableTest extends AbstractRecipientRewriteTable
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.removeErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.removeRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.removeAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
index 5c6ba96..b88712e 100644
--- a/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
+++ b/server/data/data-jpa/src/test/java/org/apache/james/rrt/jpa/JPARecipientRewriteTableTest.java
@@ -25,6 +25,7 @@ import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -57,18 +58,18 @@ public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableT
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.addErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.addRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.addAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:
@@ -77,18 +78,18 @@ public class JPARecipientRewriteTableTest extends AbstractRecipientRewriteTableT
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.removeErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.removeRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.removeAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/pom.xml
----------------------------------------------------------------------
diff --git a/server/data/data-library/pom.xml b/server/data/data-library/pom.xml
index 7aa1bc1..fe9bb3e 100644
--- a/server/data/data-library/pom.xml
+++ b/server/data/data-library/pom.xml
@@ -100,6 +100,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+            <artifactId>equalsverifier</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.assertj</groupId>
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
index d1d178a..764981e 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTable.java
@@ -119,14 +119,14 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT
                 MappingsImpl.Builder mappings = MappingsImpl.builder();
 
                 for (String target : targetMappings.asStrings()) {
-                    if (target.startsWith(RecipientRewriteTable.REGEX_PREFIX)) {
+                    if (target.startsWith(Type.Regex.asPrefix())) {
                         try {
                             target = RecipientRewriteTableUtil.regexMap(new MailAddress(user, domain.asString()), target);
                         } catch (PatternSyntaxException | ParseException e) {
                             LOGGER.error("Exception during regexMap processing: ", e);
                         }
-                    } else if (target.startsWith(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
-                        target = user + "@" + target.substring(RecipientRewriteTable.ALIASDOMAIN_PREFIX.length());
+                    } else if (target.startsWith(Type.Domain.asPrefix())) {
+                        target = user + "@" + target.substring(Type.Domain.asPrefix().length());
                     }
 
                     if (target == null) {
@@ -249,15 +249,15 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT
 
         String map = mapping.toLowerCase(Locale.US);
 
-        if (map.startsWith(RecipientRewriteTable.ERROR_PREFIX)) {
-            addErrorMapping(user, domain, map.substring(RecipientRewriteTable.ERROR_PREFIX.length()));
-        } else if (map.startsWith(RecipientRewriteTable.REGEX_PREFIX)) {
-            addRegexMapping(user, domain, map.substring(RecipientRewriteTable.REGEX_PREFIX.length()));
-        } else if (map.startsWith(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
+        if (map.startsWith(Type.Error.asPrefix())) {
+            addErrorMapping(user, domain, map.substring(Type.Error.asPrefix().length()));
+        } else if (map.startsWith(Type.Regex.asPrefix())) {
+            addRegexMapping(user, domain, map.substring(Type.Regex.asPrefix().length()));
+        } else if (map.startsWith(Type.Domain.asPrefix())) {
             if (user != null) {
                 throw new RecipientRewriteTableException("User must be null for aliasDomain mappings");
             }
-            String domainName = map.substring(RecipientRewriteTable.ALIASDOMAIN_PREFIX.length());
+            String domainName = map.substring(Type.Domain.asPrefix().length());
             addAliasDomainMapping(domain, Domain.of(domainName));
         } else {
             addAddressMapping(user, domain, map);
@@ -270,15 +270,15 @@ public abstract class AbstractRecipientRewriteTable implements RecipientRewriteT
 
         String map = mapping.toLowerCase(Locale.US);
 
-        if (map.startsWith(RecipientRewriteTable.ERROR_PREFIX)) {
-            removeErrorMapping(user, domain, map.substring(RecipientRewriteTable.ERROR_PREFIX.length()));
-        } else if (map.startsWith(RecipientRewriteTable.REGEX_PREFIX)) {
-            removeRegexMapping(user, domain, map.substring(RecipientRewriteTable.REGEX_PREFIX.length()));
-        } else if (map.startsWith(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
+        if (map.startsWith(Type.Error.asPrefix())) {
+            removeErrorMapping(user, domain, map.substring(Type.Error.asPrefix().length()));
+        } else if (map.startsWith(Type.Regex.asPrefix())) {
+            removeRegexMapping(user, domain, map.substring(Type.Regex.asPrefix().length()));
+        } else if (map.startsWith(Type.Domain.asPrefix())) {
             if (user != null) {
                 throw new RecipientRewriteTableException("User must be null for aliasDomain mappings");
             }
-            String domainName = map.substring(RecipientRewriteTable.ALIASDOMAIN_PREFIX.length());
+            String domainName = map.substring(Type.Domain.asPrefix().length());
             removeAliasDomainMapping(domain, Domain.of(domainName));
         } else {
             removeAddressMapping(user, domain, map);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
index ffb0f3e..87e093a 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/MappingImpl.java
@@ -23,7 +23,6 @@ package org.apache.james.rrt.lib;
 import java.io.Serializable;
 
 import org.apache.james.core.Domain;
-import org.apache.james.rrt.api.RecipientRewriteTable;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
@@ -33,38 +32,48 @@ public class MappingImpl implements Mapping, Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    private static final String ADDRESS_PREFIX = "";
-
     public static MappingImpl of(String mapping) {
-        return new MappingImpl("", mapping);
+        if (mapping.startsWith(Type.Regex.asPrefix())) {
+            return new MappingImpl(Type.Regex, mapping.substring(Type.Regex.asPrefix().length()));
+        }
+        if (mapping.startsWith(Type.Error.asPrefix())) {
+            return new MappingImpl(Type.Error, mapping.substring(Type.Error.asPrefix().length()));
+        }
+        if (mapping.startsWith(Type.Domain.asPrefix())) {
+            return new MappingImpl(Type.Domain, mapping.substring(Type.Domain.asPrefix().length()));
+        }
+        return new MappingImpl(Type.Address, mapping.substring(Type.Address.asPrefix().length()));
     }
     
     public static MappingImpl address(String mapping) {
-        return new MappingImpl(ADDRESS_PREFIX, mapping);
+        return new MappingImpl(Type.Address, mapping);
     }
 
     public static MappingImpl regex(String mapping) {
-        return new MappingImpl(RecipientRewriteTable.REGEX_PREFIX, mapping);
+        return new MappingImpl(Type.Regex, mapping);
     }
 
     public static MappingImpl error(String mapping) {
-        return new MappingImpl(RecipientRewriteTable.ERROR_PREFIX, mapping);
+        return new MappingImpl(Type.Error, mapping);
     }
 
     public static MappingImpl domain(Domain mapping) {
-        return new MappingImpl(RecipientRewriteTable.ALIASDOMAIN_PREFIX, mapping.asString());
+        return new MappingImpl(Type.Domain, mapping.asString());
     }
     
+    private final Type type;
     private final String mapping;
 
-    private MappingImpl(String prefix, String mapping) {
+    private MappingImpl(Type type, String mapping) {
+        Preconditions.checkNotNull(type);
         Preconditions.checkNotNull(mapping);
-        this.mapping = prefix + mapping;
+        this.type = type;
+        this.mapping = mapping;
     }
     
     @Override
     public String asString() {
-        return mapping;
+        return type.asPrefix() + mapping;
     }
     
     @Override
@@ -75,26 +84,18 @@ public class MappingImpl implements Mapping, Serializable {
     @Override
     public Mapping appendDomain(Domain domain) {
         Preconditions.checkNotNull(domain);
-        return new MappingImpl("", mapping + "@" + domain.asString());
+        return new MappingImpl(type, mapping + "@" + domain.asString());
     }
     
     @Override
     public Type getType() {
-        if (mapping.startsWith(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
-            return Type.Domain;
-        } else if (mapping.startsWith(RecipientRewriteTable.REGEX_PREFIX)) {
-            return Type.Regex;
-        } else if (mapping.startsWith(RecipientRewriteTable.ERROR_PREFIX)) {
-            return Type.Error;
-        } else {
-            return Type.Address;
-        }
+        return type;
     }
     
     @Override
     public String getErrorMessage() {
         Preconditions.checkState(getType() == Type.Error);
-        return mapping.substring(RecipientRewriteTable.ERROR_PREFIX.length());
+        return mapping;
     }
 
     @Override
@@ -104,21 +105,22 @@ public class MappingImpl implements Mapping, Serializable {
     }
 
     @Override
-    public boolean equals(Object other) {
+    public final boolean equals(Object other) {
         if (other instanceof MappingImpl) {
             MappingImpl otherMapping = (MappingImpl) other;
-            return Objects.equal(mapping, otherMapping.mapping);
+            return Objects.equal(type, otherMapping.type)
+                && Objects.equal(mapping, otherMapping.mapping);
         }
         return false;
     }
 
     @Override
-    public int hashCode() {
-        return Objects.hashCode(mapping);
+    public final int hashCode() {
+        return Objects.hashCode(type, mapping);
     }
 
     @Override
     public String toString() {
-        return "MappingImpl{mapping=" + mapping + "}";
+        return "MappingImpl{type=" + type + " mapping=" + mapping + "}";
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
index 89d3d79..44c5db1 100644
--- a/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
+++ b/server/data/data-library/src/main/java/org/apache/james/rrt/lib/RecipientRewriteTableUtil.java
@@ -28,7 +28,7 @@ import java.util.regex.PatternSyntaxException;
 
 import org.apache.james.core.Domain;
 import org.apache.james.core.MailAddress;
-import org.apache.james.rrt.api.RecipientRewriteTable;
+import org.apache.james.rrt.lib.Mapping.Type;
 
 /**
  * This helper class contains methods for the RecipientRewriteTable implementations
@@ -57,7 +57,7 @@ public class RecipientRewriteTableUtil {
      */
     public static String regexMap(MailAddress address, String targetString) {
         String result = null;
-        int identifierLength = RecipientRewriteTable.REGEX_PREFIX.length();
+        int identifierLength = Type.Regex.asPrefix().length();
 
         int msgPos = targetString.indexOf(':', identifierLength + 1);
 
@@ -180,7 +180,7 @@ public class RecipientRewriteTableUtil {
      * @return the character to tokenize on
      */
     public static String getSeparator(String targetString) {
-        return (targetString.indexOf(',') > -1 ? "," : (targetString.indexOf(';') > -1 ? ";" : ((targetString.contains(RecipientRewriteTable.ERROR_PREFIX) || targetString.contains(RecipientRewriteTable.REGEX_PREFIX) || targetString.contains(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) ? "" : ":")));
+        return (targetString.indexOf(',') > -1 ? "," : (targetString.indexOf(';') > -1 ? ";" : ((targetString.contains(Type.Error.asPrefix()) || targetString.contains(Type.Regex.asPrefix()) || targetString.contains(Type.Domain.asPrefix())) ? "" : ":")));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
index a67cb33..6cfc49b 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/AbstractRecipientRewriteTableTest.java
@@ -28,6 +28,7 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.api.RecipientRewriteTable.ErrorMappingException;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -42,10 +43,6 @@ public abstract class AbstractRecipientRewriteTableTest {
     @Rule public ExpectedException expectedException = ExpectedException.none();
 
     protected AbstractRecipientRewriteTable virtualUserTable;
-    protected static final int REGEX_TYPE = 0;
-    protected static final int ERROR_TYPE = 1;
-    protected static final int ADDRESS_TYPE = 2;
-    protected static final int ALIASDOMAIN_TYPE = 3;
 
     public void setUp() throws Exception {
         virtualUserTable = getRecipientRewriteTable();
@@ -81,7 +78,7 @@ public abstract class AbstractRecipientRewriteTableTest {
         String user = "*";
         Domain domain = Domain.of("test");
         String regex = "prefix_.*:admin@test";
-        addMapping(user, domain, regex, REGEX_TYPE);
+        addMapping(user, domain, regex, Type.Regex);
         assertThat(virtualUserTable.getMappings("prefix_abc", domain)).isNotEmpty();
     }
 
@@ -97,18 +94,18 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
 
-        addMapping(user, domain, regex, REGEX_TYPE);
-        addMapping(user, domain, regex2, REGEX_TYPE);
+        addMapping(user, domain, regex, Type.Regex);
+        addMapping(user, domain, regex2, Type.Regex);
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("Two mappings").hasSize(2);
         assertThat(virtualUserTable.getAllMappings()).describedAs("One mappingline").hasSize(1);
-        removeMapping(user, domain, regex, REGEX_TYPE);
+        removeMapping(user, domain, regex, Type.Regex);
 
         assertThatThrownBy(() -> virtualUserTable.addRegexMapping(user, domain, invalidRegex))
             .describedAs("Invalid Mapping throw exception")
             .isInstanceOf(RecipientRewriteTableException.class);
 
 
-        removeMapping(user, domain, regex2, REGEX_TYPE);
+        removeMapping(user, domain, regex2, Type.Regex);
 
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
@@ -125,15 +122,15 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
 
-        addMapping(user, domain, address, ADDRESS_TYPE);
-        addMapping(user, domain, address2, ADDRESS_TYPE);
+        addMapping(user, domain, address, Type.Address);
+        addMapping(user, domain, address2, Type.Address);
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("Two mappings").hasSize(2);
         assertThat(virtualUserTable.getAllMappings()).describedAs("One mappingline").hasSize(1);
 
-        removeMapping(user, domain, address, ADDRESS_TYPE);
+        removeMapping(user, domain, address, Type.Address);
 
-        removeMapping(user, domain, address2, ADDRESS_TYPE);
+        removeMapping(user, domain, address2, Type.Address);
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
         assertThat(virtualUserTable.getAllMappings()).describedAs("No mapping").isNull();
@@ -147,7 +144,7 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
 
-        addMapping(user, domain, error, ERROR_TYPE);
+        addMapping(user, domain, error, Type.Error);
         assertThat(virtualUserTable.getAllMappings()).describedAs("One mappingline").hasSize(1);
 
         assertThatThrownBy(() ->
@@ -155,7 +152,7 @@ public abstract class AbstractRecipientRewriteTableTest {
             .describedAs("Exception thrown on to many mappings")
             .isInstanceOf(ErrorMappingException.class);
 
-        removeMapping(user, domain, error, ERROR_TYPE);
+        removeMapping(user, domain, error, Type.Error);
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
         assertThat(virtualUserTable.getAllMappings()).describedAs("No mapping").isNull();
@@ -171,14 +168,14 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
 
-        addMapping(RecipientRewriteTable.WILDCARD, domain, address, ADDRESS_TYPE);
-        addMapping(user, domain, address2, ADDRESS_TYPE);
+        addMapping(RecipientRewriteTable.WILDCARD, domain, address, Type.Address);
+        addMapping(user, domain, address2, Type.Address);
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("One mappings").hasSize(1);
         assertThat(virtualUserTable.getMappings(user2, domain)).describedAs("One mappings").hasSize(1);
 
-        removeMapping(user, domain, address2, ADDRESS_TYPE);
-        removeMapping(RecipientRewriteTable.WILDCARD, domain, address, ADDRESS_TYPE);
+        removeMapping(user, domain, address2, Type.Address);
+        removeMapping(RecipientRewriteTable.WILDCARD, domain, address, Type.Address);
 
         assertThat(virtualUserTable.getMappings(user, domain)).describedAs("No mapping").isNull();
         assertThat(virtualUserTable.getMappings(user2, domain)).describedAs("No mapping").isNull();
@@ -197,10 +194,10 @@ public abstract class AbstractRecipientRewriteTableTest {
 
             assertThat(virtualUserTable.getAllMappings()).describedAs("No mapping").isNull();
 
-            addMapping(user1, domain1, user2 + "@" + domain2.asString(), ADDRESS_TYPE);
-            addMapping(user2, domain2, user3 + "@" + domain3.asString(), ADDRESS_TYPE);
+            addMapping(user1, domain1, user2 + "@" + domain2.asString(), Type.Address);
+            addMapping(user2, domain2, user3 + "@" + domain3.asString(), Type.Address);
             assertThat(virtualUserTable.getMappings(user1, domain1)).containsOnly(MappingImpl.address(user3 + "@" + domain3.asString()));
-            addMapping(user3, domain3, user1 + "@" + domain1.asString(), ADDRESS_TYPE);
+            addMapping(user3, domain3, user1 + "@" + domain1.asString(), Type.Address);
             
             assertThatThrownBy(() ->
                 virtualUserTable.getMappings(user1, domain1))
@@ -222,16 +219,16 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         assertThat(virtualUserTable.getAllMappings()).describedAs("No mappings").isNull();
 
-        addMapping(RecipientRewriteTable.WILDCARD, aliasDomain, user2 + "@" + domain, ADDRESS_TYPE);
-        addMapping(RecipientRewriteTable.WILDCARD, aliasDomain, domain, ALIASDOMAIN_TYPE);
+        addMapping(RecipientRewriteTable.WILDCARD, aliasDomain, user2 + "@" + domain, Type.Address);
+        addMapping(RecipientRewriteTable.WILDCARD, aliasDomain, domain, Type.Domain);
 
         assertThat(virtualUserTable.getMappings(user, aliasDomain))
             .describedAs("Domain mapped as first, Address mapped as second")
             .containsExactly(MappingImpl.address(user + "@" + domain), MappingImpl.address(user2 + "@" + domain));
 
-        removeMapping(RecipientRewriteTable.WILDCARD, aliasDomain, user2 + "@" + domain, ADDRESS_TYPE);
+        removeMapping(RecipientRewriteTable.WILDCARD, aliasDomain, user2 + "@" + domain, Type.Address);
 
-        removeMapping(RecipientRewriteTable.WILDCARD, aliasDomain, domain, ALIASDOMAIN_TYPE);
+        removeMapping(RecipientRewriteTable.WILDCARD, aliasDomain, domain, Type.Domain);
     }
 
     @Test
@@ -241,7 +238,7 @@ public abstract class AbstractRecipientRewriteTableTest {
 
     @Test
     public void sortMappingsShouldReturnSameStringWhenSingleDomainAlias() {
-        String singleDomainAlias = RecipientRewriteTable.ALIASDOMAIN_PREFIX + "first";
+        String singleDomainAlias = Type.Domain.asPrefix() + "first";
         assertThat(AbstractRecipientRewriteTable.sortMappings(MappingsImpl.fromRawString(singleDomainAlias)))
             .containsExactly(MappingImpl.domain(Domain.of("first")));
     }
@@ -249,16 +246,16 @@ public abstract class AbstractRecipientRewriteTableTest {
     @Test
     public void sortMappingsShouldReturnSameStringWhenTwoDomainAliases() {
         MappingsImpl mappings = MappingsImpl.builder()
-                .add(RecipientRewriteTable.ALIASDOMAIN_PREFIX + "first")
-                .add(RecipientRewriteTable.ALIASDOMAIN_PREFIX + "second")
+                .add(Type.Domain.asPrefix() + "first")
+                .add(Type.Domain.asPrefix() + "second")
                 .build();
         assertThat(AbstractRecipientRewriteTable.sortMappings(mappings)).isEqualTo(mappings);
     }
     
     @Test
     public void sortMappingsShouldPutDomainAliasFirstWhenVariousMappings() {
-        String regexMapping = RecipientRewriteTable.REGEX_PREFIX + "first";
-        String domainMapping = RecipientRewriteTable.ALIASDOMAIN_PREFIX + "second";
+        String regexMapping = Type.Regex.asPrefix() + "first";
+        String domainMapping = Type.Domain.asPrefix() + "second";
         MappingsImpl mappings = MappingsImpl.builder()
                 .add(regexMapping)
                 .add(domainMapping)
@@ -278,8 +275,8 @@ public abstract class AbstractRecipientRewriteTableTest {
 
         expectedException.expect(RecipientRewriteTableException.class);
 
-        addMapping(user, domain, address, ADDRESS_TYPE);
-        addMapping(user, domain, address, ADDRESS_TYPE);
+        addMapping(user, domain, address, Type.Address);
+        addMapping(user, domain, address, Type.Address);
     }
 
     @Test
@@ -288,30 +285,29 @@ public abstract class AbstractRecipientRewriteTableTest {
         Domain domain = Domain.LOCALHOST;
         String address = "test@localhost2";
 
-        addMapping(user, domain, address, ADDRESS_TYPE);
-        addMapping(user, domain, address, REGEX_TYPE);
+        addMapping(user, domain, address, Type.Address);
+        addMapping(user, domain, address, Type.Regex);
 
         assertThat(virtualUserTable.getMappings(user, domain)).hasSize(2);
     }
 
     protected abstract AbstractRecipientRewriteTable getRecipientRewriteTable() throws Exception;
 
-    protected abstract void addMapping(String user, Domain domain, String mapping, int type) throws
+    protected abstract void addMapping(String user, Domain domain, String mapping, Mapping.Type type) throws
             RecipientRewriteTableException;
 
-    protected abstract void removeMapping(String user, Domain domain, String mapping, int type) throws
+    protected abstract void removeMapping(String user, Domain domain, String mapping, Mapping.Type type) throws
             RecipientRewriteTableException;
 
     private void removeMapping(String user, Domain domain, String rawMapping) throws RecipientRewriteTableException {
-        if (rawMapping.startsWith(RecipientRewriteTable.ERROR_PREFIX)) {
-            removeMapping(user, domain, rawMapping.substring(RecipientRewriteTable.ERROR_PREFIX.length()), ERROR_TYPE);
-        } else if (rawMapping.startsWith(RecipientRewriteTable.REGEX_PREFIX)) {
-            removeMapping(user, domain, rawMapping.substring(RecipientRewriteTable.REGEX_PREFIX.length()), REGEX_TYPE);
-        } else if (rawMapping.startsWith(RecipientRewriteTable.ALIASDOMAIN_PREFIX)) {
-            removeMapping(user, domain, rawMapping.substring(RecipientRewriteTable.ALIASDOMAIN_PREFIX.length()),
-                    ALIASDOMAIN_TYPE);
+        if (rawMapping.startsWith(Type.Error.asPrefix())) {
+            removeMapping(user, domain, rawMapping.substring(Type.Error.asPrefix().length()), Type.Error);
+        } else if (rawMapping.startsWith(Type.Regex.asPrefix())) {
+            removeMapping(user, domain, rawMapping.substring(Type.Regex.asPrefix().length()), Type.Regex);
+        } else if (rawMapping.startsWith(Type.Domain.asPrefix())) {
+            removeMapping(user, domain, rawMapping.substring(Type.Domain.asPrefix().length()), Type.Domain);
         } else {
-            removeMapping(user, domain, rawMapping, ADDRESS_TYPE);
+            removeMapping(user, domain, rawMapping, Type.Address);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
index ad055d0..cd353a8 100644
--- a/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
+++ b/server/data/data-library/src/test/java/org/apache/james/rrt/lib/MappingImplTest.java
@@ -26,8 +26,16 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import org.apache.james.core.Domain;
 import org.junit.Test;
 
+import nl.jqno.equalsverifier.EqualsVerifier;
+
 public class MappingImplTest {
 
+    @Test
+    public void beanShouldRespectBeanContract() {
+        EqualsVerifier.forClass(MappingImpl.class)
+            .verify();
+    }
+
     @Test(expected = NullPointerException.class)
     public void addressFactoryMethodShouldThrowOnNull() {
         assertThat(MappingImpl.address(null));
@@ -126,11 +134,6 @@ public class MappingImplTest {
     }
 
     @Test
-    public void toStringShouldReturnValuePrefixedAsByMoreObject() {
-        assertThat(MappingImpl.of("value").toString()).isEqualTo("MappingImpl{mapping=value}");
-    }
-
-    @Test
     public void getAddressShouldReturnMappingValueForAddress() {
         assertThat(MappingImpl.address("value").getAddress()).isEqualTo("value");
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e2cc20f3/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
----------------------------------------------------------------------
diff --git a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
index a06e2ee..9de107b 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/rrt/memory/MemoryRecipientRewriteTableTest.java
@@ -24,6 +24,7 @@ import org.apache.james.core.Domain;
 import org.apache.james.rrt.api.RecipientRewriteTableException;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTable;
 import org.apache.james.rrt.lib.AbstractRecipientRewriteTableTest;
+import org.apache.james.rrt.lib.Mapping.Type;
 import org.junit.After;
 import org.junit.Before;
 
@@ -49,18 +50,18 @@ public class MemoryRecipientRewriteTableTest extends AbstractRecipientRewriteTab
     }
 
     @Override
-    protected void addMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void addMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.addErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.addRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.addAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.addAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:
@@ -69,18 +70,18 @@ public class MemoryRecipientRewriteTableTest extends AbstractRecipientRewriteTab
     }
 
     @Override
-    protected void removeMapping(String user, Domain domain, String mapping, int type) throws RecipientRewriteTableException {
+    protected void removeMapping(String user, Domain domain, String mapping, Type type) throws RecipientRewriteTableException {
         switch (type) {
-        case ERROR_TYPE:
+        case Error:
             virtualUserTable.removeErrorMapping(user, domain, mapping);
             break;
-        case REGEX_TYPE:
+        case Regex:
             virtualUserTable.removeRegexMapping(user, domain, mapping);
             break;
-        case ADDRESS_TYPE:
+        case Address:
             virtualUserTable.removeAddressMapping(user, domain, mapping);
             break;
-        case ALIASDOMAIN_TYPE:
+        case Domain:
             virtualUserTable.removeAliasDomainMapping(domain, Domain.of(mapping));
             break;
         default:


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