Repository: fppt/jedis-mock
Pull request #15 (2019-01-22 08:18:46)

Cleanup Execution of Operations


Patch:
diff --git a/README.md b/README.md
index 231a685..e59ed98 100644
--- a/README.md
+++ b/README.md
@@ -45,14 +45,6 @@ public void after() {
 
 From here test as needed
 
-## Master and Slave
-
-```
-RedisServer master = newRedisServer();
-RedisServer slave = newRedisServer();
-master.setSlave(slave);
-```
-
 ## Fault tolerance testing
 
 We can make a RedisServer close connection after every several commands. This will cause a connection exception for clients.
diff --git a/src/main/java/com/github/fppt/jedismock/RedisBase.java b/src/main/java/com/github/fppt/jedismock/RedisBase.java
index 8b29f36..defaefb 100644
--- a/src/main/java/com/github/fppt/jedismock/RedisBase.java
+++ b/src/main/java/com/github/fppt/jedismock/RedisBase.java
@@ -9,7 +9,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Consumer;
 
 /**
  * Created by Xiaolu on 2015/4/20.
@@ -17,15 +16,9 @@ import java.util.function.Consumer;
 public class RedisBase {
     private final ExpiringKeyValueStorage keyValueStorage = ExpiringKeyValueStorage.create();
     private final Map<Slice, Set<RedisClient>> subscribers = new ConcurrentHashMap<>();
-    private final Set<RedisBase> syncBases = ConcurrentHashMap.newKeySet();
 
     public RedisBase() {}
 
-    public void addSyncBase(RedisBase base) {
-        syncBases.add(base);
-    }
-
-
     public Set<Slice> keys(){
         return keyValueStorage.values().rowMap().keySet();
     }
@@ -46,28 +39,19 @@ public class RedisBase {
         return keyValueStorage.getTTL(key);
     }
 
-    private void syncBases(Consumer<RedisBase> syncFunction){
-        for (RedisBase base : syncBases) {
-            syncFunction.accept(base);
-        }
-    }
-
     public long setTTL(Slice key, long ttl) {
         long result = keyValueStorage.setTTL(key, ttl);
-        syncBases((base) -> base.setTTL(key, ttl));
         return result;
     }
 
     public long setDeadline(Slice key, long deadline) {
         long result = keyValueStorage.setDeadline(key, deadline);
-        syncBases((base) -> base.setDeadline(key, deadline));
         return result;
     }
 
     public void clear(){
         keyValueStorage.clear();
         subscribers.clear();
-        syncBases.clear();
     }
 
     public void putValue(Slice key, Slice value){
@@ -76,22 +60,18 @@ public class RedisBase {
 
     public void putValue(Slice key, Slice value, Long ttl) {
         keyValueStorage.put(key, value, ttl);
-        syncBases((base) -> base.putValue(key, value, ttl));
     }
 
     public void putValue(Slice key1, Slice key2, Slice value, Long ttl) {
         keyValueStorage.put(key1, key2, value, ttl);
-        syncBases((base) -> base.putValue(key1, key2, value, ttl));
     }
 
     public void deleteValue(Slice key) {
         keyValueStorage.delete(key);
-        syncBases((base) -> base.deleteValue(key));
     }
 
     public void deleteValue(Slice key1, Slice key2) {
         keyValueStorage.delete(key1, key2);
-        syncBases((base) -> base.deleteValue(key1, key2));
     }
 
     public void addSubscriber(Slice channel, RedisClient client){
diff --git a/src/main/java/com/github/fppt/jedismock/RedisClient.java b/src/main/java/com/github/fppt/jedismock/RedisClient.java
index 2708c49..b01f925 100644
--- a/src/main/java/com/github/fppt/jedismock/RedisClient.java
+++ b/src/main/java/com/github/fppt/jedismock/RedisClient.java
@@ -9,6 +9,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
+import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -26,12 +27,12 @@ public class RedisClient implements Runnable {
     private final InputStream in;
     private final OutputStream out;
 
-    public RedisClient(RedisBase base, Socket socket, ServiceOptions options) throws IOException {
-        Preconditions.checkNotNull(base);
+    RedisClient(Map<Integer, RedisBase> redisBases, Socket socket, ServiceOptions options) throws IOException {
+        Preconditions.checkNotNull(redisBases);
         Preconditions.checkNotNull(socket);
         Preconditions.checkNotNull(options);
 
-        this.executor = new RedisOperationExecutor(base, this);
+        this.executor = new RedisOperationExecutor(redisBases, this);
         this.socket = socket;
         this.options = options;
         this.in = socket.getInputStream();
diff --git a/src/main/java/com/github/fppt/jedismock/RedisServer.java b/src/main/java/com/github/fppt/jedismock/RedisServer.java
index a0e89bc..b258a8f 100644
--- a/src/main/java/com/github/fppt/jedismock/RedisServer.java
+++ b/src/main/java/com/github/fppt/jedismock/RedisServer.java
@@ -4,6 +4,8 @@ import com.google.common.base.Preconditions;
 
 import java.io.IOException;
 import java.net.ServerSocket;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Created by Xiaolu on 2015/4/18.
@@ -14,7 +16,7 @@ public class RedisServer {
     private ServiceOptions options = ServiceOptions.defaultOptions();
     private ServerSocket server = null;
     private Thread service = null;
-    private final RedisBase base = new RedisBase();
+    private final Map<Integer, RedisBase> redisBases = new HashMap<>();
 
     public RedisServer() throws IOException {
         this(0);
@@ -34,7 +36,6 @@ public class RedisServer {
 
     public void setOptions(ServiceOptions options) {
         Preconditions.checkNotNull(options);
-
         this.options = options;
     }
 
@@ -43,7 +44,7 @@ public class RedisServer {
         Preconditions.checkState(service == null);
 
         server = new ServerSocket(bindPort);
-        service = new Thread(new RedisService(server, base, options));
+        service = new Thread(new RedisService(server, redisBases, options));
         service.start();
     }
 
@@ -80,18 +81,6 @@ public class RedisServer {
 
     public int getBindPort() {
         Preconditions.checkNotNull(server);
-
         return server.getLocalPort();
     }
-
-    public RedisBase getBase() {
-        return base;
-    }
-
-    public void setSlave(RedisServer slave) {
-        Preconditions.checkState(server == null);
-        Preconditions.checkState(service == null);
-
-        base.addSyncBase(slave.getBase());
-    }
 }
diff --git a/src/main/java/com/github/fppt/jedismock/RedisService.java b/src/main/java/com/github/fppt/jedismock/RedisService.java
index 3ad1fd6..7e67af4 100644
--- a/src/main/java/com/github/fppt/jedismock/RedisService.java
+++ b/src/main/java/com/github/fppt/jedismock/RedisService.java
@@ -5,6 +5,7 @@ import com.google.common.base.Preconditions;
 import java.io.IOException;
 import java.net.ServerSocket;
 import java.net.Socket;
+import java.util.Map;
 
 /**
  * Created by Xiaolu on 2015/4/21.
@@ -12,16 +13,16 @@ import java.net.Socket;
 public class RedisService implements Runnable {
 
     private final ServerSocket server;
-    private final RedisBase base;
+    private final Map<Integer, RedisBase> redisBases;
     private final ServiceOptions options;
 
-    public RedisService(ServerSocket server, RedisBase base, ServiceOptions options) {
+    public RedisService(ServerSocket server, Map<Integer, RedisBase> redisBases, ServiceOptions options) {
         Preconditions.checkNotNull(server);
-        Preconditions.checkNotNull(base);
+        Preconditions.checkNotNull(redisBases);
         Preconditions.checkNotNull(options);
 
         this.server = server;
-        this.base = base;
+        this.redisBases = redisBases;
         this.options = options;
     }
 
@@ -29,7 +30,7 @@ public class RedisService implements Runnable {
         while (!server.isClosed()) {
             try {
                 Socket socket = server.accept();
-                Thread t = new Thread(new RedisClient(base, socket, options));
+                Thread t = new Thread(new RedisClient(redisBases, socket, options));
                 t.start();
             } catch (IOException e) {
                 // Do noting
diff --git a/src/main/java/com/github/fppt/jedismock/Utils.java b/src/main/java/com/github/fppt/jedismock/Utils.java
index 944a783..95dc0af 100644
--- a/src/main/java/com/github/fppt/jedismock/Utils.java
+++ b/src/main/java/com/github/fppt/jedismock/Utils.java
@@ -8,7 +8,6 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.List;
 
 /**
  * Created by Xiaolu on 2015/4/21.
@@ -23,24 +22,6 @@ public class Utils {
         }
     }
 
-    public static void checkArgumentsNumberEquals(List<Slice> args, int expect) {
-        if (args.size() != expect) {
-            throw new IllegalArgumentException("The number of arguments [" + args.size() + "] does not match the expected value [" + expect + "]");
-        }
-    }
-
-    public static void checkArgumentsNumberGreater(List<Slice> args, int expect) {
-        if (args.size() <= expect) {
-            throw new IllegalArgumentException("The number of arguments [" + args.size() + "] is less than the expected value [" + expect + "]");
-        }
-    }
-
-    public static void checkArgumentsNumberFactor(List<Slice> args, int factor) {
-        if (args.size() % factor != 0) {
-            throw new IllegalArgumentException("The number of arguments [" + args.size() + "] is not a factor of the expected value [" + factor + "]");
-        }
-    }
-
     public static Slice serializeObject(Object o){
         try {
             ByteArrayOutputStream bo = new ByteArrayOutputStream();
diff --git a/src/main/java/com/github/fppt/jedismock/commands/AbstractRedisOperation.java b/src/main/java/com/github/fppt/jedismock/commands/AbstractRedisOperation.java
index 1776d8d..d6690b3 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/AbstractRedisOperation.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/AbstractRedisOperation.java
@@ -5,18 +5,15 @@ import com.github.fppt.jedismock.Slice;
 
 import java.util.List;
 
-import static com.github.fppt.jedismock.Utils.checkArgumentsNumberEquals;
-import static com.github.fppt.jedismock.Utils.checkArgumentsNumberFactor;
-import static com.github.fppt.jedismock.Utils.checkArgumentsNumberGreater;
+import static com.github.fppt.jedismock.Utils.deserializeObject;
 
 abstract class AbstractRedisOperation implements RedisOperation {
     private final RedisBase base;
     private final List<Slice> params;
 
-    AbstractRedisOperation(RedisBase base, List<Slice> params, Integer expectedParams, Integer minParams, Integer factorParams) {
+    AbstractRedisOperation(RedisBase base, List<Slice> params) {
         this.base = base;
         this.params = params;
-        precheck(expectedParams, minParams, factorParams);
     }
 
     void doOptionalWork(){
@@ -33,21 +30,24 @@ abstract class AbstractRedisOperation implements RedisOperation {
         return params;
     }
 
-    @Override
-    public Slice execute(){
-        doOptionalWork();
-
-        synchronized (base){
-            return response();
+    <V> V getDataFromBase(Slice key, V defaultResponse){
+        Slice data = base().getValue(key);
+        if (data != null) {
+            return deserializeObject(data);
+        } else {
+            return defaultResponse;
         }
     }
 
-    /**
-     * Runs a default precheck to make sure the parameters are as expected
-     */
-    private void precheck(Integer expectedParams, Integer minParams, Integer factorParams){
-        if(expectedParams != null) checkArgumentsNumberEquals(params, expectedParams);
-        if(minParams != null) checkArgumentsNumberGreater(params, minParams);
-        if(factorParams != null) checkArgumentsNumberFactor(params, factorParams);
+    @Override
+    public Slice execute(){
+        try {
+            doOptionalWork();
+            synchronized (base) {
+                return response();
+            }
+        } catch (IndexOutOfBoundsException e){
+            throw new IllegalArgumentException("Invalid number of arguments when executing command [" + getClass().getSimpleName() + "]", e);
+        }
     }
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_add.java b/src/main/java/com/github/fppt/jedismock/commands/RO_add.java
new file mode 100644
index 0000000..95dcf9c
--- /dev/null
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_add.java
@@ -0,0 +1,36 @@
+package com.github.fppt.jedismock.commands;
+
+import com.github.fppt.jedismock.RedisBase;
+import com.github.fppt.jedismock.Response;
+import com.github.fppt.jedismock.Slice;
+
+import java.util.Collection;
+import java.util.List;
+
+import static com.github.fppt.jedismock.Utils.serializeObject;
+
+abstract class RO_add<V extends Collection<Slice>> extends AbstractRedisOperation {
+    RO_add(RedisBase base, List<Slice> params) {
+        super(base, params);
+    }
+
+    abstract void addSliceToCollection(V collection, Slice slice);
+
+    abstract V getDefaultResponse();
+
+    Slice response() {
+        Slice key = params().get(0);
+        V collection = getDataFromBase(key, getDefaultResponse());
+
+        for (int i = 1; i < params().size(); i++) {
+            addSliceToCollection(collection, params().get(i));
+        }
+
+        try {
+            base().putValue(key, serializeObject(collection));
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage());
+        }
+        return Response.integer(collection.size());
+    }
+}
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_append.java b/src/main/java/com/github/fppt/jedismock/commands/RO_append.java
index 6f98d43..3e8f659 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_append.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_append.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_append extends AbstractRedisOperation {
     RO_append(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_brpoplpush.java b/src/main/java/com/github/fppt/jedismock/commands/RO_brpoplpush.java
index cafe338..8d95821 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_brpoplpush.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_brpoplpush.java
@@ -14,8 +14,7 @@ class RO_brpoplpush extends RO_rpoplpush {
     private long count = 0L;
 
     RO_brpoplpush(RedisBase base, List<Slice> params) {
-        //NOTE: The minimum number of arguments is 1 because this mock is used for brpoplpush as well which takes in 3 arguments
-        super(base, params, 3);
+        super(base, params);
     }
 
     void doOptionalWork(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_decr.java b/src/main/java/com/github/fppt/jedismock/commands/RO_decr.java
index 6255b08..a3bc387 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_decr.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_decr.java
@@ -7,7 +7,7 @@ import java.util.List;
 
 class RO_decr extends RO_decrby {
     RO_decr(RedisBase base, List<Slice> params) {
-        super(base, params, 1);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_decrby.java b/src/main/java/com/github/fppt/jedismock/commands/RO_decrby.java
index d36338a..0386e2d 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_decrby.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_decrby.java
@@ -9,11 +9,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_decrby extends RO_incrOrDecrBy {
     RO_decrby(RedisBase base, List<Slice> params) {
-        super(base, params, 2);
-    }
-
-    RO_decrby(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams);
+        super(base, params);
     }
 
     long incrementOrDecrementValue(List<Slice> params){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_del.java b/src/main/java/com/github/fppt/jedismock/commands/RO_del.java
index e681bba..c4d429a 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_del.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_del.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_del extends AbstractRedisOperation {
     RO_del(RedisBase base, List<Slice> params) {
-        super(base, params,null, 0, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_exec.java b/src/main/java/com/github/fppt/jedismock/commands/RO_exec.java
index fa13392..f574942 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_exec.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_exec.java
@@ -13,7 +13,7 @@ class RO_exec extends AbstractRedisOperation {
     private final List<RedisOperation> transaction;
 
     RO_exec(RedisBase base, List<RedisOperation> transaction, List<Slice> params) {
-        super(base, params,0, null, null);
+        super(base, params);
         this.transaction = transaction;
     }
 
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_exists.java b/src/main/java/com/github/fppt/jedismock/commands/RO_exists.java
index 6b5d803..037da82 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_exists.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_exists.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_exists extends AbstractRedisOperation {
     RO_exists(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_expireat.java b/src/main/java/com/github/fppt/jedismock/commands/RO_expireat.java
index 7ca5903..925bdd7 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_expireat.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_expireat.java
@@ -10,7 +10,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_expireat extends AbstractRedisOperation {
     RO_expireat(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_flushall.java b/src/main/java/com/github/fppt/jedismock/commands/RO_flushall.java
index 6e04508..14ba525 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_flushall.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_flushall.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_flushall extends AbstractRedisOperation {
     RO_flushall(RedisBase base, List<Slice> params) {
-        super(base, params, 0, null, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_get.java b/src/main/java/com/github/fppt/jedismock/commands/RO_get.java
index 0ed28c4..a6e025d 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_get.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_get.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_get extends AbstractRedisOperation {
     RO_get(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_getbit.java b/src/main/java/com/github/fppt/jedismock/commands/RO_getbit.java
index 38629f5..cd3e99f 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_getbit.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_getbit.java
@@ -10,7 +10,7 @@ import static com.github.fppt.jedismock.Utils.convertToNonNegativeInteger;
 
 class RO_getbit extends AbstractRedisOperation {
     RO_getbit(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_getset.java b/src/main/java/com/github/fppt/jedismock/commands/RO_getset.java
index 46794ba..80db148 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_getset.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_getset.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_getset extends AbstractRedisOperation {
     RO_getset(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hdel.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hdel.java
index a25b903..c2cad89 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hdel.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hdel.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_hdel extends AbstractRedisOperation {
     RO_hdel(RedisBase base, List<Slice> params) {
-        super(base, params,2, null, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hegetall.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hegetall.java
index b5ed1b7..ab6f2b4 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hegetall.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hegetall.java
@@ -10,7 +10,7 @@ import java.util.Map;
 
 public class RO_hegetall extends AbstractRedisOperation {
     public RO_hegetall(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hget.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hget.java
index 53d6293..31bf3c3 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hget.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hget.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_hget extends AbstractRedisOperation {
     RO_hget(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hmget.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hmget.java
index f8c8fdf..5e0b78b 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hmget.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hmget.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 public class RO_hmget extends AbstractRedisOperation {
     public RO_hmget(RedisBase base, List<Slice> params) {
-        super(base, params, null, 2, null);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hmset.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hmset.java
index f517c26..ccef122 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hmset.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hmset.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 public class RO_hmset extends AbstractRedisOperation {
     public RO_hmset(RedisBase base, List<Slice> params) {
-        super(base, params, null, 1, null);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_hset.java b/src/main/java/com/github/fppt/jedismock/commands/RO_hset.java
index a4e0b67..e4d80f8 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_hset.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_hset.java
@@ -8,11 +8,7 @@ import java.util.List;
 
 class RO_hset extends AbstractRedisOperation {
     RO_hset(RedisBase base, List<Slice> params) {
-        super(base, params, 3, null, null);
-    }
-
-    public RO_hset(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams, null,null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_incr.java b/src/main/java/com/github/fppt/jedismock/commands/RO_incr.java
index 38169fc..1fc4c8f 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_incr.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_incr.java
@@ -7,7 +7,7 @@ import java.util.List;
 
 class RO_incr extends RO_incrby {
     RO_incr(RedisBase base, List<Slice> params) {
-        super(base, params, 1);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_incrOrDecrBy.java b/src/main/java/com/github/fppt/jedismock/commands/RO_incrOrDecrBy.java
index 64f4bb2..69b5884 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_incrOrDecrBy.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_incrOrDecrBy.java
@@ -9,8 +9,8 @@ import java.util.List;
 import static com.github.fppt.jedismock.Utils.convertToLong;
 
 abstract class RO_incrOrDecrBy extends AbstractRedisOperation {
-    RO_incrOrDecrBy(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams, null, null);
+    RO_incrOrDecrBy(RedisBase base, List<Slice> params) {
+        super(base, params);
     }
 
     abstract long incrementOrDecrementValue(List<Slice> params);
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_incrby.java b/src/main/java/com/github/fppt/jedismock/commands/RO_incrby.java
index 16c7e95..fc2cab3 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_incrby.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_incrby.java
@@ -9,11 +9,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_incrby extends RO_incrOrDecrBy {
     RO_incrby(RedisBase base, List<Slice> params) {
-        super(base, params, 2);
-    }
-
-    RO_incrby(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams);
+        super(base, params);
     }
 
     long incrementOrDecrementValue(List<Slice> params){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_keys.java b/src/main/java/com/github/fppt/jedismock/commands/RO_keys.java
index 01d529e..712e654 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_keys.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_keys.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 class RO_keys extends AbstractRedisOperation {
     RO_keys(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_lindex.java b/src/main/java/com/github/fppt/jedismock/commands/RO_lindex.java
index 5808246..2af5435 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_lindex.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_lindex.java
@@ -3,27 +3,23 @@ package com.github.fppt.jedismock.commands;
 import com.github.fppt.jedismock.RedisBase;
 import com.github.fppt.jedismock.Response;
 import com.github.fppt.jedismock.Slice;
+import com.google.common.collect.Lists;
 
 import java.util.LinkedList;
 import java.util.List;
 
 import static com.github.fppt.jedismock.Utils.convertToInteger;
-import static com.github.fppt.jedismock.Utils.deserializeObject;
 
 class RO_lindex extends AbstractRedisOperation {
     RO_lindex(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
         Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        LinkedList<Slice> list;
-        if (data != null) {
-            list = deserializeObject(data);
-        } else {
-            return Response.NULL;
-        }
+        LinkedList<Slice> list = getDataFromBase(key, Lists.newLinkedList());
+        if(list.isEmpty()) return Response.NULL;
+
         int index = convertToInteger(params().get(1).toString());
         if (index < 0) {
             index = list.size() + index;
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_llen.java b/src/main/java/com/github/fppt/jedismock/commands/RO_llen.java
index 86a73cc..5979a29 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_llen.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_llen.java
@@ -8,22 +8,14 @@ import com.google.common.collect.Lists;
 import java.util.LinkedList;
 import java.util.List;
 
-import static com.github.fppt.jedismock.Utils.deserializeObject;
-
 class RO_llen extends AbstractRedisOperation {
     RO_llen(RedisBase base, List<Slice> params) {
-        super(base, params,  1, null, null);
+        super(base, params);
     }
 
     Slice response() {
         Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        LinkedList<Slice> list;
-        if (data != null) {
-            list = deserializeObject(data);
-        } else {
-            list = Lists.newLinkedList();
-        }
+        LinkedList<Slice> list = getDataFromBase(key, Lists.newLinkedList());
         return Response.integer(list.size());
     }
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_lpop.java b/src/main/java/com/github/fppt/jedismock/commands/RO_lpop.java
index 313825e..08cd62f 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_lpop.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_lpop.java
@@ -6,7 +6,7 @@ import com.github.fppt.jedismock.Slice;
 import java.util.LinkedList;
 import java.util.List;
 
-class RO_lpop extends RO_pop {
+class RO_lpop extends RO_pop<LinkedList<Slice>> {
     RO_lpop(RedisBase base,List<Slice> params ) {
         super(base, params);
     }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_lpush.java b/src/main/java/com/github/fppt/jedismock/commands/RO_lpush.java
index b21b03b..23134ec 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_lpush.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_lpush.java
@@ -2,18 +2,24 @@ package com.github.fppt.jedismock.commands;
 
 import com.github.fppt.jedismock.RedisBase;
 import com.github.fppt.jedismock.Slice;
+import com.google.common.collect.Lists;
 
 import java.util.LinkedList;
 import java.util.List;
 
-class RO_lpush extends RO_push {
+class RO_lpush extends RO_add<LinkedList<Slice>> {
     RO_lpush(RedisBase base, List<Slice> params) {
         super(base, params);
     }
 
     @Override
-    void pusher(LinkedList<Slice> list, Slice slice) {
+    void addSliceToCollection(LinkedList<Slice> list, Slice slice) {
         list.addFirst(slice);
     }
 
+    @Override
+    LinkedList<Slice> getDefaultResponse() {
+        return Lists.newLinkedList();
+    }
+
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_lrange.java b/src/main/java/com/github/fppt/jedismock/commands/RO_lrange.java
index e0ad3ed..c5aacf4 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_lrange.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_lrange.java
@@ -10,22 +10,15 @@ import java.util.LinkedList;
 import java.util.List;
 
 import static com.github.fppt.jedismock.Utils.convertToInteger;
-import static com.github.fppt.jedismock.Utils.deserializeObject;
 
 class RO_lrange extends AbstractRedisOperation {
     RO_lrange(RedisBase base, List<Slice> params) {
-        super(base, params, 3, null, null);
+        super(base, params);
     }
 
     Slice response() {
         Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        LinkedList<Slice> list;
-        if (data != null) {
-            list = deserializeObject(data);
-        } else {
-            list = Lists.newLinkedList();
-        }
+        LinkedList<Slice> list = getDataFromBase(key, Lists.newLinkedList());
 
         int start = convertToInteger(params().get(1).toString());
         int end = convertToInteger(params().get(2).toString());
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_lrem.java b/src/main/java/com/github/fppt/jedismock/commands/RO_lrem.java
index a762449..7b26795 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_lrem.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_lrem.java
@@ -14,7 +14,7 @@ import static com.github.fppt.jedismock.Utils.serializeObject;
 
 class RO_lrem extends AbstractRedisOperation {
     RO_lrem(RedisBase base, List<Slice> params) {
-        super(base, params,3, null, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_mget.java b/src/main/java/com/github/fppt/jedismock/commands/RO_mget.java
index 3f7be6a..c208c87 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_mget.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_mget.java
@@ -9,7 +9,7 @@ import java.util.List;
 
 class RO_mget extends AbstractRedisOperation {
     RO_mget(RedisBase base, List<Slice> params) {
-        super(base, params, null, 0, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_mset.java b/src/main/java/com/github/fppt/jedismock/commands/RO_mset.java
index 3b40383..562a8d8 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_mset.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_mset.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_mset extends AbstractRedisOperation {
     RO_mset(RedisBase base, List<Slice> params ) {
-        super(base, params, null, 0, 2);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pexpire.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pexpire.java
index 3d1e840..78b506e 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pexpire.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pexpire.java
@@ -10,7 +10,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_pexpire extends AbstractRedisOperation {
     RO_pexpire(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     long getValue(List<Slice> params){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pexpireat.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pexpireat.java
index 2702b90..a30a5f9 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pexpireat.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pexpireat.java
@@ -10,7 +10,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_pexpireat extends AbstractRedisOperation {
     RO_pexpireat(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pfadd.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pfadd.java
index 1faa1c8..9c1e085 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pfadd.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pfadd.java
@@ -13,7 +13,7 @@ import static com.github.fppt.jedismock.Utils.serializeObject;
 
 class RO_pfadd extends AbstractRedisOperation {
     RO_pfadd(RedisBase base, List<Slice> params) {
-        super(base, params,null, 1, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pfcount.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pfcount.java
index f6f6e5b..8537ee3 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pfcount.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pfcount.java
@@ -12,7 +12,7 @@ import static com.github.fppt.jedismock.Utils.deserializeObject;
 
 class RO_pfcount extends AbstractRedisOperation {
     RO_pfcount(RedisBase base, List<Slice> params) {
-        super(base, params, null, 0, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pfmerge.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pfmerge.java
index a8d9926..d440a5d 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pfmerge.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pfmerge.java
@@ -13,7 +13,7 @@ import static com.github.fppt.jedismock.Utils.serializeObject;
 
 class RO_pfmerge extends AbstractRedisOperation {
     RO_pfmerge(RedisBase base, List<Slice> params) {
-        super(base, params,null, 0, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_ping.java b/src/main/java/com/github/fppt/jedismock/commands/RO_ping.java
index 001f21c..a8b1c68 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_ping.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_ping.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_ping extends AbstractRedisOperation {
     RO_ping(RedisBase base, List<Slice> params) {
-        super(base, params,  0, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_pop.java b/src/main/java/com/github/fppt/jedismock/commands/RO_pop.java
index 662f830..8d25024 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_pop.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_pop.java
@@ -4,32 +4,22 @@ import com.github.fppt.jedismock.RedisBase;
 import com.github.fppt.jedismock.Response;
 import com.github.fppt.jedismock.Slice;
 
-import java.util.LinkedList;
+import java.util.Collection;
 import java.util.List;
 
-import static com.github.fppt.jedismock.Utils.deserializeObject;
 import static com.github.fppt.jedismock.Utils.serializeObject;
 
-abstract class RO_pop extends AbstractRedisOperation {
+abstract class RO_pop<V extends Collection<Slice>> extends AbstractRedisOperation {
     RO_pop(RedisBase base, List<Slice> params ) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
-    abstract Slice popper(LinkedList<Slice> list);
+    abstract Slice popper(V list);
 
     Slice response() {
         Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        LinkedList<Slice> list;
-        if (data != null) {
-            list = deserializeObject(data);
-        } else {
-            return Response.NULL;
-        }
-
-        if (list.isEmpty()) {
-            return Response.NULL;
-        }
+        V list = getDataFromBase(key, null);
+        if(list == null || list.isEmpty()) return Response.NULL;
         Slice v = popper(list);
         base().putValue(key, serializeObject(list));
         return Response.bulkString(v);
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_psetex.java b/src/main/java/com/github/fppt/jedismock/commands/RO_psetex.java
index 5a6fe2c..94ebb34 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_psetex.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_psetex.java
@@ -9,7 +9,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_psetex extends RO_setex {
     RO_psetex(RedisBase base, List<Slice> params) {
-        super(base, params, 3);
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_publish.java b/src/main/java/com/github/fppt/jedismock/commands/RO_publish.java
index be4b2f0..519c6e7 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_publish.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_publish.java
@@ -11,7 +11,7 @@ import java.util.Set;
 class RO_publish extends AbstractRedisOperation {
 
     RO_publish(RedisBase base, List<Slice> params) {
-        super(base, params,2, null, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_push.java b/src/main/java/com/github/fppt/jedismock/commands/RO_push.java
deleted file mode 100644
index 7d9b295..0000000
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_push.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.github.fppt.jedismock.commands;
-
-import com.github.fppt.jedismock.RedisBase;
-import com.github.fppt.jedismock.Response;
-import com.github.fppt.jedismock.Slice;
-import com.google.common.collect.Lists;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.github.fppt.jedismock.Utils.deserializeObject;
-import static com.github.fppt.jedismock.Utils.serializeObject;
-
-abstract class RO_push extends AbstractRedisOperation {
-    RO_push(RedisBase base, List<Slice> params) {
-        super(base, params,null, 1, null);
-    }
-
-    abstract void pusher(LinkedList<Slice> list, Slice slice);
-
-    Slice response() {
-        Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        LinkedList<Slice> list;
-
-        if (data != null) {
-            list = deserializeObject(data);
-        } else {
-            list = Lists.newLinkedList();
-        }
-
-        for (int i = 1; i < params().size(); i++) {
-            pusher(list, params().get(i));
-        }
-        try {
-            base().putValue(key, serializeObject(list));
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage());
-        }
-        return Response.integer(list.size());
-    }
-}
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_quit.java b/src/main/java/com/github/fppt/jedismock/commands/RO_quit.java
index 932686f..e7d6d90 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_quit.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_quit.java
@@ -11,7 +11,7 @@ class RO_quit extends AbstractRedisOperation {
     private final RedisClient client;
 
     RO_quit(RedisBase base, RedisClient client, List<Slice> params) {
-        super(base, params,0, null, null);
+        super(base, params);
         this.client = client;
     }
 
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_rpop.java b/src/main/java/com/github/fppt/jedismock/commands/RO_rpop.java
index c5af8f1..ca8d00c 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_rpop.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_rpop.java
@@ -6,7 +6,7 @@ import com.github.fppt.jedismock.Slice;
 import java.util.LinkedList;
 import java.util.List;
 
-class RO_rpop extends RO_pop {
+class RO_rpop extends RO_pop<LinkedList<Slice>> {
     RO_rpop(RedisBase base, List<Slice> params ) {
         super(base, params);
     }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_rpoplpush.java b/src/main/java/com/github/fppt/jedismock/commands/RO_rpoplpush.java
index 77a1294..ce113ed 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_rpoplpush.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_rpoplpush.java
@@ -10,11 +10,7 @@ import java.util.List;
 
 class RO_rpoplpush extends AbstractRedisOperation {
     RO_rpoplpush(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
-    }
-
-    RO_rpoplpush(RedisBase base, List<Slice> params, Integer numExpected) {
-        super(base, params, numExpected, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_rpush.java b/src/main/java/com/github/fppt/jedismock/commands/RO_rpush.java
index c7bd5be..8483c3e 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_rpush.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_rpush.java
@@ -2,18 +2,24 @@ package com.github.fppt.jedismock.commands;
 
 import com.github.fppt.jedismock.RedisBase;
 import com.github.fppt.jedismock.Slice;
+import com.google.common.collect.Lists;
 
 import java.util.LinkedList;
 import java.util.List;
 
-class RO_rpush extends RO_push {
+class RO_rpush extends RO_add<LinkedList<Slice>> {
     RO_rpush(RedisBase base, List<Slice> params) {
         super(base, params);
     }
 
     @Override
-    void pusher(LinkedList<Slice> list, Slice slice) {
+    void addSliceToCollection(LinkedList<Slice> list, Slice slice) {
         list.addLast(slice);
     }
 
+    @Override
+    LinkedList<Slice> getDefaultResponse() {
+        return Lists.newLinkedList();
+    }
+
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_sadd.java b/src/main/java/com/github/fppt/jedismock/commands/RO_sadd.java
index 7e8f60c..9b3b370 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_sadd.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_sadd.java
@@ -1,40 +1,26 @@
 package com.github.fppt.jedismock.commands;
 
 import com.github.fppt.jedismock.RedisBase;
-import com.github.fppt.jedismock.Response;
 import com.github.fppt.jedismock.Slice;
 
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import static com.github.fppt.jedismock.Utils.deserializeObject;
-import static com.github.fppt.jedismock.Utils.serializeObject;
-
-class RO_sadd extends AbstractRedisOperation {
+class RO_sadd extends RO_add<Set<Slice>> {
     RO_sadd(RedisBase base, List<Slice> params) {
-        super(base, params,null, 1, null);
+        super(base, params);
     }
 
-    Slice response() {
-        Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        Set<Slice> set;
-
-        if (data != null) {
-            set = deserializeObject(data);
-        } else {
-            set = new HashSet<>();
-        }
-
+    @Override
+    void addSliceToCollection(Set<Slice> set, Slice slice) {
         for (int i = 1; i < params().size(); i++) {
             set.add(params().get(i));
         }
-        try {
-            base().putValue(key, serializeObject(set));
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage());
-        }
-        return Response.integer(set.size());
+    }
+
+    @Override
+    Set<Slice> getDefaultResponse() {
+        return new HashSet<>();
     }
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_set.java b/src/main/java/com/github/fppt/jedismock/commands/RO_set.java
index 5ae8aff..0851248 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_set.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_set.java
@@ -8,11 +8,7 @@ import java.util.List;
 
 class RO_set extends AbstractRedisOperation {
     RO_set(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
-    }
-
-    public RO_set(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams, null,null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_setbit.java b/src/main/java/com/github/fppt/jedismock/commands/RO_setbit.java
index 32c9c57..bd8ac0f 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_setbit.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_setbit.java
@@ -12,7 +12,7 @@ import static com.github.fppt.jedismock.Utils.convertToNonNegativeInteger;
 
 class RO_setbit extends AbstractRedisOperation {
     RO_setbit(RedisBase base, List<Slice> params) {
-        super(base, params, 3, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_setex.java b/src/main/java/com/github/fppt/jedismock/commands/RO_setex.java
index 7f6b28e..dd12c1da5 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_setex.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_setex.java
@@ -10,11 +10,7 @@ import static com.github.fppt.jedismock.Utils.convertToLong;
 
 class RO_setex extends RO_set {
     RO_setex(RedisBase base, List<Slice> params) {
-        super(base, params, 3);
-    }
-
-    RO_setex(RedisBase base, List<Slice> params, Integer expectedParams) {
-        super(base, params, expectedParams);
+        super(base, params);
     }
 
     long valueToSet(List<Slice> params){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_setnx.java b/src/main/java/com/github/fppt/jedismock/commands/RO_setnx.java
index 330175e..7488a10 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_setnx.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_setnx.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_setnx extends AbstractRedisOperation {
     RO_setnx(RedisBase base, List<Slice> params) {
-        super(base, params, 2, null, null);
+        super(base, params);
     }
 
     Slice response(){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_sinter.java b/src/main/java/com/github/fppt/jedismock/commands/RO_sinter.java
index 177f957..92e4644 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_sinter.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_sinter.java
@@ -12,9 +12,9 @@ import java.util.Set;
 
 import static com.github.fppt.jedismock.Utils.deserializeObject;
 
-public class RO_sinter extends AbstractRedisOperation {
-    public RO_sinter(RedisBase base, List<Slice> params) {
-        super(base, params,  null, null, null);
+class RO_sinter extends AbstractRedisOperation {
+    RO_sinter(RedisBase base, List<Slice> params) {
+        super(base, params);
     }
 
     @Override
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_smembers.java b/src/main/java/com/github/fppt/jedismock/commands/RO_smembers.java
index eb935fb..54c2bce 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_smembers.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_smembers.java
@@ -13,7 +13,7 @@ import static com.github.fppt.jedismock.Utils.deserializeObject;
 
 class RO_smembers extends AbstractRedisOperation {
     RO_smembers(RedisBase base, List<Slice> params) {
-        super(base, params,  1, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_spop.java b/src/main/java/com/github/fppt/jedismock/commands/RO_spop.java
index 485b6af..6e5065a 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_spop.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_spop.java
@@ -1,38 +1,22 @@
 package com.github.fppt.jedismock.commands;
 
 import com.github.fppt.jedismock.RedisBase;
-import com.github.fppt.jedismock.Response;
 import com.github.fppt.jedismock.Slice;
 
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
-import static com.github.fppt.jedismock.Utils.deserializeObject;
-import static com.github.fppt.jedismock.Utils.serializeObject;
-
-class RO_spop extends AbstractRedisOperation {
+class RO_spop extends RO_pop<Set<Slice>> {
     RO_spop(RedisBase base, List<Slice> params ) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
-    Slice response() {
-        Slice key = params().get(0);
-        Slice data = base().getValue(key);
-        Set<Slice> set;
-        if (data != null) {
-            set = deserializeObject(data);
-        } else {
-            return Response.NULL;
-        }
-
-        if (set.isEmpty()) {
-            return Response.NULL;
-        }
-        Iterator<Slice> it = set.iterator();
+    @Override
+    Slice popper(Set<Slice> collection) {
+        Iterator<Slice> it = collection.iterator();
         Slice v = it.next();
         it.remove();
-        base().putValue(key, serializeObject(set));
-        return Response.bulkString(v);
+        return v;
     }
 }
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_strlen.java b/src/main/java/com/github/fppt/jedismock/commands/RO_strlen.java
index e2910da..0260c0c 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_strlen.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_strlen.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_strlen extends AbstractRedisOperation {
     RO_strlen(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     Slice response() {
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_subscribe.java b/src/main/java/com/github/fppt/jedismock/commands/RO_subscribe.java
index 28669fd..1053363 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_subscribe.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_subscribe.java
@@ -11,7 +11,7 @@ class RO_subscribe extends AbstractRedisOperation {
     private final RedisClient client;
 
     RO_subscribe(RedisBase base, RedisClient client, List<Slice> params) {
-        super(base, params,null, 0, null);
+        super(base, params);
         this.client = client;
     }
 
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_ttl.java b/src/main/java/com/github/fppt/jedismock/commands/RO_ttl.java
index 8800a16..34fe745 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_ttl.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_ttl.java
@@ -8,7 +8,7 @@ import java.util.List;
 
 class RO_ttl extends AbstractRedisOperation {
     RO_ttl(RedisBase base, List<Slice> params) {
-        super(base, params, 1, null, null);
+        super(base, params);
     }
 
     Slice finalReturn(Long pttl){
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RO_unsubscribe.java b/src/main/java/com/github/fppt/jedismock/commands/RO_unsubscribe.java
index 7952e56..8673de5 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RO_unsubscribe.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RO_unsubscribe.java
@@ -13,7 +13,7 @@ class RO_unsubscribe extends AbstractRedisOperation {
     private final RedisClient client;
 
     RO_unsubscribe(RedisBase base, RedisClient client, List<Slice> params) {
-        super(base, params,null, null, null);
+        super(base, params);
         this.client = client;
     }
 
diff --git a/src/main/java/com/github/fppt/jedismock/commands/RedisOperationExecutor.java b/src/main/java/com/github/fppt/jedismock/commands/RedisOperationExecutor.java
index 5f5b5c1..b1298e5 100644
--- a/src/main/java/com/github/fppt/jedismock/commands/RedisOperationExecutor.java
+++ b/src/main/java/com/github/fppt/jedismock/commands/RedisOperationExecutor.java
@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by Xiaolu on 2015/4/20.
@@ -18,132 +19,137 @@ import java.util.List;
 public class RedisOperationExecutor {
     private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(RedisOperationExecutor.class);
     private final RedisClient owner;
-    private final RedisBase base;
+    private final Map<Integer, RedisBase> redisBases;
     private boolean transactionModeOn;
     private List<RedisOperation> transaction;
+    private int selectedRedisBase = 0;
 
-    public RedisOperationExecutor(RedisBase base, RedisClient owner) {
-        this.base = base;
+    public RedisOperationExecutor(Map<Integer, RedisBase> redisBases, RedisClient owner) {
+        this.redisBases = redisBases;
         this.owner = owner;
         transactionModeOn = false;
         transaction = new ArrayList<>();
     }
 
+    private RedisBase getCurrentBase(){
+        return redisBases.computeIfAbsent(selectedRedisBase, key -> new RedisBase());
+    }
+
     private RedisOperation buildSimpleOperation(String name, List<Slice> params){
         switch(name){
             case "set":
-                return new RO_set(base, params);
+                return new RO_set(getCurrentBase(), params);
             case "setex":
-                return new RO_setex(base, params);
+                return new RO_setex(getCurrentBase(), params);
             case "psetex":
-                return new RO_psetex(base, params);
+                return new RO_psetex(getCurrentBase(), params);
             case "setnx":
-                return new RO_setnx(base, params);
+                return new RO_setnx(getCurrentBase(), params);
             case "setbit":
-                return new RO_setbit(base, params);
+                return new RO_setbit(getCurrentBase(), params);
             case "append":
-                return new RO_append(base, params);
+                return new RO_append(getCurrentBase(), params);
             case "get":
-                return new RO_get(base, params);
+                return new RO_get(getCurrentBase(), params);
             case "getbit":
-                return new RO_getbit(base, params);
+                return new RO_getbit(getCurrentBase(), params);
             case "ttl":
-                return new RO_ttl(base, params);
+                return new RO_ttl(getCurrentBase(), params);
             case "pttl":
-                return new RO_pttl(base, params);
+                return new RO_pttl(getCurrentBase(), params);
             case "expire":
-                return new RO_expire(base, params);
+                return new RO_expire(getCurrentBase(), params);
             case "pexpire":
-                return new RO_pexpire(base, params);
+                return new RO_pexpire(getCurrentBase(), params);
             case "incr":
-                return new RO_incr(base, params);
+                return new RO_incr(getCurrentBase(), params);
             case "incrby":
-                return new RO_incrby(base, params);
+                return new RO_incrby(getCurrentBase(), params);
             case "decr":
-                return new RO_decr(base, params);
+                return new RO_decr(getCurrentBase(), params);
             case "decrby":
-                return new RO_decrby(base, params);
+                return new RO_decrby(getCurrentBase(), params);
             case "pfcount":
-                return new RO_pfcount(base, params);
+                return new RO_pfcount(getCurrentBase(), params);
             case "pfadd":
-                return new RO_pfadd(base, params);
+                return new RO_pfadd(getCurrentBase(), params);
             case "pfmerge":
-                return new RO_pfmerge(base, params);
+                return new RO_pfmerge(getCurrentBase(), params);
             case "mget":
-                return new RO_mget(base, params);
+                return new RO_mget(getCurrentBase(), params);
             case "mset":
-                return new RO_mset(base, params);
+                return new RO_mset(getCurrentBase(), params);
             case "getset":
-                return new RO_getset(base, params);
+                return new RO_getset(getCurrentBase(), params);
             case "strlen":
-                return new RO_strlen(base, params);
+                return new RO_strlen(getCurrentBase(), params);
             case "del":
-                return new RO_del(base, params);
+                return new RO_del(getCurrentBase(), params);
             case "exists":
-                return new RO_exists(base, params);
+                return new RO_exists(getCurrentBase(), params);
             case "expireat":
-                return new RO_expireat(base, params);
+                return new RO_expireat(getCurrentBase(), params);
             case "pexpireat":
-                return new RO_pexpireat(base, params);
+                return new RO_pexpireat(getCurrentBase(), params);
             case "lpush":
-                return new RO_lpush(base, params);
+                return new RO_lpush(getCurrentBase(), params);
             case "rpush":
-                return new RO_rpush(base, params);
+                return new RO_rpush(getCurrentBase(), params);
             case "lpushx":
-                return new RO_lpushx(base, params);
+                return new RO_lpushx(getCurrentBase(), params);
             case "lrange":
-                return new RO_lrange(base, params);
+                return new RO_lrange(getCurrentBase(), params);
             case "llen":
-                return new RO_llen(base, params);
+                return new RO_llen(getCurrentBase(), params);
             case "lpop":
-                return new RO_lpop(base, params);
+                return new RO_lpop(getCurrentBase(), params);
             case "rpop":
-                return new RO_rpop(base, params);
+                return new RO_rpop(getCurrentBase(), params);
             case "lindex":
-                return new RO_lindex(base, params);
+                return new RO_lindex(getCurrentBase(), params);
             case "rpoplpush":
-                return new RO_rpoplpush(base, params);
+                return new RO_rpoplpush(getCurrentBase(), params);
             case "brpoplpush":
-                return new RO_brpoplpush(base, params);
+                return new RO_brpoplpush(getCurrentBase(), params);
             case "subscribe":
-                return new RO_subscribe(base, owner, params);
+                return new RO_subscribe(getCurrentBase(), owner, params);
             case "unsubscribe":
-                return new RO_unsubscribe(base, owner, params);
+                return new RO_unsubscribe(getCurrentBase(), owner, params);
             case "publish":
-                return new RO_publish(base, params);
+                return new RO_publish(getCurrentBase(), params);
             case "flushall":
-                return new RO_flushall(base, params);
+                return new RO_flushall(getCurrentBase(), params);
             case "lrem":
-                return new RO_lrem(base, params);
+                return new RO_lrem(getCurrentBase(), params);
             case "quit":
-                return new RO_quit(base, owner, params);
+                return new RO_quit(getCurrentBase(), owner, params);
             case "exec":
                 transactionModeOn = false;
-                return new RO_exec(base, transaction, params);
+                return new RO_exec(getCurrentBase(), transaction, params);
             case "ping":
-                return new RO_ping(base, params);
+                return new RO_ping(getCurrentBase(), params);
             case "keys":
-                return new RO_keys(base, params);
+                return new RO_keys(getCurrentBase(), params);
             case "sadd":
-                return new RO_sadd(base, params);
+                return new RO_sadd(getCurrentBase(), params);
             case "smembers":
-                return new RO_smembers(base, params);
+                return new RO_smembers(getCurrentBase(), params);
             case "spop":
-                return new RO_spop(base, params);
+                return new RO_spop(getCurrentBase(), params);
             case "hget":
-                return new RO_hget(base, params);
+                return new RO_hget(getCurrentBase(), params);
             case "hset":
-                return new RO_hset(base, params);
+                return new RO_hset(getCurrentBase(), params);
             case "hdel":
-                return new RO_hdel(base, params);
+                return new RO_hdel(getCurrentBase(), params);
             case "hgetall":
-                return new RO_hegetall(base, params);
+                return new RO_hegetall(getCurrentBase(), params);
             case "sinter":
-                return new RO_sinter(base, params);
+                return new RO_sinter(getCurrentBase(), params);
             case "hmget":
-                return new RO_hmget(base, params);
+                return new RO_hmget(getCurrentBase(), params);
             case "hmset":
-                return new RO_hmset(base, params);
+                return new RO_hmset(getCurrentBase(), params);
             default:
                 throw new UnsupportedOperationException(String.format("Unsupported operation '%s'", name));
         }
@@ -162,7 +168,7 @@ public class RedisOperationExecutor {
                 return Response.clientResponse(name, Response.OK);
             }
 
-            //Checking if we mutating the transaction or the base
+            //Checking if we mutating the transaction or the redisBases
             RedisOperation redisOperation = buildSimpleOperation(name, commandParams);
             if(transactionModeOn){
                 transaction.add(redisOperation);


Test patch:
diff --git a/src/test/java/com/github/fppt/jedismock/TestRedisOperationExecutor.java b/src/test/java/com/github/fppt/jedismock/TestRedisOperationExecutor.java
index c565882..2ac2ad8 100644
--- a/src/test/java/com/github/fppt/jedismock/TestRedisOperationExecutor.java
+++ b/src/test/java/com/github/fppt/jedismock/TestRedisOperationExecutor.java
@@ -6,6 +6,9 @@ import com.github.fppt.jedismock.exception.ParseErrorException;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -57,7 +60,9 @@ public class TestRedisOperationExecutor {
     @Before
     public void initCommandExecutor() {
         //TODO: Mock out the client here
-        executor = new RedisOperationExecutor(new RedisBase(), null);
+        Map<Integer, RedisBase> redisBases = new HashMap<>();
+        redisBases.put(0, new RedisBase());
+        executor = new RedisOperationExecutor(redisBases, null);
     }
 
     @Test
@@ -70,12 +75,6 @@ public class TestRedisOperationExecutor {
         assertCommandNull(array("GET", "ac"));
     }
 
-    @Test
-    public void testWrongNumberOfArguments() throws ParseErrorException, EOFException {
-        assertCommandError(array("SET", "ab"));
-        assertCommandError(array("pfcount"));
-    }
-
     @Test
     public void testUnknownCommand() throws ParseErrorException, EOFException {
         assertCommandError(array("unknown"));
diff --git a/src/test/java/com/github/fppt/jedismock/TestRedisServer.java b/src/test/java/com/github/fppt/jedismock/TestRedisServer.java
index e5e83f5..6b9c7cc 100644
--- a/src/test/java/com/github/fppt/jedismock/TestRedisServer.java
+++ b/src/test/java/com/github/fppt/jedismock/TestRedisServer.java
@@ -54,79 +54,6 @@ public class TestRedisServer {
         }
     }
 
-    @Test
-    public void testSlave() throws IOException {
-        RedisServer master = RedisServer.newRedisServer();
-        RedisServer slave = RedisServer.newRedisServer();
-        master.setSlave(slave);
-        master.start();
-        slave.start();
-        Jedis jedis1 = new Jedis(master.getHost(), master.getBindPort());
-        Jedis jedis2 = new Jedis(slave.getHost(), slave.getBindPort());
-        assertEquals(jedis1.set("ab", "cd"), "OK");
-        assertEquals(jedis2.get("ab"), "cd");
-        jedis1.disconnect();
-        jedis2.disconnect();
-        master.stop();
-        slave.stop();
-    }
-
-    @Test
-    public void testDelInMasterSlave() throws IOException {
-        RedisServer master = RedisServer.newRedisServer();
-        RedisServer slave = RedisServer.newRedisServer();
-        master.setSlave(slave);
-        master.start();
-        slave.start();
-        Jedis jedis1 = new Jedis(master.getHost(), master.getBindPort());
-        Jedis jedis2 = new Jedis(slave.getHost(), slave.getBindPort());
-        assertEquals(jedis1.set("a", "b"), "OK");
-        assertEquals(jedis1.del("a"), (Long) 1L);
-        assertEquals(jedis2.exists("a"), false);
-        jedis1.disconnect();
-        jedis2.disconnect();
-        master.stop();
-        slave.stop();
-    }
-
-    @Test
-    public void testExpireInMasterSlave() throws IOException {
-        RedisServer master = RedisServer.newRedisServer();
-        RedisServer slave = RedisServer.newRedisServer();
-        master.setSlave(slave);
-        master.start();
-        slave.start();
-        Jedis jedis1 = new Jedis(master.getHost(), master.getBindPort());
-        Jedis jedis2 = new Jedis(slave.getHost(), slave.getBindPort());
-        assertEquals(jedis1.set("a", "b"), "OK");
-        assertEquals(jedis1.expire("a", 1), (Long) 1L);
-        assertEquals(jedis2.ttl("a"), (Long) 1L);
-        jedis1.disconnect();
-        jedis2.disconnect();
-        master.stop();
-        slave.stop();
-    }
-
-    @Test
-    public void testExpireAtInMasterSlave() throws IOException {
-        RedisServer master = RedisServer.newRedisServer();
-        RedisServer slave = RedisServer.newRedisServer();
-        master.setSlave(slave);
-        master.start();
-        slave.start();
-        Jedis jedis1 = new Jedis(master.getHost(), master.getBindPort());
-        Jedis jedis2 = new Jedis(slave.getHost(), slave.getBindPort());
-        assertEquals(jedis1.set("a", "b"), "OK");
-        long now = System.currentTimeMillis() / 1000;
-        assertEquals(jedis1.expireAt("a", now + 5), (Long) 1L);
-        assertEquals(jedis2.ttl("a"), (Long) 5L);
-        jedis1.disconnect();
-        jedis2.disconnect();
-        master.stop();
-        slave.stop();
-    }
-
-
     @Test
     public void testCloseSocket() throws IOException {
         RedisServer server = RedisServer.newRedisServer();
diff --git a/src/test/java/com/github/fppt/jedismock/TestUtils.java b/src/test/java/com/github/fppt/jedismock/TestUtils.java
index 33920ad..46f9f19 100644
--- a/src/test/java/com/github/fppt/jedismock/TestUtils.java
+++ b/src/test/java/com/github/fppt/jedismock/TestUtils.java
@@ -1,16 +1,13 @@
 package com.github.fppt.jedismock;
 
-import com.google.common.collect.Lists;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.List;
-import java.util.function.BiConsumer;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
 
 /**
  * Created by Xiaolu on 2015/4/20.
@@ -36,29 +33,6 @@ public class TestUtils {
         });
     }
 
-    private void assertArgumentCheckThrowsException(BiConsumer<List<Slice>, Integer> check, List<Slice> args, int passValue, int failValue){
-        check.accept(args, passValue);
-        exception.expect(IllegalArgumentException.class);
-        check.accept(args, failValue);
-    }
-
-    @Test
-    public void testCheckArgumentsNumberEquals() {
-        List<Slice> args = Lists.newArrayList(Slice.create(""), Slice.create(""));
-        assertArgumentCheckThrowsException(Utils::checkArgumentsNumberEquals, args, 2, 1);
-    }
-
-    @Test
-    public void testCheckArgumentsNumberGreater() {
-        List<Slice> args = Lists.newArrayList(Slice.create(""), Slice.create(""));
-        assertArgumentCheckThrowsException(Utils::checkArgumentsNumberGreater, args, 1, 2);
-    }
-
-    @Test
-    public void testCheckArgumentsNumberFactor() {
-        List<Slice> args = Lists.newArrayList(Slice.create(""), Slice.create(""), Slice.create(""));
-        assertArgumentCheckThrowsException(Utils::checkArgumentsNumberFactor, args, 1, 2);
-    }
 
     @Test
     public void testSerializeAndDeserialize() {