Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Espresso idling resource for Apollo GraphQL client #469

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7a1664d
Add apollo-idling-resource module
VisheshVadhera Apr 19, 2017
3ad4610
Restructuring of the module
VisheshVadhera Apr 19, 2017
1210f32
Add IdlingResource class
VisheshVadhera Apr 19, 2017
0dda9b8
Add dispatcher
VisheshVadhera Apr 20, 2017
51817a7
Add ApolloTracker for tracking the requests
VisheshVadhera Apr 22, 2017
76780b3
Execute callback on calls finished
VisheshVadhera Apr 24, 2017
0af44d1
Register espresso callback with apolloTracker
VisheshVadhera Apr 24, 2017
989e102
Add basic test to check that idlingResource is being created properly
VisheshVadhera Apr 24, 2017
b68e8e5
Add test for idleNow
VisheshVadhera Apr 25, 2017
ff6fa0d
Add test for registerCallBack
VisheshVadhera Apr 26, 2017
7158335
Rename variables
VisheshVadhera Apr 26, 2017
873f393
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera Apr 28, 2017
5525529
Change variable names
VisheshVadhera Apr 28, 2017
43a90b6
Add tests for apolloCallTracker
VisheshVadhera Apr 28, 2017
53801bf
Hide usage of apolloTracker in apolloClient
VisheshVadhera Apr 28, 2017
4483920
Fix tests in apolloCallTracker
VisheshVadhera Apr 28, 2017
190ae11
Add tests for syncCalls
VisheshVadhera Apr 28, 2017
664b033
Add test for checking that idleCallback is invoked
VisheshVadhera Apr 28, 2017
41dcb1d
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera Apr 28, 2017
72484ae
Cleanup
VisheshVadhera Apr 28, 2017
cbf6574
Add docs for ApolloCallTracker
VisheshVadhera Apr 28, 2017
de9a829
Checkstyle
VisheshVadhera May 1, 2017
1cc6187
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 2, 2017
07d4b91
Merge branch 'feature-espresso-idling-resource' of github.com:Vishesh…
VisheshVadhera May 2, 2017
5d23a9f
Temp fix for apollo-sample module
VisheshVadhera May 2, 2017
69a28d5
Revert the change made in last commit
VisheshVadhera May 3, 2017
d934cc0
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 3, 2017
8d1a6d6
Fix the assertionError in ApolloPrefetchCallbackTest
VisheshVadhera May 3, 2017
7610a67
Move the test class to idling-resource package
VisheshVadhera May 3, 2017
c75d4c4
Add docs for new methods in apolloClient
VisheshVadhera May 3, 2017
79d2f99
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 4, 2017
f5ba765
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 9, 2017
85581e0
Change method names
VisheshVadhera May 11, 2017
7471952
Move the private method to the last
VisheshVadhera May 11, 2017
f3f1e48
Change method names
VisheshVadhera May 11, 2017
fa598f1
Change Deque with LinkedHashSet
VisheshVadhera May 11, 2017
0d495e1
Remove synchronized from setIdleCallback
VisheshVadhera May 11, 2017
8133815
Rename idleCallback to idleResourceCallback
VisheshVadhera May 12, 2017
1860193
Merge branch 'feature-espresso-idling-resource' of github.com:Vishesh…
VisheshVadhera May 12, 2017
f47672b
Fix checkstyle
VisheshVadhera May 12, 2017
c8102ba
Fix checkstyle
VisheshVadhera May 12, 2017
dd3cb51
Fix failing test
VisheshVadhera May 13, 2017
95c9383
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 13, 2017
f9d36a8
Change package & module name
VisheshVadhera May 13, 2017
ac1e4a8
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 13, 2017
516615b
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 23, 2017
4fab454
Code review
VisheshVadhera May 24, 2017
57c401d
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 29, 2017
c4e5ab5
Change the order of methods in the class
VisheshVadhera May 29, 2017
3dad93e
Add missing tracker to builder in RealApolloCall
VisheshVadhera May 29, 2017
9820c66
Fix tests in queryFetcher
VisheshVadhera May 30, 2017
2096424
Merge branch 'master' of github.com:apollographql/apollo-android into…
VisheshVadhera May 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' of github.com:apollographql/apollo-android into…
… feature-espresso-idling-resource
  • Loading branch information
