DistributedCache implements Cache { @Override public ActionResponse get(String key) { if (null == key) { return null; } String data = distributedMap.get(key); if(null != data) { try { return mapper.readValue(data, ActionResponse.class); } catch (IOException e) { logger.error("Error deserializing: ", e); } } return null; } 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 testGet() throws Exception { GroupResponse baseRequest = new GroupResponse(); baseRequest.setResult(Collections.<String, Object>singletonMap("Hello", "World")); String requestString = mapper.writeValueAsString(baseRequest); distributedCache.put("DUMMY_KEY_GET", mapper.readValue(requestString, ActionResponse.class)); ActionResponse actionResponse = distributedCache.get("DUMMY_KEY_GET"); String actualResponse = mapper.writeValueAsString(actionResponse); assertEquals(requestString, actualResponse); }
@Test public void testGetInvalidKeyValue() throws Exception { assertNull(distributedCache.get("DUMMY_KEY_GET")); }
@Test public void testGetNullKey() throws Exception { assertNull(distributedCache.get(null)); }