Here is the method I am trying to unit test:
public void setToCache(final String cacheKey, final String value) {
if (StringUtils.isEmpty(cacheKey)) {
throw new NamedSystemException(
ENamedSystemExceptionCode.ILLEGAL_ARGUMENT_EXCEPTION,
"Cache Key is null or empty.");
} else if (StringUtils.isEmpty(value)) {
throw new NamedSystemException(
ENamedSystemExceptionCode.ILLEGAL_ARGUMENT_EXCEPTION,
"Value is null or empty.");
}
final Jedis jedis = getJedisClient();
try {
jedis.set(cacheKey, value);
jedis.expire(cacheKey, 60);
} finally {
jedis.close();
}
}
How can I mock the Jedis
object?