CachingPublicationsFileClientAdapter implements PublicationsFileClientAdapter { public synchronized PublicationsFile getPublicationsFile() throws KSIException { if (isCacheUpdateNeeded()) { logger.debug("Publication file cache will be updated."); ByteBuffer data = publicationsFileClient.getPublicationsFile().getResult(); cachedPublicationsFile = publicationsFileFactory.create(new ByteArrayInputStream(data.array())); cacheLastUpdated = System.currentTimeMillis(); } else { logger.debug("Returning cached publication file data."); } return cachedPublicationsFile; } CachingPublicationsFileClientAdapter(KSIPublicationsFileClient publicationsFileClient, PublicationsFileFactory publicationsFileFactory, long cacheExpirationTime); synchronized PublicationsFile getPublicationsFile(); KSIPublicationsFileClient getPublicationsFileClient();  }
@Test public void tesCachingPublicationsFileAdapterReturnsPublicationFile() throws Exception { assertNotNull(adapter.getPublicationsFile()); }
@Test public void testCachingPublicationsFileAdapterCachesRequest() throws Exception { adapter.getPublicationsFile(); adapter.getPublicationsFile(); verify(mockedPublicationsFileClient, times(1)).getPublicationsFile(); }