|
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertEquals; |
4 | 4 | import static org.junit.Assert.assertNotNull; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
5 | 6 |
|
6 | 7 | import com.fasterxml.jackson.databind.ObjectMapper; |
7 | 8 | import graphql.kickstart.spring.webclient.testapp.Simple; |
8 | | -import java.util.HashMap; |
9 | 9 | import java.util.Map; |
10 | 10 | import org.junit.jupiter.api.BeforeEach; |
11 | 11 | import org.junit.jupiter.api.DisplayName; |
@@ -47,23 +47,25 @@ void queryWithoutVariablesSucceeds() { |
47 | 47 | @Test |
48 | 48 | @DisplayName("Query echo with String variable and returning String") |
49 | 49 | void echoStringSucceeds() { |
50 | | - Map<String, Object> variables = new HashMap<>(); |
51 | | - variables.put("value", "echo echo echo"); |
52 | | - Mono<String> response = graphqlClient.post("query-echo.graphql", variables, String.class); |
| 50 | + Mono<String> response = graphqlClient.post("query-echo.graphql", Map.of("value", "echo echo echo"), String.class); |
53 | 51 | assertNotNull("response should not be null", response); |
54 | 52 | assertEquals("response should equal 'echo echo echo'", "echo echo echo", response.block()); |
55 | 53 | } |
56 | 54 |
|
57 | 55 | @Test |
58 | 56 | @DisplayName("Query simple return type") |
59 | 57 | void simpleTypeSucceeds() { |
60 | | - Map<String, Object> variables = new HashMap<>(); |
61 | | - variables.put("id", "my-id"); |
62 | | - Mono<Simple> response = graphqlClient.post("query-simple.graphql", variables, Simple.class); |
| 58 | + Mono<Simple> response = graphqlClient.post("query-simple.graphql", Map.of("id", "my-id"), Simple.class); |
63 | 59 | assertNotNull("response should not be null", response); |
64 | 60 | Simple object = response.block(); |
65 | 61 | assertNotNull(object); |
66 | 62 | assertEquals("response id should equal 'my-id'", "my-id", object.getId()); |
67 | 63 | } |
68 | 64 |
|
| 65 | + @Test |
| 66 | + void errorResponseSucceeds() { |
| 67 | + Mono<String> response = graphqlClient.post("error.graphql", String.class); |
| 68 | + assertThrows(GraphQLErrorsException.class, response::block); |
| 69 | + } |
| 70 | + |
69 | 71 | } |
0 commit comments