use of com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_partialRequest_mutation_withRequestName.
@SuppressWarnings("unchecked")
@Test
void testInvoke_partialRequest_mutation_withRequestName() throws NoSuchMethodException, SecurityException, GraphQLRequestExecutionException {
// Preparation
HumanInput input = new HumanInput();
Human h = Human.builder().withId("1").withHomePlanet("home planet").withName(" a name ").build();
doReturn(h).when(spyMutationExecutor).createHumanWithBindValues(any(ObjectResponse.class), any(HumanInput.class), any(Map.class));
// Go, go, go
Character verif = graphQLRepository.thisIsAMutation(input);
// Verification
assertEquals(h, verif);
assertEquals("{id name}", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "thisIsAMutation", HumanInput.class));
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRequest_fragmentTest method setup.
@BeforeEach
void setup() {
// Default configuration for GraphQLRequest
GraphQLRequest.setStaticConfiguration(new GraphQLConfiguration("http://localhost"));
// A useful init for some tests
input = new HumanInput();
input.setName("a new name");
List<Episode> episodes = new ArrayList<>();
episodes.add(Episode.JEDI);
episodes.add(Episode.EMPIRE);
episodes.add(Episode.NEWHOPE);
input.setAppearsIn(episodes);
params.put("humanInput", input);
params.put("value", "the mutation value");
params.put("anotherValue", "the other mutation value");
params.put("uppercaseFalse", false);
params.put("uppercaseTrue", true);
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRequest_allGraphQLCasesTest method setup.
@BeforeEach
void setup() {
input = new HumanInput();
input.setName("a new name");
List<Episode> episodes = new ArrayList<>();
episodes.add(Episode.JEDI);
episodes.add(Episode.EMPIRE);
episodes.add(Episode.NEWHOPE);
input.setAppearsIn(episodes);
params.put("humanInput", input);
params.put("value", "the mutation value");
params.put("anotherValue", "the other mutation value");
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractGraphQLRepositoryInvocationHandlerTest method testInvoke_partialRequest_mutation_withoutRequestName.
@SuppressWarnings("unchecked")
@Test
void testInvoke_partialRequest_mutation_withoutRequestName() throws NoSuchMethodException, SecurityException, GraphQLRequestExecutionException {
// Preparation
HumanInput input = new HumanInput();
Human h = Human.builder().withId("1").withHomePlanet("home planet").withName(" a name ").build();
doReturn(h).when(spyMutationExecutor).createHumanWithBindValues(any(ObjectResponse.class), any(HumanInput.class), any(Map.class));
// Go, go, go
Character verif = graphQLRepository.createHuman(input);
// Verification
assertEquals(h, verif);
assertEquals("{id}", GraphQLRepositoryTestHelper.getRegisteredGraphQLRequest(invocationHandler, GraphQLRepositoryTestCase.class, "createHuman", HumanInput.class));
}
use of com.graphql_java_generator.domain.client.allGraphQLCases.HumanInput 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