DistributedCache implements Cache { @Override public ActionResponse put(String key, ActionResponse data) { try { final String serializedData = mapper.writeValueAsString(data); if (serializedData != null) { if (serializedData.length() <= 32 * 1024) { distributedMap.put(key, mapper.writeValueAsString(data)); } else { logger.error( String.format("Size of response is too big for cache. Skipping it. Response Part : %s", serializedData.substring(0, 1024))); } } } catch (JsonProcessingException e) { logger.error("Error saving value to map: ", e); } return data; } DistributedCache(HazelcastConnection hazelcastConnection, String name, ObjectMapper mapper); static void setupConfig(HazelcastConnection hazelcastConnection); @Override ActionResponse put(String key, ActionResponse data); @Override ActionResponse get(String key); @Override boolean has(String key);  }
@Test public void testPut() throws Exception { ActionResponse expectedResponse = new GroupResponse(Collections.<String, Object>singletonMap("Hello", "world")); ActionResponse returnResponse = distributedCache.put("DUMMY_KEY_PUT", expectedResponse); assertEquals(expectedResponse, returnResponse); GroupResponse actualResponse = GroupResponse.class.cast(distributedCache.get("DUMMY_KEY_PUT")); assertEquals(GroupResponse.class.cast(expectedResponse).getResult(), actualResponse.getResult()); }