@Test(expectedExceptions = InvalidDirectiveLocationException.class) public void wireGraphQLInputObjectField_invalidLocations_exceptionIsThrown() throws Exception { // Arrange AnnotationsDirectiveWiring upperWiring = mock(AnnotationsDirectiveWiring.class); GraphQLInputObjectField directiveContainer = GraphQLInputObjectField.newInputObjectField().name("asdf") .type(GraphQLInputObjectType.newInputObject().name("dfdf").build()).build(); AnnotationsWiringEnvironmentImpl upperCaseEnv = new AnnotationsWiringEnvironmentImpl(directiveContainer, directiveContainer.getDirective("upperCase")); when(upperWiring.onInputObjectField(upperCaseEnv)).thenReturn(directiveContainer); HashMap<GraphQLDirective, AnnotationsDirectiveWiring> map = new HashMap<>(); GraphQLDirective upperCase = newDirective().name("upperCase").build(); map.put(upperCase, upperWiring); // Act directiveWirer.wire(directiveContainer, map); }
@Test public void wireGraphQLInputObjectField_validLocations_correctMethodIsCalled() throws Exception { // Arrange AnnotationsDirectiveWiring upperWiring = mock(AnnotationsDirectiveWiring.class); GraphQLInputObjectField directiveContainer = GraphQLInputObjectField.newInputObjectField().name("asdf") .type(GraphQLInputObjectType.newInputObject().name("dfdf").build()).build(); AnnotationsWiringEnvironmentImpl upperCaseEnv = new AnnotationsWiringEnvironmentImpl(directiveContainer, directiveContainer.getDirective("upperCase")); when(upperWiring.onInputObjectField(upperCaseEnv)).thenReturn(directiveContainer); HashMap<GraphQLDirective, AnnotationsDirectiveWiring> map = new HashMap<>(); GraphQLDirective upperCase = newDirective().name("upperCase").validLocations(Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION).build(); map.put(upperCase, upperWiring); // Act directiveWirer.wire(directiveContainer, map); // Assert verify(upperWiring).onInputObjectField(upperCaseEnv); }