Search in sources :

Example 1 with AllPostsQuery

use of com.amazonaws.mobileconnectors.appsync.demo.AllPostsQuery 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());
}
Also used : AWSAppSyncClient(com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient) AllPostsQuery(com.amazonaws.mobileconnectors.appsync.demo.AllPostsQuery) Cancelable(com.apollographql.apollo.internal.util.Cancelable) Test(org.junit.Test)

Aggregations

AWSAppSyncClient (com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient)1 AllPostsQuery (com.amazonaws.mobileconnectors.appsync.demo.AllPostsQuery)1 Cancelable (com.apollographql.apollo.internal.util.Cancelable)1 Test (org.junit.Test)1