RedisRepository implements IDbRepository<T> { @Override public T getById(String id) { if (id == null) { return null; } T result; try (Jedis jedis = this.jedisPool.getResource()) { String entryKey = String.format("%s:%s", this.entryNamespace, id); String entryValue = jedis.get(entryKey); result = this.jsonConverter.fromJson(entryValue, this.type); } return result; } RedisRepository(Class<T> type);  RedisRepository(Class<T> entry, JedisPool pool); @Override T getById(String id); @Override List<T> getAll(); @Override T add(T entry); @Override T update(T entry); @Override T delete(String id);  }
@Test public void getById() { Entity entry = new Entity(); this.repository.add(entry); String expectedResult = entry.getId(); String actualResult = this.repository.getById(entry.getId()).getId(); Assert.assertEquals(expectedResult, actualResult); }