use of com.graphql_java_generator.samples.forum.client.graphql.forum.client.TopicInput in project graphql-maven-plugin-project by graphql-java-generator.
the class Queries method getTopicInput.
/**
* A utility method to create the TopicInput Type, from its values
*/
default TopicInput getTopicInput(Board board, Member author, Date date, boolean publiclyAvailable, String title, String content) {
TopicInput input = new TopicInput();
input.setBoardId(board.getId());
input.setInput(getTopicPostInput(author, date, publiclyAvailable, title, content));
return input;
}
use of com.graphql_java_generator.samples.forum.client.graphql.forum.client.TopicInput in project graphql-maven-plugin-project by graphql-java-generator.
the class AbstractIT method testCreateTopicThenPostThenPosts.
@Test
void testCreateTopicThenPostThenPosts() throws GraphQLRequestPreparationException, GraphQLRequestExecutionException {
// Preparation
Calendar cal = Calendar.getInstance();
cal.clear();
// Month is 0-based, so this date is 2009, December the 20th
cal.set(2009, 11, 20);
List<Topic> before = queries.topicAuthorPostAuthor("Board name 3", cal.getTime());
TopicInput topicInput = new TopicInput();
topicInput.setBoardId(before.get(0).getId());
topicInput.setInput(getTopicPostInput(before.get(0).getAuthor(), "Some content", new GregorianCalendar(2009, 11 - 1, 20).getTime(), true, "The good title"));
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////// CHECK OF TOPIC CREATION
Topic topic = queries.createTopic(topicInput);
// Verification
assertNotNull(topic.getId());
assertEquals("Some content", topic.getContent());
assertEquals(new GregorianCalendar(2009, 11 - 1, 20).getTime(), topic.getDate());
assertEquals(true, topic.getPubliclyAvailable());
assertEquals("The good title", topic.getTitle());
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////// CHECK OF POST CREATION
// Preparation
PostInput postInput = new PostInput();
postInput.setTopicId(topic.getId());
postInput.setInput(getTopicPostInput(before.get(0).getAuthor(), "Some other content", new GregorianCalendar(2009, 11 - 1, 21).getTime(), false, "The good title for a post"));
// Go, go, go
Post post = queries.createPost(postInput);
// Verification
assertNotNull(post.getId());
assertEquals("Some other content", post.getContent());
assertEquals(new GregorianCalendar(2009, 11 - 1, 21).getTime(), post.getDate());
assertEquals(false, post.getPubliclyAvailable());
assertEquals("The good title for a post", post.getTitle());
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //////////////// CHECK OF POSTS (check the plural!) CREATION
// Preparation
List<PostInput> list = new ArrayList<>();
list.add(postInput);
// Go, go, go (the server always response with an exception: we'll check that this is the expected one)
GraphQLRequestExecutionException e = assertThrows(GraphQLRequestExecutionException.class, () -> queries.createPosts(list));
// Verification
assertTrue(e.getMessage().contains("Spamming is forbidden"));
}
Aggregations