Created
April 12, 2021 20:40
-
-
Save dannyshain/ad4c6d7fc4d025b5dfcf77877333ef7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void addUser_checkReturnedData_shouldCorrespondToDataSent() { | |
GraphQLQuery query = new GraphQLQuery(); | |
query.setQuery("mutation insert_users ($id: uuid!, $name: String!, $rocket: String!) { insert_users(objects: {id: $id, name: $name, rocket: $rocket}) { returning { id name rocket } } }"); | |
User myUser = new User( | |
UUID.randomUUID(), | |
"Bas", | |
"My awesome rocket" | |
); | |
query.setVariables(myUser); | |
given(). | |
contentType(ContentType.JSON). | |
body(query). | |
when(). | |
post("https://api.spacex.land/graphql/"). | |
then(). | |
assertThat(). | |
statusCode(200). | |
and(). | |
body("data.insert_users.returning[0].id", equalTo(myUser.getId().toString())). | |
body("data.insert_users.returning[0].name", equalTo(myUser.getName())). | |
body("data.insert_users.returning[0].rocket", equalTo(myUser.getRocket())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment