Search in sources :

Example 1 with SubscriptionCallbackToADate

use of org.allGraphQLCases.subscription.SubscriptionCallbackToADate in project graphql-maven-plugin-project by graphql-java-generator.

the class GraphQLVariablesIT method test_GraphQLVariables_subscribeToADate.

@Execution(ExecutionMode.CONCURRENT)
@Test
public void test_GraphQLVariables_subscribeToADate() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException, InterruptedException {
    // Preparation
    SubscriptionCallbackToADate callback = new SubscriptionCallbackToADate("test_GraphQLVariables_subscribeToAList");
    Date date = new GregorianCalendar(2021, 4 - 1, 15).getTime();
    // Go, go, go
    GraphQLRequest subscription = subscriptionExecutor.getGraphQLRequest("subscription sub($aCustomScalarParam: Date!) {issue53(date: $aCustomScalarParam){}}");
    SubscriptionClient sub = subscription.execSubscription(callback, Date.class, "aCustomScalarParam", date);
    // Let's wait a max of 10 second, until we receive some notifications (my PC is really slow, especially when the
    // antivirus consumes 98% of my CPU!
    callback.latchForMessageReception.await(10, TimeUnit.SECONDS);
    // Let's disconnect from the subscription
    sub.unsubscribe();
    // Verification
    assertNull(callback.lastReceivedError, "expected no error, but received " + callback.lastReceivedError);
    assertNotNull(callback.lastReceivedMessage, "The subscription should have received a message");
}
Also used : GraphQLRequest(org.allGraphQLCases.client.util.GraphQLRequest) SubscriptionClient(com.graphql_java_generator.client.SubscriptionClient) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) SubscriptionCallbackToADate(org.allGraphQLCases.subscription.SubscriptionCallbackToADate) SubscriptionCallbackToADate(org.allGraphQLCases.subscription.SubscriptionCallbackToADate) Execution(org.junit.jupiter.api.parallel.Execution) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

SubscriptionClient (com.graphql_java_generator.client.SubscriptionClient)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 GraphQLRequest (org.allGraphQLCases.client.util.GraphQLRequest)1 SubscriptionCallbackToADate (org.allGraphQLCases.subscription.SubscriptionCallbackToADate)1 Test (org.junit.jupiter.api.Test)1 Execution (org.junit.jupiter.api.parallel.Execution)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1