use of com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory in project apollo-android by apollographql.
the class ApolloWatcherTest method setUp.
@Before
public void setUp() throws IOException {
OkHttpClient okHttpClient = new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.immediateExecutorService())).build();
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).dispatcher(immediateExecutor()).okHttpClient(okHttpClient).logger(new Logger() {
@Override
public void log(int priority, @Nonnull String message, @Nonnull Optional<Throwable> t, @Nonnull Object... args) {
String throwableTrace = "";
if (t.isPresent()) {
throwableTrace = t.get().getMessage();
}
System.out.println(String.format(message, args) + " " + throwableTrace);
}
}).normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()).build();
}
use of com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory in project apollo-android by apollographql.
the class IntegrationTest method setUp.
@Before
public void setUp() {
dateCustomTypeAdapter = new CustomTypeAdapter<Date>() {
@Override
public Date decode(CustomTypeValue value) {
try {
return DATE_FORMAT.parse(value.value.toString());
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public CustomTypeValue encode(Date value) {
return new CustomTypeValue.GraphQLString(DATE_FORMAT.format(value));
}
};
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.immediateExecutorService())).build()).addCustomTypeAdapter(CustomType.DATE, dateCustomTypeAdapter).normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()).defaultResponseFetcher(ApolloResponseFetchers.NETWORK_ONLY).dispatcher(Utils.immediateExecutor()).build();
}
use of com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory in project apollo-android by apollographql.
the class OptimisticCacheTestCase method setUp.
@Before
public void setUp() {
OkHttpClient okHttpClient = new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.immediateExecutorService())).build();
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(okHttpClient).normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()).dispatcher(Utils.immediateExecutor()).build();
}
use of com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory in project apollo-android by apollographql.
the class ResponseWriteTestCase method setUp.
@Before
public void setUp() {
OkHttpClient okHttpClient = new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.immediateExecutorService())).build();
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(okHttpClient).normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()).dispatcher(Utils.immediateExecutor()).addCustomTypeAdapter(CustomType.DATE, new CustomTypeAdapter<Date>() {
@Override
public Date decode(CustomTypeValue value) {
try {
return DATE_TIME_FORMAT.parse(value.value.toString());
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public CustomTypeValue encode(Date value) {
return new CustomTypeValue.GraphQLString(DATE_TIME_FORMAT.format(value));
}
}).build();
}
use of com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory in project apollo-android by apollographql.
the class RxApolloTest method setup.
@Before
public void setup() {
OkHttpClient okHttpClient = new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.immediateExecutorService())).build();
apolloClient = ApolloClient.builder().serverUrl(server.url("/")).okHttpClient(okHttpClient).dispatcher(Utils.immediateExecutor()).normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()).build();
}
Aggregations