use of com.generated.graphql.Character 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.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method test_heroFull.
@Test
void test_heroFull() throws GraphQLRequestExecutionException, GraphQLRequestPreparationException {
// return queryType.hero("{id appearsIn name}", Episode.NEWHOPE);
Character c = queries.heroFull();
checkCharacter(c, "heroSimple", "00000000-0000-0000-0000-000000000001", "Bala-Tik", 0, Episode.JEDI);
}
use of com.generated.graphql.Character in project graphql-maven-plugin-project by graphql-java-generator.
the class SubscriptionIT method testSubscription.
@Test
@Execution(ExecutionMode.CONCURRENT)
void testSubscription() throws GraphQLRequestExecutionException, InterruptedException, ExecutionException {
// Preparation
CharacterSubscriptionCallback callback = new CharacterSubscriptionCallback();
// Go, go, go
logger.debug("Subscribing to the GraphQL subscription");
SubscriptionClient client = subscriptionType.newCharacter(subscriptionRequest, callback);
// Let's wait 1 seconds max, that the web socket is properly connected
try {
// Wait 1s
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.debug("Got interrupted (1)");
}
logger.debug("Creating the post, for which we should receice the notification");
CompletableFuture<Character> createdPostASync = CompletableFuture.supplyAsync(() -> {
try {
// But we wait as little as possible
for (int i = 0; i < 100; i += 1) {
Thread.sleep(10);
if (callback.connected)
break;
}
return mutationType.createHuman(createHumanRequest, "new name", "new home planet");
} catch (GraphQLRequestExecutionException | InterruptedException e) {
throw new RuntimeException(e.getMessage(), e);
}
});
// (see the callback implementation in the CharacterSubscriptionCallback class)
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException e) {
logger.debug("Got interrupted (2)");
}
// Verification
assertNull(callback.lastReceivedClose, "We should have received no close message (" + callback.lastReceivedClose + ")");
assertNull(callback.lastReceivedError, "We should have received no error (" + callback.lastReceivedError + ")");
assertNotNull(callback.lastReceivedMessage, "We should have received a post");
Character createdCharacter = createdPostASync.get();
assertTrue(createdCharacter instanceof Human);
assertEquals(createdCharacter.getId(), callback.lastReceivedMessage.getId(), "Is it 'our' new Character?");
assertEquals("new home planet", ((Human) callback.lastReceivedMessage).getHomePlanet(), "Check of the fragment behavior");
// We must free the server resource at the end
client.unsubscribe();
logger.debug("Stopped listening");
}
Aggregations