55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,8 +35,7 @@ public class GraphQLExtensionsTest {
3535 @ GraphQLName ("TestObject" )
3636 public static class TestObject {
3737 @ GraphQLField
38- public
39- String field () {
38+ public String field () {
4039 return "test" ;
4140 }
4241
@@ -88,15 +87,16 @@ public String getField() {
8887 public static class TestDataFetcher implements DataFetcher {
8988 @ Override
9089 public Object get (DataFetchingEnvironment environment ) {
91- return ((TestObject )environment .getSource ()).field () + " test3" ;
90+ return ((TestObject ) environment .getSource ()).field () + " test3" ;
9291 }
9392 }
9493
9594 @ Test
9695 public void fields () {
97- GraphQLAnnotations .getInstance ().registerTypeExtension (TestObjectExtension .class );
98- GraphQLObjectType object = GraphQLAnnotations .object (GraphQLExtensionsTest .TestObject .class );
99- GraphQLAnnotations .getInstance ().unregisterTypeExtension (TestObjectExtension .class );
96+ GraphQLAnnotations instance = new GraphQLAnnotations ();
97+ instance .registerTypeExtension (TestObjectExtension .class );
98+ GraphQLObjectType object = instance .getObject (GraphQLExtensionsTest .TestObject .class );
99+ instance .unregisterTypeExtension (TestObjectExtension .class );
100100
101101 List <GraphQLFieldDefinition > fields = object .getFieldDefinitions ();
102102 assertEquals (fields .size (), 5 );
@@ -112,9 +112,10 @@ public void fields() {
112112
113113 @ Test
114114 public void values () {
115- GraphQLAnnotations .getInstance ().registerTypeExtension (TestObjectExtension .class );
116- GraphQLObjectType object = GraphQLAnnotations .object (GraphQLExtensionsTest .TestObject .class );
117- GraphQLAnnotations .getInstance ().unregisterTypeExtension (TestObjectExtension .class );
115+ GraphQLAnnotations instance = new GraphQLAnnotations ();
116+ instance .registerTypeExtension (TestObjectExtension .class );
117+ GraphQLObjectType object = instance .getObject (GraphQLExtensionsTest .TestObject .class );
118+ instance .unregisterTypeExtension (TestObjectExtension .class );
118119
119120 GraphQLSchema schema = newSchema ().query (object ).build ();
120121 GraphQLSchema schemaInherited = newSchema ().query (object ).build ();
@@ -130,9 +131,10 @@ public void values() {
130131
131132 @ Test
132133 public void testDuplicateField () {
133- GraphQLAnnotations .getInstance ().registerTypeExtension (TestObjectExtensionInvalid .class );
134- GraphQLAnnotationsException e = expectThrows (GraphQLAnnotationsException .class , () -> GraphQLAnnotations .object (TestObject .class ));
134+ GraphQLAnnotations instance = new GraphQLAnnotations ();
135+ instance .registerTypeExtension (TestObjectExtensionInvalid .class );
136+ GraphQLAnnotationsException e = expectThrows (GraphQLAnnotationsException .class , () -> instance .getObject (TestObject .class ));
135137 assertTrue (e .getMessage ().startsWith ("Duplicate field" ));
136- GraphQLAnnotations . getInstance () .unregisterTypeExtension (TestObjectExtensionInvalid .class );
138+ instance .unregisterTypeExtension (TestObjectExtensionInvalid .class );
137139 }
138140}
0 commit comments