11/**
22 * Copyright 2016 Yurii Rashkovskii
3- *
3+ * <p>
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
7- *
7+ * <p>
88 * http://www.apache.org/licenses/LICENSE-2.0
9- *
9+ * <p>
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -78,7 +78,7 @@ public String fieldWithArgs(@GraphQLName("a") @GraphQLNonNull String a, @GraphQL
7878 }
7979
8080 @ GraphQLField
81- public String fieldWithArgsAndEnvironment (DataFetchingEnvironment env ,@ GraphQLName ("a" ) String a , @ GraphQLName ("b" ) String b ) {
81+ public String fieldWithArgsAndEnvironment (DataFetchingEnvironment env , @ GraphQLName ("a" ) String a , @ GraphQLName ("b" ) String b ) {
8282 return a ;
8383 }
8484
@@ -141,7 +141,7 @@ public static class TestMappedObject {
141141 public String aaa ;
142142 }
143143
144- public static class TestObjectDB {
144+ public static class TestObjectDB {
145145 public String aaa ;
146146
147147 private String name ;
@@ -151,11 +151,12 @@ public String getName() {
151151 }
152152
153153 public TestObjectDB (String name , String aaa ) {
154- this .name = name ; this .aaa =aaa ;
154+ this .name = name ;
155+ this .aaa = aaa ;
155156 }
156157 }
157158
158- public static class TestQuery {
159+ public static class TestQuery {
159160 @ GraphQLField
160161 @ GraphQLDataFetcher (ObjectFetcher .class )
161162 public TestMappedObject object ;
@@ -169,15 +170,62 @@ public TestObjectDB get(DataFetchingEnvironment environment) {
169170 }
170171 }
171172
173+ public static class NameTest {
174+ @ GraphQLField
175+ public Boolean isCool ;
176+
177+ @ GraphQLField
178+ @ GraphQLPrettify
179+ public Boolean isAwesome ;
180+
181+ @ GraphQLField
182+ @ GraphQLPrettify
183+ @ GraphQLName ("yarinnn" )
184+ public Boolean isYarin ;
185+
186+ @ GraphQLField
187+ public String getX () {
188+ return "Asdf0" ;
189+ }
190+
191+ @ GraphQLField
192+ @ GraphQLPrettify
193+ public String getY () {
194+ return "asd" ;
195+ }
196+
197+ @ GraphQLField
198+ @ GraphQLPrettify
199+ @ GraphQLName ("daniel" )
200+ public String setM (){
201+ return "Asdf" ;
202+ }
203+
204+ }
205+
172206 @ Test
173- public void fetchTestMappedObject_assertNameIsMappedFromDBObject (){
207+ public void objectCreation_nameIsCorrect () {
208+ // Act
209+ GraphQLObjectType object = GraphQLAnnotations .object (NameTest .class );
210+
211+ // Assert
212+ assertNotNull (object .getFieldDefinition ("awesome" ));
213+ assertNotNull (object .getFieldDefinition ("isCool" ));
214+ assertNotNull (object .getFieldDefinition ("yarinnn" ));
215+ assertNotNull (object .getFieldDefinition ("getX" ));
216+ assertNotNull (object .getFieldDefinition ("y" ));
217+ assertNotNull (object .getFieldDefinition ("daniel" ));
218+ }
219+
220+ @ Test
221+ public void fetchTestMappedObject_assertNameIsMappedFromDBObject () {
174222 GraphQLObjectType object = GraphQLAnnotations .object (TestQuery .class );
175223 GraphQLSchema schema = newSchema ().query (object ).build ();
176224
177225 ExecutionResult result = GraphQL .newGraphQL (schema ).build ().execute ("{object {name aaa}}" );
178226 assertTrue (result .getErrors ().isEmpty ());
179- assertEquals (((LinkedHashMap )(((LinkedHashMap )result .getData ()).get ("object" ))).get ("name" ), "test" );
180- assertEquals (((LinkedHashMap )(((LinkedHashMap )result .getData ()).get ("object" ))).get ("aaa" ), "test" );
227+ assertEquals (((LinkedHashMap ) (((LinkedHashMap ) result .getData ()).get ("object" ))).get ("name" ), "test" );
228+ assertEquals (((LinkedHashMap ) (((LinkedHashMap ) result .getData ()).get ("object" ))).get ("aaa" ), "test" );
181229 }
182230
183231 @ Test
@@ -540,7 +588,7 @@ public static class Class2 {
540588 @ Test
541589 public void recursiveTypes () {
542590 GraphQLAnnotations graphQLAnnotations = new GraphQLAnnotations ();
543- GraphQLObjectType object = graphQLAnnotations .getObjectHandler ().getObject (Class1 .class ,graphQLAnnotations .getContainer ());
591+ GraphQLObjectType object = graphQLAnnotations .getObjectHandler ().getObject (Class1 .class , graphQLAnnotations .getContainer ());
544592 GraphQLSchema schema = newSchema ().query (object ).build ();
545593
546594 Class1 class1 = new Class1 ();
@@ -593,7 +641,7 @@ public void customTypeFunction() {
593641 assertEquals (object .getFieldDefinition ("id" ).getType (), GraphQLString );
594642 }
595643
596- public static class TestInputArgument {
644+ public static class TestInputArgument {
597645 @ GraphQLField
598646 public String a ;
599647 @ GraphQLField
@@ -621,8 +669,7 @@ public Collection<TestInputArgument> inputs() {
621669 }
622670
623671
624-
625- public static class TestObjectInput {
672+ public static class TestObjectInput {
626673 @ GraphQLField
627674 public String test (@ GraphQLName ("other" ) int other , @ GraphQLName ("arg" ) TestInputArgument arg ) {
628675 return arg .a ;
@@ -634,7 +681,7 @@ public String test2(@GraphQLName("other") int other, @GraphQLName("arg") TestCom
634681 }
635682 }
636683
637- public static class InputObject {
684+ public static class InputObject {
638685 @ GraphQLField
639686 int a ;
640687
@@ -688,7 +735,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
688735
689736 @ Override
690737 public GraphQLType buildType (boolean input , Class <?> aClass , AnnotatedType annotatedType , ProcessingElementsContainer container ) {
691- return buildType (input ,aClass ,annotatedType );
738+ return buildType (input , aClass , annotatedType );
692739 }
693740
694741 @ Override
0 commit comments