@Test public void add() throws TimeoutException, CacheException { String cacheKey = "key1"; int expiration = 900; Object value = new Point(66, 99); cache.add(cacheKey, expiration, value, defaultSerializationType); Mockito.verify(cacheClient).add(getKey(cacheKey), expiration, value); cache.add(cacheKey, expiration, value, SerializationType.JSON); Mockito.verify(cacheClient).add(getKey(cacheKey), expiration, value, jsonTranscoder); }
@Override public <T> boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType) throws TimeoutException, CacheException { final boolean added; switch (getSerializationType(serializationType)) { case JAVA: added = add(cacheKey, expiration, value, SerializationType.JAVA, javaTranscoder); break; case JSON: added = add(cacheKey, expiration, value, SerializationType.JSON, jsonTranscoder); break; case PROVIDER: added = add(cacheKey, expiration, value, SerializationType.PROVIDER, null); break; case CUSTOM: added = add(cacheKey, expiration, value, SerializationType.CUSTOM, customTranscoder); break; default: throw new IllegalArgumentException(String.format("Serialization type %s is not supported", serializationType)); } return added; }
CacheImpl implements Cache { @Override public <T> boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType) throws TimeoutException, CacheException { final boolean added; switch (getSerializationType(serializationType)) { case JAVA: added = add(cacheKey, expiration, value, SerializationType.JAVA, javaTranscoder); break; case JSON: added = add(cacheKey, expiration, value, SerializationType.JSON, jsonTranscoder); break; case PROVIDER: added = add(cacheKey, expiration, value, SerializationType.PROVIDER, null); break; case CUSTOM: added = add(cacheKey, expiration, value, SerializationType.CUSTOM, customTranscoder); break; default: throw new IllegalArgumentException(String.format("Serialization type %s is not supported", serializationType)); } return added; } }
CacheImpl implements Cache { @Override public <T> boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType) throws TimeoutException, CacheException { final boolean added; switch (getSerializationType(serializationType)) { case JAVA: added = add(cacheKey, expiration, value, SerializationType.JAVA, javaTranscoder); break; case JSON: added = add(cacheKey, expiration, value, SerializationType.JSON, jsonTranscoder); break; case PROVIDER: added = add(cacheKey, expiration, value, SerializationType.PROVIDER, null); break; case CUSTOM: added = add(cacheKey, expiration, value, SerializationType.CUSTOM, customTranscoder); break; default: throw new IllegalArgumentException(String.format("Serialization type %s is not supported", serializationType)); } return added; } CacheImpl(final String name, final Collection<String> aliases, final CacheClient cacheClient,
            final SerializationType defaultSerializationType, final JsonTranscoder jsonTranscoder, final JavaTranscoder javaTranscoder,
            final CacheTranscoder customTranscoder, final CacheProperties properties); }
CacheImpl implements Cache { @Override public <T> boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType) throws TimeoutException, CacheException { final boolean added; switch (getSerializationType(serializationType)) { case JAVA: added = add(cacheKey, expiration, value, SerializationType.JAVA, javaTranscoder); break; case JSON: added = add(cacheKey, expiration, value, SerializationType.JSON, jsonTranscoder); break; case PROVIDER: added = add(cacheKey, expiration, value, SerializationType.PROVIDER, null); break; case CUSTOM: added = add(cacheKey, expiration, value, SerializationType.CUSTOM, customTranscoder); break; default: throw new IllegalArgumentException(String.format("Serialization type %s is not supported", serializationType)); } return added; } CacheImpl(final String name, final Collection<String> aliases, final CacheClient cacheClient,
            final SerializationType defaultSerializationType, final JsonTranscoder jsonTranscoder, final JavaTranscoder javaTranscoder,
            final CacheTranscoder customTranscoder, final CacheProperties properties); @Override Collection<SocketAddress> getAvailableServers(); @Override T get(final String cacheKey, final SerializationType serializationType); @Override @SuppressWarnings("unchecked") void set(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override void setSilently(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override boolean addSilently(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override Map<String, Object> getBulk(final Collection<String> keys, final SerializationType serializationType); @Override long decr(final String key, final int by); @Override boolean delete(final String key); @Override void delete(final Collection<String> keys); @Override void flush(); @Override long incr(final String key, final int by, final long def); @Override long incr(final String key, final int by, final long def, final int exp); @Override boolean isEnabled(); @Override Long getCounter(final String cacheKey); @Override void setCounter(final String cacheKey, final int expiration, final long value); @Override void shutdown(); @Override Object getNativeClient(); }
CacheImpl implements Cache { @Override public <T> boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType) throws TimeoutException, CacheException { final boolean added; switch (getSerializationType(serializationType)) { case JAVA: added = add(cacheKey, expiration, value, SerializationType.JAVA, javaTranscoder); break; case JSON: added = add(cacheKey, expiration, value, SerializationType.JSON, jsonTranscoder); break; case PROVIDER: added = add(cacheKey, expiration, value, SerializationType.PROVIDER, null); break; case CUSTOM: added = add(cacheKey, expiration, value, SerializationType.CUSTOM, customTranscoder); break; default: throw new IllegalArgumentException(String.format("Serialization type %s is not supported", serializationType)); } return added; } CacheImpl(final String name, final Collection<String> aliases, final CacheClient cacheClient,
            final SerializationType defaultSerializationType, final JsonTranscoder jsonTranscoder, final JavaTranscoder javaTranscoder,
            final CacheTranscoder customTranscoder, final CacheProperties properties); @Override Collection<SocketAddress> getAvailableServers(); @Override T get(final String cacheKey, final SerializationType serializationType); @Override @SuppressWarnings("unchecked") void set(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override void setSilently(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override boolean add(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override boolean addSilently(final String cacheKey, final int expiration, final Object value, final SerializationType serializationType); @Override Map<String, Object> getBulk(final Collection<String> keys, final SerializationType serializationType); @Override long decr(final String key, final int by); @Override boolean delete(final String key); @Override void delete(final Collection<String> keys); @Override void flush(); @Override long incr(final String key, final int by, final long def); @Override long incr(final String key, final int by, final long def, final int exp); @Override boolean isEnabled(); @Override Long getCounter(final String cacheKey); @Override void setCounter(final String cacheKey, final int expiration, final long value); @Override void shutdown(); @Override Object getNativeClient();  }