15
15
16
16
import static org .junit .jupiter .api .Assertions .assertEquals ;
17
17
18
- public class JakartaValidationDirectiveTest {
18
+ class JakartaValidationDirectiveTest {
19
19
@ Test
20
- public void testJakartaArgumentAnnotationChangedToConstraint () {
20
+ void testJakartaArgumentAnnotationChangedToConstraint () {
21
21
GraphQL schema = GraphQL .newGraphQL (SchemaBuilder .build ("com.fleetpin.graphql.builder.type.directive" )).build ();
22
22
var name = schema .getGraphQLSchema ().getFieldDefinition (FieldCoordinates .coordinates (schema .getGraphQLSchema ().getMutationType (), "setName" ));
23
23
var constraint = name .getArgument ("name" ).getAppliedDirective ("Size" );
@@ -27,29 +27,28 @@ public void testJakartaArgumentAnnotationChangedToConstraint() {
27
27
}
28
28
29
29
@ Test
30
- public void testDirectiveArgumentDefinition () {
31
- Map <String , Object > response = execute ("query IntrospectionQuery { __schema { directives { name locations args { name } } } }" , null ).getData ();
30
+ void testDirectiveArgumentDefinition () {
31
+ Map <String , Object > response = execute ("query IntrospectionQuery { __schema { directives { name locations args { name } } } }" ).getData ();
32
32
List <LinkedHashMap <String , Object >> dir = (List <LinkedHashMap <String , Object >>) ((Map <String , Object >) response .get ("__schema" )).get ("directives" );
33
33
LinkedHashMap <String , Object > constraint = dir .stream ().filter (map -> map .get ("name" ).equals ("Size" )).collect (Collectors .toList ()).get (0 );
34
34
35
35
assertEquals (9 , dir .size ());
36
36
assertEquals ("ARGUMENT_DEFINITION" , ((List <String >) constraint .get ("locations" )).get (0 ));
37
- assertEquals (1 , ((List <Object >) constraint .get ("args" )).size ());
38
- assertEquals ("{name=validatedBy}" , ((List <Object >) constraint .get ("args" )).getFirst ().toString ());
39
- //setName(name: String! @Size(min : 3)): Int!
40
- //directive @Constraint(name: String!) on ARGUMENT_DEFINITION
37
+ assertEquals ("INPUT_FIELD_DEFINITION" , ((List <String >) constraint .get ("locations" )).get (1 ));
38
+ assertEquals (5 , ((List <Object >) constraint .get ("args" )).size ());
39
+ assertEquals ("{name=payload}" , ((List <Object >) constraint .get ("args" )).getFirst ().toString ());
40
+ assertEquals ("{name=min}" , ((List <Object >) constraint .get ("args" )).get (1 ).toString ());
41
+ assertEquals ("{name=max}" , ((List <Object >) constraint .get ("args" )).get (2 ).toString ());
42
+ assertEquals ("{name=message}" , ((List <Object >) constraint .get ("args" )).get (3 ).toString ());
43
+ assertEquals ("{name=groups}" , ((List <Object >) constraint .get ("args" )).get (4 ).toString ());
41
44
}
42
45
43
- private ExecutionResult execute (String query , Map < String , Object > variables ) {
46
+ private ExecutionResult execute (String query ) {
44
47
GraphQLSchema preSchema = SchemaBuilder .builder ().classpath ("com.fleetpin.graphql.builder.type.directive" ).build ().build ();
45
48
GraphQL schema = GraphQL .newGraphQL (new IntrospectionWithDirectivesSupport ().apply (preSchema )).build ();
46
49
47
50
var input = ExecutionInput .newExecutionInput ();
48
51
input .query (query );
49
- if (variables != null ) {
50
- input .variables (variables );
51
- }
52
- ExecutionResult result = schema .execute (input );
53
- return result ;
52
+ return schema .execute (input );
54
53
}
55
54
}
0 commit comments