Search in sources :

Example 6 with ScalarTypeAdapters

use of com.apollographql.apollo.response.ScalarTypeAdapters 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

ScalarTypeAdapters (com.apollographql.apollo.response.ScalarTypeAdapters)6 Test (org.junit.Test)5 Logger (com.apollographql.apollo.Logger)3 ScalarType (com.apollographql.apollo.api.ScalarType)3 ApolloLogger (com.apollographql.apollo.internal.ApolloLogger)3 CustomTypeAdapter (com.apollographql.apollo.response.CustomTypeAdapter)3 Nullable (javax.annotation.Nullable)3 Predicate (com.google.common.base.Predicate)2 Request (okhttp3.Request)2 Buffer (okio.Buffer)2 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 AllPlanetsQuery (com.apollographql.apollo.integration.httpcache.AllPlanetsQuery)1 EpisodeHeroNameQuery (com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery)1 HeroNameQuery (com.apollographql.apollo.integration.normalizer.HeroNameQuery)1 MapFieldValueResolver (com.apollographql.apollo.internal.field.MapFieldValueResolver)1 JsonWriter (com.apollographql.apollo.internal.json.JsonWriter)1