use of com.graphql_java_generator.domain.client.allGraphQLCases.AnotherMutationTypeResponse in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_fullRequest_mutation.
@SuppressWarnings("unchecked")
@Test
void testInvoke_fullRequest_mutation() throws GraphQLRequestExecutionException, NoSuchMethodException, SecurityException {
// Preparation
AnotherMutationTypeResponse mutation = new AnotherMutationTypeResponse();
HumanInput input = HumanInput.builder().withName("the name").withAppearsIn(Arrays.asList(Episode.JEDI, Episode.NEWHOPE)).build();
doReturn(mutation).when(spyMutationExecutor).execWithBindValues(any(ObjectResponse.class), any(Map.class));
// Go, go, go
AnotherMutationType verif = graphQLRepository.fullRequestMutation(input);
// Verification
assertEquals(mutation, verif);
ArgumentCaptor<Map<String, Object>> bindParamsCaptor = ArgumentCaptor.forClass(Map.class);
verify(spyMutationExecutor).execWithBindValues(any(ObjectResponse.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("input"));
// Mockito changes the List<Object[]> objects to a List<String> at runtime:
assertEquals(input, params.get(0).get("input"));
assertEquals("mutation($input: HumanInput!) {createHuman(human: $input) {id name }}", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "fullRequestMutation", HumanInput.class));
}
Aggregations