|
14 | 14 | import java.util.stream.Collectors;
|
15 | 15 |
|
16 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
| 17 | +import static org.junit.jupiter.api.Assertions.assertNull; |
17 | 18 |
|
18 | 19 | class JakartaValidationDirectiveTest {
|
19 | 20 | @Test
|
@@ -44,12 +45,39 @@ void testJakartaSizeDirectiveArgumentDefinition() {
|
44 | 45 | }
|
45 | 46 |
|
46 | 47 | @Test
|
47 |
| - void testJakartaValidationIsApplied() { |
| 48 | + void testJakartaSizeValidationIsApplied() { |
48 | 49 | var name = "Roger";
|
49 | 50 | Map<String, String> response = execute("mutation setName($name: String!){setName(name: $name)} ", Map.of("name", name)).getData();
|
50 | 51 | var result = response.get("setName");
|
51 | 52 |
|
52 | 53 | assertEquals(name, result);
|
| 54 | + |
| 55 | + name = "Po"; |
| 56 | + response = execute("mutation setName($name: String!){setName(name: $name)} ", Map.of("name", name)).getData(); |
| 57 | + |
| 58 | + // TODO: response is currently null, I would expect it to return an error. |
| 59 | + assertNull(response); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + void testJakartaMinAndMaxValidationIsApplied() { |
| 64 | + var age = 4; |
| 65 | + Map<String, Integer> response = execute("mutation setAge($age: Int!){setAge(age: $age)} ", Map.of("age", age)).getData(); |
| 66 | + var result = response.get("setAge"); |
| 67 | + |
| 68 | + assertEquals(age, result); |
| 69 | + |
| 70 | + age = 2; |
| 71 | + response = execute("mutation setAge($age: int!){setAge(age: $age)} ", Map.of("age", age)).getData(); |
| 72 | + |
| 73 | + // TODO: response is currently null, I would expect it to return an error. |
| 74 | + assertNull(response); |
| 75 | + |
| 76 | + age = 100; |
| 77 | + response = execute("mutation setAge($age: int!){setAge(age: $age)} ", Map.of("age", age)).getData(); |
| 78 | + |
| 79 | + // TODO: response is currently null, I would expect it to return an error. |
| 80 | + assertNull(response); |
53 | 81 | }
|
54 | 82 |
|
55 | 83 | private ExecutionResult execute(String query, Map<String, Object> variables) {
|
|
0 commit comments