use of com.apollographql.apollo.Logger in project apollo-android by apollographql.
the class ApolloServerInterceptorTest method testDefaultHttpCall.
@Test
public void testDefaultHttpCall() throws Exception {
Predicate<Request> requestAssertPredicate = new Predicate<Request>() {
@Override
public boolean apply(@Nullable Request request) {
assertThat(request).isNotNull();
assertDefaultRequestHeaders(request);
assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull();
assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull();
assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull();
assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull();
assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull();
assertRequestBody(request);
return true;
}
};
ApolloServerInterceptor interceptor = new ApolloServerInterceptor(serverUrl, new AssertHttpCallFactory(requestAssertPredicate), null, false, new ScalarTypeAdapters(Collections.<ScalarType, CustomTypeAdapter>emptyMap()), new ApolloLogger(Optional.<Logger>absent()), false);
interceptor.httpCall(query);
}
use of com.apollographql.apollo.Logger in project apollo-android by apollographql.
the class ApolloServerInterceptorTest method testCachedHttpCall.
@Test
public void testCachedHttpCall() throws Exception {
Predicate<Request> requestAssertPredicate = new Predicate<Request>() {
@Override
public boolean apply(@Nullable Request request) {
assertThat(request).isNotNull();
assertDefaultRequestHeaders(request);
assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isEqualTo("1f2f23bb27630f5795166091713e18a1");
assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isEqualTo("NETWORK_FIRST");
assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isEqualTo("10000");
assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isEqualTo("false");
assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isEqualTo("false");
assertRequestBody(request);
return true;
}
};
ApolloServerInterceptor interceptor = new ApolloServerInterceptor(serverUrl, new AssertHttpCallFactory(requestAssertPredicate), HttpCachePolicy.NETWORK_FIRST.expireAfter(10, TimeUnit.SECONDS), false, new ScalarTypeAdapters(Collections.<ScalarType, CustomTypeAdapter>emptyMap()), new ApolloLogger(Optional.<Logger>absent()), false);
interceptor.httpCall(query);
}
use of com.apollographql.apollo.Logger 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);
}
Aggregations