use of com.generated.graphql.Human 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.Human 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.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_humanPartial.
@Test
void test_humanPartial() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// queryType.human("{appearsIn homePlanet name}", "45");
Human h = queries.humanPartial("00000000-0000-0000-0000-000000000045");
checkCharacter(h, "humanPartial", null, "Joruus C'Baoth", 0, Episode.EMPIRE);
assertEquals("Kashyyyk", h.getHomePlanet());
}
use of com.generated.graphql.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_humanFriendsFriendsFriends.
@Test
void test_humanFriendsFriendsFriends() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// queryType.human("{id appearsIn name friends {name friends {friends{id name
// appearsIn}}}}", "180");
Human h = queries.humanFriendsFriendsFriends("00000000-0000-0000-0000-000000000180");
checkCharacter(h, "testHeroFriendsFriendsFriends[friends_1]", "00000000-0000-0000-0000-000000000180", "Luke Skywalker", 2, Episode.EMPIRE);
assertNull(h.getHomePlanet());
// "94", "Mara Jade"
Character friends_0 = h.getFriends().get(0);
checkCharacter(friends_0, "testHeroFriendsFriendsFriends[friends_0]", null, "Mara Jade", 1);
//
// "180", "Luke Skywalker"
Character friends_0_0 = friends_0.getFriends().get(0);
checkCharacter(friends_0_0, "testHeroFriendsFriendsFriends[friends_0]", null, null, 2);
// "179", "Anakin Skywalker"
Character friends_1 = h.getFriends().get(1);
checkCharacter(friends_1, "testHeroFriendsFriendsFriends[friends_0]", null, "Anakin Skywalker", 1);
// "8", "Obi-Wan Kenobi"
Character friends_1_0 = friends_1.getFriends().get(0);
checkCharacter(friends_1_0, "testHeroFriendsFriendsFriends[friends_0]", null, null, 4);
}
use of com.generated.graphql.Human in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_humanFull.
@Test
void test_humanFull() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// queryType.human("{id appearsIn homePlanet name}", "45");
Human h = queries.humanFull("00000000-0000-0000-0000-000000000045");
checkCharacter(h, "testHeroFriendsFriendsFriends[friends_1_0]", "00000000-0000-0000-0000-000000000045", "Joruus C'Baoth", 0, Episode.EMPIRE);
assertEquals("Kashyyyk", h.getHomePlanet());
}
Aggregations