NinjaCache { public boolean safeReplace(String key, Object value, String expiration) { checkSerializable(value); return cache.safeReplace(key, value, TimeUtil.parseDuration(expiration)); } @Inject  NinjaCache(Cache cache); void add(String key, Object value, String expiration); boolean safeAdd(String key, Object value, String expiration); void add(String key, Object value); void set(String key, Object value, String expiration); boolean safeSet(String key, Object value, String expiration); void set(String key, Object value); void replace(String key, Object value, String expiration); boolean safeReplace(String key, Object value, String expiration); void replace(String key, Object value); long incr(String key, int by); long incr(String key); long decr(String key, int by); long decr(String key); Object get(String key); Map<String, Object> get(String... key); void delete(String key); boolean safeDelete(String key); void clear(); @SuppressWarnings("unchecked") T get(String key, Class<T> clazz);  }
@Test public void testSafeReplaceKeyValueExpiration() { String key = "key"; String value = "value"; String expiration = "10s"; ninjaCache.safeReplace(key, value, expiration); verify(cache).safeReplace(key, value, TimeUtil.parseDuration(expiration)); }
@Test(expected = CacheException.class) public void testSafeReplaceKeyValueExpirationChecksSerializable() { Object notSerializable = new Object(); ninjaCache.safeReplace(null, notSerializable, null); }