Search in sources :

Example 1 with NamedCountDownLatch

use of com.apollographql.apollo.NamedCountDownLatch in project apollo-android by apollographql.

the class ApolloStoreTest method storeClearAllCallsNormalizedCacheClearAll.

@Test
public void storeClearAllCallsNormalizedCacheClearAll() throws Exception {
    final NamedCountDownLatch latch = new NamedCountDownLatch("storeClearAllCallsNormalizedCacheClearAll", 1);
    final RealApolloStore realApolloStore = new RealApolloStore(new NormalizedCache() {

        @Nullable
        @Override
        public Record loadRecord(@Nonnull String key, @Nonnull CacheHeaders cacheHeaders) {
            return null;
        }

        @Nonnull
        @Override
        public Set<String> merge(@Nonnull Record record, @Nonnull CacheHeaders cacheHeaders) {
            return emptySet();
        }

        @Override
        public void clearAll() {
            latch.countDown();
        }

        @Override
        public boolean remove(@Nonnull CacheKey cacheKey) {
            return false;
        }

        @Nonnull
        @Override
        protected Set<String> performMerge(@Nonnull Record apolloRecord, @Nonnull CacheHeaders cacheHeaders) {
            return emptySet();
        }
    }, CacheKeyResolver.DEFAULT, new ScalarTypeAdapters(Collections.EMPTY_MAP), Executors.newSingleThreadExecutor(), new ApolloLogger(Optional.<Logger>absent()));
    realApolloStore.clearAll().execute();
    latch.awaitOrThrowWithTimeout(3, TimeUnit.SECONDS);
}
Also used : Collections.emptySet(java.util.Collections.emptySet) Set(java.util.Set) Nonnull(javax.annotation.Nonnull) NamedCountDownLatch(com.apollographql.apollo.NamedCountDownLatch) ApolloLogger(com.apollographql.apollo.internal.ApolloLogger) Logger(com.apollographql.apollo.Logger) ApolloLogger(com.apollographql.apollo.internal.ApolloLogger) ScalarTypeAdapters(com.apollographql.apollo.response.ScalarTypeAdapters) CacheHeaders(com.apollographql.apollo.cache.CacheHeaders) NormalizedCache(com.apollographql.apollo.cache.normalized.NormalizedCache) Record(com.apollographql.apollo.cache.normalized.Record) Nullable(javax.annotation.Nullable) CacheKey(com.apollographql.apollo.cache.normalized.CacheKey) Test(org.junit.Test)

Aggregations

Logger (com.apollographql.apollo.Logger)1 NamedCountDownLatch (com.apollographql.apollo.NamedCountDownLatch)1 CacheHeaders (com.apollographql.apollo.cache.CacheHeaders)1 CacheKey (com.apollographql.apollo.cache.normalized.CacheKey)1 NormalizedCache (com.apollographql.apollo.cache.normalized.NormalizedCache)1 Record (com.apollographql.apollo.cache.normalized.Record)1 ApolloLogger (com.apollographql.apollo.internal.ApolloLogger)1 ScalarTypeAdapters (com.apollographql.apollo.response.ScalarTypeAdapters)1 Collections.emptySet (java.util.Collections.emptySet)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Test (org.junit.Test)1