RedisDBHandler implements IDBHandler { @Override public String put(String key, int sequenceId, byte[] value) { if (key == null || value == null) { return null; } try { redis.hset(serialize(key), serialize(sequenceId), value); } catch (IOException e) { e.printStackTrace(); } return key; } RedisDBHandler(); synchronized Jedis getJedisConnection(); @Override String getDatabaseVendor(); byte[] serialize(Object obj); Object deserialize(byte[] bytes); @Override boolean hasKey(String key); @Override String put(String key, int sequenceId, byte[] value); @Override Map<Integer, byte[]> get(String key); @Override List<Integer> getSequenceIds(String key); @Override boolean update(String key, int sequenceId, byte[] value); @Override String store(byte[] value); @Override Map<Integer, byte[]> remove(String key);  }
@Test public void testPut() { String key = "prasanna"; Map<Integer, byte[]> mapGiven = new HashMap<Integer, byte[]>(); String obtainedKey = ""; try { mapGiven.put(0, serialize("data1")); mapGiven.put(2, serialize("data2")); obtainedKey = dbHandler.put(key, 0, serialize("data1")); assertEquals(key, obtainedKey); obtainedKey = ""; obtainedKey = dbHandler.put(key, 2, serialize("data2")); assertEquals(key, obtainedKey); obtainedKey = ""; obtainedKey = dbHandler.put(null, 0, "bar".getBytes()); assertNull(obtainedKey); obtainedKey = ""; obtainedKey = dbHandler.put(key, 0, null); assertNull(obtainedKey); } catch (IOException e) { e.printStackTrace(); } }