use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_heroPartial.
@Test
void test_heroPartial() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// return queryType.hero("{id appearsIn name}", Episode.NEWHOPE);
Character c = queries.heroPartial(Episode.NEWHOPE);
checkCharacter(c, "heroSimple", null, "BB-8", 0, Episode.NEWHOPE);
}
use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_heroFriendsFriendsFriends.
@Test
void test_heroFriendsFriendsFriends() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// return queryType.hero("{id appearsIn friends {name friends {friends{id name
// appearsIn}}}}", Episode.NEWHOPE);
Character c = queries.heroFriendsFriendsFriends(Episode.NEWHOPE);
checkCharacter(c, "testHeroFriendsFriendsFriends", "00000000-0000-0000-0000-000000000002", null, 2, Episode.NEWHOPE);
Character friends_0 = c.getFriends().get(0);
checkCharacter(friends_0, "testHeroFriendsFriendsFriends[friends_0]", null, "Poe Dameron", 0);
Character friends_1 = c.getFriends().get(1);
checkCharacter(friends_1, "testHeroFriendsFriendsFriends[friends_1]", null, "Luke Skywalker", 2);
// "94", "Mara Jade"
Character friends_1_0 = friends_1.getFriends().get(0);
checkCharacter(friends_1_0, "testHeroFriendsFriendsFriends[friends_1_0]", null, null, 1);
Character friends_1_0_0 = friends_1_0.getFriends().get(0);
checkCharacter(friends_1_0_0, "testHeroFriendsFriendsFriends[friends_1_0]", "00000000-0000-0000-0000-000000000180", "Luke Skywalker", 0, Episode.EMPIRE);
// "179", "Anakin Skywalker"
Character friends_1_1 = friends_1.getFriends().get(1);
checkCharacter(friends_1_1, "testHeroFriendsFriendsFriends[friends_1_0]", null, null, 1);
Character friends_1_1_0 = friends_1_1.getFriends().get(0);
checkCharacter(friends_1_1_0, "testHeroFriendsFriendsFriends[friends_1_0]", "00000000-0000-0000-0000-000000000008", "Obi-Wan Kenobi", 0, Episode.NEWHOPE);
}
use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_addFriend.
@Test
void test_addFriend() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Preparation
String idMaceWindu = "00000000-0000-0000-0000-000000000224";
Human maceWindu = queries.humanFriendsFriendsFriends(idMaceWindu);
int nbBefore = (maceWindu.getFriends() == null) ? 0 : maceWindu.getFriends().size();
//
List<Character> chars = queryType.characters("{id name friends{id name}}", null);
int idFriend = (int) (Math.random() * chars.size());
Character friend = chars.get(idFriend);
// Go, go, go
Character characterAfter = queries.addFriend(idMaceWindu, friend.getId());
// Verification
assertNotNull(maceWindu);
assertNotNull(characterAfter);
assertNotNull(characterAfter.getFriends());
assertEquals(nbBefore + 1, characterAfter.getFriends().size());
// The new friend should be somewhere in the list
boolean found = false;
for (Character c : characterAfter.getFriends()) {
if (c.getId().equals(friend.getId())) {
found = true;
break;
}
}
assertTrue(found, "We should have found the new friend");
}
use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_createHuman.
@Test
void test_createHuman() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// Preparation
List<Character> charactersBefore = queryType.characters("{id name}", null);
// Go, go, go
Human human = queries.createHuman("A name", "a planet");
// Verification
assertNotNull(human.getId());
assertEquals("A name", human.getName());
assertEquals("a planet", human.getHomePlanet());
//
List<Character> charactersAfter = queryType.characters("{id name }", null);
assertEquals(charactersBefore.size() + 1, charactersAfter.size());
// The last character should be the new one
Character lastCharacter = charactersAfter.get(charactersAfter.size() - 1);
assertEquals("A name", lastCharacter.getName());
assertEquals(human.getId(), lastCharacter.getId());
}
use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_droidFriendsFriendsFriends.
@Test
void test_droidFriendsFriendsFriends() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// droid("{id appearsIn name friends {name friends {friends{id name appearsIn}}}
// primaryFunction }", "2");
Droid d = queries.droidFriendsFriendsFriends("00000000-0000-0000-0000-000000000002");
checkCharacter(d, "testDroidFriendsFriendsFriends", "00000000-0000-0000-0000-000000000002", "BB-8", 2, Episode.NEWHOPE);
assertEquals("Function of BB-8", d.getPrimaryFunction());
// "52", "Poe Dameron"
Character friends_0 = d.getFriends().get(0);
checkCharacter(friends_0, "testDroidFriendsFriendsFriends[friends_0]", null, "Poe Dameron", 0);
// "180", "Luke Skywalker"
Character friends_1 = d.getFriends().get(1);
checkCharacter(friends_1, "testDroidFriendsFriendsFriends[friends_1]", null, "Luke Skywalker", 2);
}
Aggregations