VisheshVadhera committed May 29, 2017
commit 57c401d54c99e21ca4db3c2835d08f40292d4bf6
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private <D extends Operation.Data, T, V extends Operation.Variables> RealApolloC
.logger(logger)
.applicationInterceptors(applicationInterceptors)
.tracker(callTracker)
.refetchQueries(Collections.<Query>emptyList())
.refetchQueryNames(Collections.<OperationName>emptyList())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,39 @@ public static <T> Builder<T> builder() {
}

private RealApolloCall(Builder<T> builder) {
this.operation = builder.operation;
this.serverUrl = builder.serverUrl;
this.httpCallFactory = builder.httpCallFactory;
this.httpCache = builder.httpCache;
this.httpCachePolicy = builder.httpCachePolicy;
this.moshi = builder.moshi;
this.responseFieldMapper = builder.responseFieldMapper;
this.customTypeAdapters = builder.customTypeAdapters;
this.apolloStore = builder.apolloStore;
this.cacheControl = builder.cacheControl;
this.cacheHeaders = builder.cacheHeaders;
this.dispatcher = builder.dispatcher;
this.logger = builder.logger;
this.applicationInterceptors = builder.applicationInterceptors;
this.refetchQueryNames = builder.refetchQueryNames;
this.tracker = builder.tracker;
operation = builder.operation;
serverUrl = builder.serverUrl;
httpCallFactory = builder.httpCallFactory;
httpCache = builder.httpCache;
httpCachePolicy = builder.httpCachePolicy;
moshi = builder.moshi;
responseFieldMapperFactory = builder.responseFieldMapperFactory;
customTypeAdapters = builder.customTypeAdapters;
apolloStore = builder.apolloStore;
cacheControl = builder.cacheControl;
cacheHeaders = builder.cacheHeaders;
dispatcher = builder.dispatcher;
logger = builder.logger;
applicationInterceptors = builder.applicationInterceptors;
refetchQueryNames = builder.refetchQueryNames;
refetchQueries = builder.refetchQueries;
tracker = builder.tracker;
if (refetchQueries.isEmpty() || builder.apolloStore == null) {
queryFetcher = Optional.absent();
} else {
queryFetcher = Optional.of(QueryFetcher.builder()
.queries(builder.refetchQueries)
.serverUrl(builder.serverUrl)
.httpCallFactory(builder.httpCallFactory)
.moshi(builder.moshi)
.responseFieldMapperFactory(builder.responseFieldMapperFactory)
.customTypeAdapters(builder.customTypeAdapters)
.apolloStore(builder.apolloStore)
.dispatcher(builder.dispatcher)
.logger(builder.logger)
.applicationInterceptors(builder.applicationInterceptors)
.build());
}
interceptorChain = prepareInterceptorChain(operation);
}

Expand Down Expand Up @@ -185,73 +202,90 @@ private RealApolloCall(Builder<T> builder) {
.build();
}

