use of com.graphql_java_generator.client.SubscriptionClientReactiveImpl in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_fullRequest_subscription.
@SuppressWarnings("unchecked")
@Test
@Disabled
void testInvoke_fullRequest_subscription() throws GraphQLRequestExecutionException, NoSuchMethodException, SecurityException {
// Preparation
Date date = new Calendar.Builder().setDate(2021, 6 - 1, 18).build().getTime();
// This would be invalid in real use. Null is just for this test
SubscriptionCallback<Date> callback = null;
SubscriptionClient client = new SubscriptionClientReactiveImpl(null, null);
doReturn(client).when(spySubscriptionExecutor).execWithBindValues(any(ObjectResponse.class), any(SubscriptionCallback.class), any(Map.class));
// Go, go, go
graphQLRepository.fullSubscription(callback, date);
// Verification
assertNotNull(client);
ArgumentCaptor<Map<String, Object>> bindParamsCaptor = ArgumentCaptor.forClass(Map.class);
verify(spySubscriptionExecutor).execWithBindValues(any(ObjectResponse.class), any(SubscriptionCallback.class), bindParamsCaptor.capture());
List<Map<String, Object>> params = bindParamsCaptor.getAllValues();
assertEquals(1, params.size(), "one invocation");
assertEquals(1, params.get(0).keySet().size(), "one parameter");
//
assertTrue(params.get(0).keySet().contains("date"));
// Mockito changes the List<Object[]> objects to a List<String> at runtime:
assertEquals(date, params.get(0).get("date"));
assertEquals("subscription {issue53(date: &date) {}}", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "fullSubscription", SubscriptionCallback.class, Date.class));
}
use of com.graphql_java_generator.client.SubscriptionClientReactiveImpl in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_partialRequest_subscription.
@SuppressWarnings("unchecked")
@Test
void testInvoke_partialRequest_subscription() throws GraphQLRequestExecutionException, NoSuchMethodException, SecurityException {
// Preparation
SubscriptionCallback<Human> callback = new SubscriptionCallback<Human>() {
@Override
public void onConnect() {
}
@Override
public void onMessage(Human t) {
}
@Override
public void onClose(int statusCode, String reason) {
}
@Override
public void onError(Throwable cause) {
}
};
Episode episode = Episode.JEDI;
SubscriptionClient subscriptionClient = new SubscriptionClientReactiveImpl(null, null);
doReturn(subscriptionClient).when(spySubscriptionExecutor).subscribeNewHumanForEpisodeWithBindValues(any(ObjectResponse.class), any(SubscriptionCallback.class), any(Episode.class), any(Map.class));
// Go, go, go
SubscriptionClient verif = graphQLRepository.subscribeNewHumanForEpisode(callback, episode);
// Verification
assertEquals(subscriptionClient, verif);
assertEquals("{ id appearsIn }", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "subscribeNewHumanForEpisode", SubscriptionCallback.class, Episode.class));
}
Aggregations