1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 */
15+ package graphql .annotations ; /**
16+ * Copyright 2016 Yurii Rashkovskii
17+ * <p>
18+ * Licensed under the Apache License, Version 2.0 (the "License");
19+ * you may not use this file except in compliance with the License.
20+ * You may obtain a copy of the License at
21+ * <p>
22+ * http://www.apache.org/licenses/LICENSE-2.0
23+ * <p>
24+ * Unless required by applicable law or agreed to in writing, software
25+ * distributed under the License is distributed on an "AS IS" BASIS,
26+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27+ * See the License for the specific language governing permissions and
28+ */
1529
1630import graphql .ExecutionResult ;
1731import graphql .GraphQL ;
2135import graphql .annotations .directives .AnnotationsWiringEnvironment ;
2236import graphql .annotations .directives .Directive ;
2337import graphql .annotations .processor .GraphQLAnnotations ;
24- import graphql .annotations .processor .ProcessingElementsContainer ;
2538import graphql .annotations .processor .exceptions .GraphQLAnnotationsException ;
2639import graphql .introspection .Introspection ;
2740import graphql .schema .*;
41+ import org .testng .annotations .BeforeClass ;
42+ import org .testng .annotations .BeforeMethod ;
2843import org .testng .annotations .Test ;
2944
3045import java .util .Map ;
3853
3954public class GraphQLDirectivesTest {
4055
56+ @ BeforeClass
57+ public static void setUp () throws Exception {
58+ GraphQLAnnotations .getInstance ().getTypeRegistry ().clear ();
59+ }
60+
61+ @ BeforeMethod
62+ public void init () {
63+ GraphQLAnnotations .getInstance ().getTypeRegistry ().clear ();
64+ GraphQLAnnotations .getInstance ().getContainer ().getDirectiveRegistry ().clear ();
65+ }
66+
67+
4168 public static class UpperWiring implements AnnotationsDirectiveWiring {
4269 @ Override
4370 public GraphQLFieldDefinition onField (AnnotationsWiringEnvironment <GraphQLFieldDefinition > environment ) {
@@ -102,7 +129,6 @@ public static String name() {
102129
103130 @ Test (expectedExceptions = GraphQLAnnotationsException .class )
104131 public void queryName_noDirectivesProvidedToRegistry_exceptionIsThrown () throws Exception {
105- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
106132 GraphQLObjectType object = GraphQLAnnotations .object (Query .class );
107133 GraphQLSchema schema = newSchema ().query (object ).build ();
108134
@@ -111,7 +137,6 @@ public void queryName_noDirectivesProvidedToRegistry_exceptionIsThrown() throws
111137
112138 @ Test
113139 public void queryName_directivesProvidedToRegistry_wiringIsActivated () throws Exception {
114- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
115140 GraphQLDirective upperCase = newDirective ().name ("upperCase" ).argument (builder -> builder .name ("isActive" ).type (GraphQLBoolean ))
116141 .validLocations (Introspection .DirectiveLocation .FIELD_DEFINITION ).build ();
117142 GraphQLObjectType object = GraphQLAnnotations .object (Query .class , upperCase );
@@ -124,7 +149,6 @@ public void queryName_directivesProvidedToRegistry_wiringIsActivated() throws Ex
124149
125150 @ Test
126151 public void queryNameWithFalse_directivesProvidedToRegistry_wiringIsActivated () throws Exception {
127- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
128152 GraphQLDirective upperCase = newDirective ().name ("upperCase" ).argument (builder -> builder .name ("isActive" ).type (GraphQLBoolean ))
129153 .validLocations (Introspection .DirectiveLocation .FIELD_DEFINITION ).build ();
130154 GraphQLObjectType object = GraphQLAnnotations .object (Query .class , upperCase );
@@ -137,7 +161,6 @@ public void queryNameWithFalse_directivesProvidedToRegistry_wiringIsActivated()
137161
138162 @ Test
139163 public void queryNameWithNoArgs_directivesProvidedToRegistry_wiringIsActivated () throws Exception {
140- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
141164 GraphQLDirective upperCase = newDirective ().name ("upperCase" ).argument (builder -> builder .name ("isActive" ).type (GraphQLBoolean ).defaultValue (true ))
142165 .validLocations (Introspection .DirectiveLocation .FIELD_DEFINITION ).build ();
143166 GraphQLObjectType object = GraphQLAnnotations .object (Query2 .class , upperCase );
@@ -150,8 +173,6 @@ public void queryNameWithNoArgs_directivesProvidedToRegistry_wiringIsActivated()
150173
151174 @ Test (expectedExceptions = NullPointerException .class )
152175 public void queryNameWithNoArgs_noDefaultValue_exceptionIsThrown () throws Exception {
153- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
154- GraphQLAnnotations .getInstance ().getContainer ().getDirectiveRegistry ().clear ();
155176 GraphQLDirective upperCase = newDirective ().name ("upperCase" ).argument (builder -> builder .name ("isActive" ).type (GraphQLBoolean ))
156177 .validLocations (Introspection .DirectiveLocation .FIELD_DEFINITION ).build ();
157178 GraphQLObjectType object = GraphQLAnnotations .object (Query2 .class , upperCase );
@@ -162,7 +183,6 @@ public void queryNameWithNoArgs_noDefaultValue_exceptionIsThrown() throws Except
162183
163184 @ Test
164185 public void queryName_chainedDirectives_wiringIsActivatedInCorrectOrder () throws Exception {
165- GraphQLAnnotations .getInstance ().setContainer (new ProcessingElementsContainer ());
166186 GraphQLDirective upperCase = newDirective ().name ("upperCase" ).argument (builder -> builder .name ("isActive" ).type (GraphQLBoolean ).defaultValue (true ))
167187 .validLocations (Introspection .DirectiveLocation .FIELD_DEFINITION ).build ();
168188 GraphQLDirective suffixDirective = GraphQLDirective .newDirective ().name ("suffix" ).argument (builder -> builder .name ("suffix" ).type (GraphQLString ))
0 commit comments