use of com.apollographql.apollo.internal.util.Cancelable in project aws-mobile-appsync-sdk-android by awslabs.
the class QueryInstrumentationTest method testBaseSyncQuery.
@Test
public void testBaseSyncQuery() {
AWSAppSyncClient awsAppSyncClient = AWSAppSyncClients.withIAMFromAWSConfiguration();
// Perform a base query and await success.
LatchedGraphQLCallback<Operation.Data> baseQueryCallback = LatchedGraphQLCallback.instance();
Cancelable syncCancelable = awsAppSyncClient.sync(AllPostsQuery.builder().build(), baseQueryCallback, 0);
assertFalse(syncCancelable.isCanceled());
baseQueryCallback.awaitResponse();
// Cancel the query. TODO: it just completed with success, so this probably does nothing.
syncCancelable.cancel();
assertTrue(syncCancelable.isCanceled());
// Canceling twice should land things in the same place.
syncCancelable.cancel();
assertTrue(syncCancelable.isCanceled());
}
use of com.apollographql.apollo.internal.util.Cancelable in project aws-mobile-appsync-sdk-android by awslabs.
the class QueryInstrumentationTest method testBaseAndDeltaSyncQuery.
@Test
public void testBaseAndDeltaSyncQuery() {
AWSAppSyncClient awsAppSyncClient = AWSAppSyncClients.withIAMFromAWSConfiguration();
AllPostsQuery baseQuery = AllPostsQuery.builder().build();
LatchedGraphQLCallback<Operation.Data> baseQueryCallback = LatchedGraphQLCallback.instance();
AllPostsQuery deltaQuery = AllPostsQuery.builder().build();
LatchedGraphQLCallback<Operation.Data> deltaQueryCallback = LatchedGraphQLCallback.instance();
// First, a base sync happens
Cancelable cancelable = awsAppSyncClient.sync(baseQuery, baseQueryCallback, deltaQuery, deltaQueryCallback, TimeUnit.HOURS.toSeconds(1));
assertFalse(cancelable.isCanceled());
baseQueryCallback.awaitSuccessfulResponse();
// Next, a delta sync, since the refresh interval isn't over.
// deltaQueryCallback.awaitResponse(); This does not appear to be working.
cancelable.cancel();
assertTrue(cancelable.isCanceled());
// This should be a No op. Test to make sure that there are no unintended side effects
cancelable.cancel();
assertTrue(cancelable.isCanceled());
}
use of com.apollographql.apollo.internal.util.Cancelable in project aws-mobile-appsync-sdk-android by awslabs.
the class MultiClientInstrumentationTest method testSyncOnlyBaseQuery.
@Test
public void testSyncOnlyBaseQuery() {
List<AWSAppSyncClient> clients = Arrays.asList(AWSAppSyncClients.withAPIKEYFromAWSConfiguration(), AWSAppSyncClients.withIAMFromAWSConfiguration(), AWSAppSyncClients.withUserPoolsFromAWSConfiguration());
for (AWSAppSyncClient client : clients) {
Query<AllPostsQuery.Data, AllPostsQuery.Data, Variables> baseQuery = AllPostsQuery.builder().build();
LatchedGraphQLCallback<Query.Data> baseQueryCallback = LatchedGraphQLCallback.instance();
Cancelable handle = client.sync(baseQuery, baseQueryCallback, 0);
assertFalse(handle.isCanceled());
baseQueryCallback.awaitSuccessfulResponse();
handle.cancel();
assertTrue(handle.isCanceled());
// This should be a No-op. Test to make sure.
handle.cancel();
assertTrue(handle.isCanceled());
}
}
Aggregations