### Question:
CachedIpFilter implements IpFilter { @Override public boolean accept(String ip) { if (cachedMap.containsKey(ip)) return cachedMap.get(ip); Boolean result = delegate.accept(ip); cachedMap.put(ip, result); return result; } CachedIpFilter(IpFilter delegate); @Override boolean accept(String ip);  }### Answer:
@Test public void shouldCacheDupIp() { IpFilter mockFilter = mock(IpFilter.class); String ip = "1.2.3.4"; when(mockFilter.accept(ip)).thenReturn(true); CachedIpFilter filter = new CachedIpFilter(mockFilter); filter.accept(ip); verify(mockFilter, only()).accept(ip); filter.accept(ip); verify(mockFilter, only()).accept(ip); }