Skip to content

Commit 4d625b6

Browse files
committed
Fix the tests
1 parent 0b984e8 commit 4d625b6

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

graphql-builder/src/main/java/com/phocassoftware/graphql/builder/MethodProcessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class MethodProcessor {
4444
private final GraphQLObjectType.Builder graphMutations;
4545
private final GraphQLObjectType.Builder graphSubscriptions;
4646

47-
public MethodProcessor(DataFetcherRunner dataFetcherRunner, EntityProcessor entityProcessor, DirectivesSchema diretives) {
47+
public MethodProcessor(DataFetcherRunner dataFetcherRunner, EntityProcessor entityProcessor, DirectivesSchema directives) {
4848
this.dataFetcherRunner = dataFetcherRunner;
4949
this.entityProcessor = entityProcessor;
50-
this.directives = diretives;
50+
this.directives = directives;
5151
this.codeRegistry = GraphQLCodeRegistry.newCodeRegistry();
5252

5353
this.graphQuery = GraphQLObjectType.newObject();
@@ -58,7 +58,7 @@ public MethodProcessor(DataFetcherRunner dataFetcherRunner, EntityProcessor enti
5858
graphSubscriptions.name("Subscriptions");
5959
}
6060

61-
void process(AuthorizerSchema authorizer, Method method) throws ReflectiveOperationException {
61+
void process(AuthorizerSchema authorizer, Method method) {
6262
if (!Modifier.isStatic(method.getModifiers())) {
6363
throw new RuntimeException("End point must be a static method");
6464
}

graphql-builder/src/test/java/com/phocassoftware/graphql/builder/JakartaValidationDirectiveTest.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class JakartaValidationDirectiveTest {
1919
@Test
2020
void testJakartaSizeAnnotationAddedAsDirective() {
21-
GraphQL schema = GraphQL.newGraphQL(SchemaBuilder.build("com.fleetpin.graphql.builder.type.directive")).build();
21+
GraphQL schema = GraphQL.newGraphQL(SchemaBuilder.build("com.phocassoftware.graphql.builder.type.directive")).build();
2222
var name = schema.getGraphQLSchema().getFieldDefinition(FieldCoordinates.coordinates(schema.getGraphQLSchema().getMutationType(), "setName"));
2323
var directive = name.getArgument("name").getAppliedDirective("Size");
2424
var argument = directive.getArgument("min");
@@ -28,7 +28,7 @@ void testJakartaSizeAnnotationAddedAsDirective() {
2828

2929
@Test
3030
void testJakartaSizeDirectiveArgumentDefinition() {
31-
Map<String, Object> response = execute("query IntrospectionQuery { __schema { directives { name locations args { name } } } }").getData();
31+
Map<String, Object> response = execute("query IntrospectionQuery { __schema { directives { name locations args { name } } } }", null).getData();
3232
List<LinkedHashMap<String, Object>> dir = (List<LinkedHashMap<String, Object>>) ((Map<String, Object>) response.get("__schema")).get("directives");
3333
LinkedHashMap<String, Object> constraint = dir.stream().filter(map -> map.get("name").equals("Size")).collect(Collectors.toList()).get(0);
3434

@@ -43,12 +43,24 @@ void testJakartaSizeDirectiveArgumentDefinition() {
4343
assertEquals("{name=groups}", ((List<Object>) constraint.get("args")).get(4).toString());
4444
}
4545

46-
private ExecutionResult execute(String query) {
47-
GraphQLSchema preSchema = SchemaBuilder.builder().classpath("com.fleetpin.graphql.builder.type.directive").build().build();
46+
@Test
47+
void testJakartaValidationIsApplied() {
48+
var name = "Roger";
49+
Map<String, String> response = execute("mutation setName($name: String!){setName(name: $name)} ", Map.of("name", name)).getData();
50+
var result = response.get("setName");
51+
52+
assertEquals(name, result);
53+
}
54+
55+
private ExecutionResult execute(String query, Map<String, Object> variables) {
56+
GraphQLSchema preSchema = SchemaBuilder.builder().classpath("com.phocassoftware.graphql.builder.type.directive").build().build();
4857
GraphQL schema = GraphQL.newGraphQL(new IntrospectionWithDirectivesSupport().apply(preSchema)).build();
4958

5059
var input = ExecutionInput.newExecutionInput();
5160
input.query(query);
61+
if (variables != null) {
62+
input.variables(variables);
63+
}
5264
return schema.execute(input);
5365
}
5466
}

0 commit comments

Comments
 (0)