final class AsyncCall implements ApolloInterceptor.CallBack {

private final Callback<T> responseCallback;
@Nonnull @Override public ApolloMutationCall<T> refetchQueries(@Nonnull Query... queries) {
if (executed.get()) throw new IllegalStateException("Already Executed");
return toBuilder()
.refetchQueries(Arrays.asList(checkNotNull(queries, "queries == null")))
.build();
}

private AsyncCall(Callback<T> callback) {
this.responseCallback = callback;
}
final class AsyncCall implements ApolloInterceptor.CallBack {

@Override public void onResponse(@Nonnull ApolloInterceptor.InterceptorResponse response) {
try {
private final Callback<T> responseCallback;

if (responseCallback == null) {
return;
}
if (canceled) {
responseCallback.onCanceledError(new ApolloCanceledException("Canceled"));
} else { //noinspection unchecked
responseCallback.onResponse(response.parsedResponse.get());
}
} finally {
tracker.onAsyncCallFinished(this);
private AsyncCall(Callback<T> callback) {
this.responseCallback = callback;
}
}

@Override public void onFailure(@Nonnull ApolloException e) {
try {

if (responseCallback == null) {
return;
@Override public void onResponse(@Nonnull final ApolloInterceptor.InterceptorResponse response) {
try {

if (responseCallback == null) {
return;
}
if (canceled) {
responseCallback.onCanceledError(new ApolloCanceledException("Canceled"));
return;
}
if(queryFetcher.isPresent()){
queryFetcher.get().refetchAsync(new QueryFetcher.OnFetchCompleteCallback() {
@Override public void onFetchComplete() {
//noinspection unchecked
responseCallback.onResponse(response.parsedResponse.get());
}
});
}
else { //noinspection unchecked
responseCallback.onResponse(response.parsedResponse.get());
}
} finally {
tracker.onAsyncCallFinished(this);
}
}

if (canceled) {
responseCallback.onCanceledError(new ApolloCanceledException("Canceled", e));
} else if (e instanceof ApolloHttpException) {
responseCallback.onHttpError((ApolloHttpException) e);
} else if (e instanceof ApolloParseException) {
responseCallback.onParseError((ApolloParseException) e);
} else if (e instanceof ApolloNetworkException) {
responseCallback.onNetworkError((ApolloNetworkException) e);
} else {
responseCallback.onFailure(e);
@Override public void onFailure(@Nonnull ApolloException e) {
try {

if (responseCallback == null) {
return;
}

if (canceled) {
responseCallback.onCanceledError(new ApolloCanceledException("Canceled", e));
} else if (e instanceof ApolloHttpException) {
responseCallback.onHttpError((ApolloHttpException) e);
} else if (e instanceof ApolloParseException) {
responseCallback.onParseError((ApolloParseException) e);
} else if (e instanceof ApolloNetworkException) {
responseCallback.onNetworkError((ApolloNetworkException) e);
} else {
responseCallback.onFailure(e);
}
} finally {
tracker.onAsyncCallFinished(this);
}
} finally {
tracker.onAsyncCallFinished(this);
}
}
}

public Builder<T> toBuilder() {
return RealApolloCall.<T>builder()
.operation(operation)
.serverUrl(serverUrl)
.httpCallFactory(httpCallFactory)
.httpCache(httpCache)
.httpCachePolicy(httpCachePolicy)
.moshi(moshi)
.responseFieldMapperFactory(responseFieldMapperFactory)
.customTypeAdapters(customTypeAdapters)
.apolloStore(apolloStore)
.cacheControl(cacheControl)
.cacheHeaders(cacheHeaders)
.dispatcher(dispatcher)
.logger(logger)
.applicationInterceptors(applicationInterceptors)
.refetchQueryNames(refetchQueryNames)
.refetchQueries(refetchQueries);
}
public Builder<T> toBuilder () {
return RealApolloCall.<T>builder()
.operation(operation)
.serverUrl(serverUrl)
.httpCallFactory(httpCallFactory)
.httpCache(httpCache)
.httpCachePolicy(httpCachePolicy)
.moshi(moshi)
.responseFieldMapperFactory(responseFieldMapperFactory)
.customTypeAdapters(customTypeAdapters)
.apolloStore(apolloStore)
.cacheControl(cacheControl)
.cacheHeaders(cacheHeaders)
.dispatcher(dispatcher)
.logger(logger)
.applicationInterceptors(applicationInterceptors)
.refetchQueryNames(refetchQueryNames)
.refetchQueries(refetchQueries);
}

private ApolloInterceptorChain prepareInterceptorChain(Operation operation) {
List<ApolloInterceptor> interceptors = new ArrayList<>();
Expand Down Expand Up @@ -286,6 +320,7 @@ public static final class Builder<T> {
List<ApolloInterceptor> applicationInterceptors;
List<OperationName> refetchQueryNames;
ApolloCallTracker tracker;
List<Query> refetchQueries = emptyList();

public Builder<T> operation(Operation operation) {
this.operation = operation;
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.