Skip to content

Commit c9f9e5f

Browse files
committed
fix tests
1 parent 7034121 commit c9f9e5f

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/test/java/GraphQLDirectivesTest.java renamed to src/test/java/graphql/annotations/GraphQLDirectivesTest.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
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

1630
import graphql.ExecutionResult;
1731
import graphql.GraphQL;
@@ -21,10 +35,11 @@
2135
import graphql.annotations.directives.AnnotationsWiringEnvironment;
2236
import graphql.annotations.directives.Directive;
2337
import graphql.annotations.processor.GraphQLAnnotations;
24-
import graphql.annotations.processor.ProcessingElementsContainer;
2538
import graphql.annotations.processor.exceptions.GraphQLAnnotationsException;
2639
import graphql.introspection.Introspection;
2740
import graphql.schema.*;
41+
import org.testng.annotations.BeforeClass;
42+
import org.testng.annotations.BeforeMethod;
2843
import org.testng.annotations.Test;
2944

3045
import java.util.Map;
@@ -38,6 +53,18 @@
3853

3954
public 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

Comments
 (0)