@Test @Override public final void testContains() throws Exception { MockWebServer server = new MockWebServer(); server.enqueue(new MockResponse().setResponseCode(404)); server.enqueue(new MockResponse()); server.enqueue(new MockResponse().setResponseCode(404)); server.enqueue(new MockResponse()); server.enqueue(new MockResponse().setResponseCode(404)); server.start(); baseUrl = server.url("/"); super.testContains(); CachedStorage storage = createStorage(); OutputStream localStream = storage.getLocal().openOutputStream(TestUtils.TEST_NAME_2); localStream.write(TestUtils.TEST_DATA_2); localStream.flush(); localStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_2)); assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID)); OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3); remoteStream.write(TestUtils.TEST_DATA_3); remoteStream.flush(); remoteStream.close(); assertTrue(storage.contains(TestUtils.TEST_NAME_3)); assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID)); server.shutdown(); }
@Override public boolean contains(@NonNull String id) throws IOException { return local.contains(id) || remote.contains(id); }
CachedStorage implements Storage { @Override public boolean contains(@NonNull String id) throws IOException { return local.contains(id) || remote.contains(id); } }
CachedStorage implements Storage { @Override public boolean contains(@NonNull String id) throws IOException { return local.contains(id) || remote.contains(id); } CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local
    );  CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local,
            @NonNull CachedStorageStates cachedStorageStates
    ); }
CachedStorage implements Storage { @Override public boolean contains(@NonNull String id) throws IOException { return local.contains(id) || remote.contains(id); } CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local
    );  CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local,
            @NonNull CachedStorageStates cachedStorageStates
    ); @Override boolean contains(@NonNull String id); @NonNull @Override OutputStream openOutputStream(@NonNull final String id); @Override InputStream openInputStream(@NonNull final String id); boolean isFullyCached(@NonNull String id); @Override boolean delete(@NonNull String id); @Override void deleteAll(); @SuppressWarnings("TryFinallyCanBeTryWithResources") void cache(String id); boolean purge(@NonNull String id); void setLazyCaching(boolean lazyCaching); boolean isLazyCaching(boolean lazyCaching); }
CachedStorage implements Storage { @Override public boolean contains(@NonNull String id) throws IOException { return local.contains(id) || remote.contains(id); } CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local
    );  CachedStorage(
            @NonNull Storage remote,
            @NonNull Storage local,
            @NonNull CachedStorageStates cachedStorageStates
    ); @Override boolean contains(@NonNull String id); @NonNull @Override OutputStream openOutputStream(@NonNull final String id); @Override InputStream openInputStream(@NonNull final String id); boolean isFullyCached(@NonNull String id); @Override boolean delete(@NonNull String id); @Override void deleteAll(); @SuppressWarnings("TryFinallyCanBeTryWithResources") void cache(String id); boolean purge(@NonNull String id); void setLazyCaching(boolean lazyCaching); boolean isLazyCaching(boolean lazyCaching);  }