@Test public void shouldReturnZippedOutputStream() { when(delegate.put(any(), any())).thenReturn(mock(OutputStream.class)); ContentCache contentCache = new ZippedContentCache(delegate); final OutputStream stream = contentCache.put(() -> StringUtils.EMPTY, ContentCache.TimeToLive.DEFAULT); verify(delegate, times(1)).put(any(), any()); assertEquals(GZIPOutputStream.class, stream.getClass()); }
@Override @VolumeMetered public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return ofNullable(delegate.put(key, timeToLive)) .map(entry -> { try { return new GZIPOutputStream(entry); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }) .orElse(null); }
ZippedContentCache implements ContentCache { @Override @VolumeMetered public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return ofNullable(delegate.put(key, timeToLive)) .map(entry -> { try { return new GZIPOutputStream(entry); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }) .orElse(null); } }
ZippedContentCache implements ContentCache { @Override @VolumeMetered public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return ofNullable(delegate.put(key, timeToLive)) .map(entry -> { try { return new GZIPOutputStream(entry); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }) .orElse(null); } ZippedContentCache(ContentCache delegate); }
ZippedContentCache implements ContentCache { @Override @VolumeMetered public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return ofNullable(delegate.put(key, timeToLive)) .map(entry -> { try { return new GZIPOutputStream(entry); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }) .orElse(null); } ZippedContentCache(ContentCache delegate); @Override @Timed boolean has(ContentCacheKey key); @Override @VolumeMetered InputStream get(ContentCacheKey key); @Override @VolumeMetered OutputStream put(ContentCacheKey key, TimeToLive timeToLive); @Override @Timed void evict(ContentCacheKey key); @Override @Timed void evictMatch(ContentCacheKey key); @Override @Timed void move(ContentCacheKey from, ContentCacheKey to, TimeToLive toTimeToLive); @Override @Timed void clear(); }
ZippedContentCache implements ContentCache { @Override @VolumeMetered public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return ofNullable(delegate.put(key, timeToLive)) .map(entry -> { try { return new GZIPOutputStream(entry); } catch (IOException e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } }) .orElse(null); } ZippedContentCache(ContentCache delegate); @Override @Timed boolean has(ContentCacheKey key); @Override @VolumeMetered InputStream get(ContentCacheKey key); @Override @VolumeMetered OutputStream put(ContentCacheKey key, TimeToLive timeToLive); @Override @Timed void evict(ContentCacheKey key); @Override @Timed void evictMatch(ContentCacheKey key); @Override @Timed void move(ContentCacheKey from, ContentCacheKey to, TimeToLive toTimeToLive); @Override @Timed void clear();  }