### Question:
CreatedQueryLogicCacheBean { public Map<String,Pair<QueryLogic<?>,Connector>> snapshot() { HashMap<Pair<String,Long>,Triple> snapshot = Maps.newHashMap(cache); HashMap<String,Pair<QueryLogic<?>,Connector>> tformMap = Maps.newHashMapWithExpectedSize(cache.size()); for (Entry<String,Pair<QueryLogic<?>,Connector>> tform : Iterables.transform(snapshot.entrySet(), toPair)) { tformMap.put(tform.getKey(), tform.getValue()); } return tformMap; }  boolean add(String queryId, String userId, QueryLogic<?> logic, Connector cxn); Pair<QueryLogic<?>,Connector> poll(String id); Map<String,Pair<QueryLogic<?>,Connector>> snapshot(); Map<String,Pair<QueryLogic<?>,Connector>> entriesOlderThan(final Long now, final Long expiration); Pair<QueryLogic<?>,Connector> pollIfOwnedBy(String queryId, String userId); void clearQueryLogics(long currentTimeMs, long timeToLiveMs); @PreDestroy void shutdown();  }### Answer:
@Test public void testSnapshot() throws Exception { String queryId1 = "12345", queryId2 = "123456"; String userId = "me"; long timestamp = 1l; EasyMock.expect(System.currentTimeMillis()).andReturn(timestamp); PowerMock.replayAll(); boolean ret1 = qlCache.add(queryId1, userId, queryLogic, conn); Map<String,Pair<QueryLogic<?>,Connector>> snapshot = qlCache.snapshot(); PowerMock.verifyAll(); Assert.assertTrue("Expected the cache add to return true", ret1); Assert.assertEquals(1, internalCache.size()); Assert.assertEquals(1, snapshot.size()); PowerMock.resetAll(); EasyMock.expect(System.currentTimeMillis()).andReturn(timestamp); PowerMock.replayAll(); boolean ret2 = qlCache.add(queryId2, userId, queryLogic, conn); PowerMock.verifyAll(); Assert.assertTrue("Expected the cache add to return true", ret2); Assert.assertEquals(2, internalCache.size()); Assert.assertEquals(1, snapshot.size()); }