use of org.allGraphQLCases.client.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class FullQueriesIT method test_Issue65_withGraphQLValuedParameter.
@Test
@Execution(ExecutionMode.CONCURRENT)
void test_Issue65_withGraphQLValuedParameter() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException {
// Preparation
String request = //
"mutation mut1 {" + //
"createHuman (human: {name: \"a name with a string that contains a \\\", two { { and a } \", friends: [], appearsIn: [JEDI,NEWHOPE]} )" + "@testDirective(value:?value, anotherValue:?anotherValue, anArray : [ \"a string that contains [ [ and ] that should be ignored\" , \"another string\" ] , \r\n" + "anObject:{ name: \"a name\" , appearsIn:[],friends : [{name:\"subname\",appearsIn:[],type:\"\"}],type:\"type\"}) {id name appearsIn friends {id name}}}";
GraphQLRequest graphQLRequest = new GraphQLRequest(request);
// Go, go, go
Human human = mutationType.execWithBindValues(graphQLRequest, null).getCreateHuman();
// Verifications
assertEquals("a name with a string that contains a \", two { { and a } ", human.getName());
}
use of org.allGraphQLCases.client.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class GraphQLVariablesIT method mutation.
@Execution(ExecutionMode.CONCURRENT)
@Test
void mutation() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Preparation
GraphQLRequest mutationWithDirectiveRequest = mutationType.getGraphQLRequest(//
"" + //
"mutation creation($name : String!, $friends : [ CharacterInput\r\n] , $appearsIn: [Episode]!,$uppercaseName:Boolean)\r\n" + //
"{createHuman (human: {name:$name, friends:$friends, appearsIn:$appearsIn}) " + //
"{id name(uppercase: $uppercaseName) appearsIn friends {id friends appearsIn name}}}");
CharacterInput friendsParam = CharacterInput.builder().withName("a friend's name").withAppearsIn(Arrays.asList(Episode.NEWHOPE)).withType("Human").build();
// Go, go, go
AnotherMutationType resp = //
mutationWithDirectiveRequest.execMutation(//
"name", //
"a new name", //
"appearsIn", //
Arrays.asList(Episode.JEDI, Episode.EMPIRE, Episode.NEWHOPE), //
"uppercaseName", //
true, "friends", friendsParam);
// Verifications
assertNotNull(resp);
Human human = resp.getCreateHuman();
assertNotNull(human);
assertEquals("A NEW NAME", human.getName());
assertEquals(3, human.getAppearsIn().size());
assertEquals(Episode.JEDI, human.getAppearsIn().get(0));
assertEquals(Episode.EMPIRE, human.getAppearsIn().get(1));
assertEquals(Episode.NEWHOPE, human.getAppearsIn().get(2));
}
use of org.allGraphQLCases.client.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class AliasesIT method test_subscription.
@Execution(ExecutionMode.CONCURRENT)
@Test
public void test_subscription() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException, InterruptedException {
// Preparation
HumanSubscriptionCallback callback = new HumanSubscriptionCallback();
// Go, go, go
SubscriptionClient sub = subscriptionExecutor.subscribeNewHumanForEpisode(//
"{aliasId:id id aliasName:name name aliasHomePlanet:homePlanet homePlanet}", callback, Episode.JEDI);
// Let's wait a max of 10 second, until we receive some notifications
waitForEvent(100, () -> {
return callback.lastReceivedMessage != null || callback.lastError != null;
}, "Waiting for the subscription to receive the notification");
// Let's disconnect from the subscription
sub.unsubscribe();
// Verification
if (callback.lastError != null) {
fail("The subsccription raised this error: " + callback.lastError);
}
assertNotNull(callback.lastReceivedMessage);
assertTrue(callback.lastReceivedMessage instanceof Human);
Human verif = callback.lastReceivedMessage;
assertEquals(verif.getId(), verif.getAliasValue("aliasId"));
assertEquals(verif.getName(), verif.getAliasValue("aliasName"));
assertEquals(verif.getHomePlanet(), verif.getAliasValue("aliasHomePlanet"));
}
use of org.allGraphQLCases.client.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class FragmentIT method test_InlineAndGlobalFragments_withOneOptionalParam_Human.
@Execution(ExecutionMode.CONCURRENT)
@Test
void test_InlineAndGlobalFragments_withOneOptionalParam_Human() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException {
// Preparation
GraphQLRequest graphQLRequest = myQuery.getGraphQLRequest(//
"" + //
"query{" + //
" withOneOptionalParam(character: &input){" + //
" appearsIn " + //
" ...id " + //
" ... on Character { ...id } " + //
" ... on Droid { primaryFunction ... on Character {name(uppercase: ?notDefinedBindVariable) friends {name}} } " + //
" ... on Human { homePlanet ... on Human { ... on Character { name(uppercase: ?notDefinedBindVariable)}} } " + //
" } " + //
"} " + //
"fragment id on Character {id} ");
input.setType("Human");
// Go, go, go
Character withOneOptionalParam = graphQLRequest.execQuery(params).getWithOneOptionalParam();
// Verification
assertNotNull(withOneOptionalParam);
assertTrue(withOneOptionalParam instanceof Human, "we've ask for thas in input's type");
assertEquals("Human", withOneOptionalParam.get__typename());
assertTrue(withOneOptionalParam instanceof Human);
assertNotNull(withOneOptionalParam.getAppearsIn());
assertNotNull(withOneOptionalParam.getId());
assertNull(withOneOptionalParam.getFriends(), "friends have been requested onyl for droids");
assertNotNull(withOneOptionalParam.getName(), "name has been requested in inline fragment for human");
assertNotNull(((Human) withOneOptionalParam).getHomePlanet(), "homePlanet is requested for humans");
}
use of org.allGraphQLCases.client.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class FullQueriesDeprecatedIT method mutation.
@Execution(ExecutionMode.CONCURRENT)
@Test
void mutation() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Preparation
HumanInput 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);
// //////////////////////////////////////////////////////////////////////////////////////////////
// WITHOUT DIRECTIVE
// Go, go, go
AnotherMutationTypeResponse resp = mutationType.exec(mutationWithoutDirectiveResponse, "humanInput", input);
// Verifications
assertNotNull(resp);
Human ret = resp.getCreateHuman();
assertNotNull(ret);
assertEquals("a new name", ret.getName());
// //////////////////////////////////////////////////////////////////////////////////////////////
// WITH DIRECTIVE
// Go, go, go
resp = //
mutationType.exec(//
mutationWithDirectiveResponse, //
"humanInput", //
input, //
"value", //
"the mutation value", "anotherValue", "the other mutation value");
// Verifications
assertNotNull(resp);
ret = resp.getCreateHuman();
assertNotNull(ret);
assertEquals("the other mutation value", ret.getName());
}
Aggregations