@@ -61,7 +61,14 @@ void defaultConstructor() throws Exception {
6161 void defaultConstructorWithNestedBeanProperty () throws Exception {
6262
6363 Object result = initializer .get ().initializeArgument (
64- environment ("{\" key\" :{\" name\" :\" test name\" ,\" author\" :{\" firstName\" :\" Jane\" ,\" lastName\" :\" Spring\" }}}" ), "key" ,
64+ environment (
65+ "{\" key\" :{" +
66+ "\" name\" :\" test name\" ," +
67+ "\" author\" :{" +
68+ " \" firstName\" :\" Jane\" ," +
69+ " \" lastName\" :\" Spring\" " +
70+ "}}}" ),
71+ "key" ,
6572 ResolvableType .forClass (Book .class ));
6673
6774 assertThat (result ).isNotNull ().isInstanceOf (Book .class );
@@ -109,19 +116,29 @@ void primaryConstructor() throws Exception {
109116 void primaryConstructorWithBeanArgument () throws Exception {
110117
111118 Object result = initializer .get ().initializeArgument (
112- environment ("{\" key\" :{\" item\" :{\" name\" :\" Item name\" },\" name\" :\" Hello\" }}" ), "key" ,
119+ environment (
120+ "{\" key\" :{" +
121+ "\" item\" :{\" name\" :\" Item name\" }," +
122+ "\" name\" :\" Hello\" ," +
123+ "\" age\" :\" 30\" }}" ),
124+ "key" ,
113125 ResolvableType .forClass (PrimaryConstructorItemBean .class ));
114126
115127 assertThat (result ).isNotNull ().isInstanceOf (PrimaryConstructorItemBean .class );
116- assertThat (((PrimaryConstructorItemBean ) result ).item .name ).isEqualTo ("Item name" );
117- assertThat (((PrimaryConstructorItemBean ) result ).name ).isEqualTo ("Hello" );
128+ assertThat (((PrimaryConstructorItemBean ) result ).getItem ().getName ()).isEqualTo ("Item name" );
129+ assertThat (((PrimaryConstructorItemBean ) result ).getName ()).isEqualTo ("Hello" );
130+ assertThat (((PrimaryConstructorItemBean ) result ).getAge ()).isEqualTo (30 );
118131 }
119132
120133 @ Test
121134 void primaryConstructorWithNestedBeanList () throws Exception {
122135
123136 Object result = initializer .get ().initializeArgument (
124- environment ("{\" key\" :{\" items\" :[{\" name\" :\" first\" },{\" name\" :\" second\" }]}}" ), "key" ,
137+ environment (
138+ "{\" key\" :{\" items\" :[" +
139+ "{\" name\" :\" first\" }," +
140+ "{\" name\" :\" second\" }]}}" ),
141+ "key" ,
125142 ResolvableType .forClass (PrimaryConstructorItemListBean .class ));
126143
127144 assertThat (result ).isNotNull ().isInstanceOf (PrimaryConstructorItemListBean .class );
@@ -132,11 +149,9 @@ void primaryConstructorWithNestedBeanList() throws Exception {
132149 @ Test
133150 void primaryConstructorNotFound () {
134151 assertThatThrownBy (
135- () -> {
136- initializer .get ().initializeArgument (
137- environment ("{\" key\" :{\" name\" :\" test\" }}" ), "key" ,
138- ResolvableType .forClass (NoPrimaryConstructorBean .class ));
139- })
152+ () -> initializer .get ().initializeArgument (
153+ environment ("{\" key\" :{\" name\" :\" test\" }}" ), "key" ,
154+ ResolvableType .forClass (NoPrimaryConstructorBean .class )))
140155 .isInstanceOf (IllegalStateException .class )
141156 .hasMessageContaining ("No primary or single unique constructor found" );
142157 }
@@ -150,9 +165,9 @@ private DataFetchingEnvironment environment(String jsonPayload) throws JsonProce
150165
151166 static class SimpleBean {
152167
153- String name ;
168+ private String name ;
154169
155- int age ;
170+ private int age ;
156171
157172 public String getName () {
158173 return this .name ;
@@ -174,7 +189,7 @@ public void setAge(int age) {
174189
175190 static class PrimaryConstructorBean {
176191
177- final String name ;
192+ private final String name ;
178193
179194 public PrimaryConstructorBean (String name ) {
180195 this .name = name ;
@@ -186,30 +201,28 @@ public String getName() {
186201 }
187202
188203
189- static class NoPrimaryConstructorBean {
190-
191- NoPrimaryConstructorBean (String name ) {
192- }
193-
194- NoPrimaryConstructorBean (String name , Long id ) {
195- }
196- }
204+ static class PrimaryConstructorItemBean {
197205
206+ private final String name ;
198207
199- static class PrimaryConstructorItemBean {
200- final String name ;
208+ private final int age ;
201209
202- final Item item ;
210+ private final Item item ;
203211
204- public PrimaryConstructorItemBean (String name , Item item ) {
212+ public PrimaryConstructorItemBean (String name , int age , Item item ) {
205213 this .name = name ;
214+ this .age = age ;
206215 this .item = item ;
207216 }
208217
209218 public String getName () {
210219 return this .name ;
211220 }
212221
222+ public int getAge () {
223+ return this .age ;
224+ }
225+
213226 public Item getItem () {
214227 return item ;
215228 }
@@ -218,7 +231,7 @@ public Item getItem() {
218231
219232 static class PrimaryConstructorItemListBean {
220233
221- final List <Item > items ;
234+ private final List <Item > items ;
222235
223236 public PrimaryConstructorItemListBean (List <Item > items ) {
224237 this .items = items ;
@@ -230,9 +243,19 @@ public List<Item> getItems() {
230243 }
231244
232245
246+ static class NoPrimaryConstructorBean {
247+
248+ NoPrimaryConstructorBean (String name ) {
249+ }
250+
251+ NoPrimaryConstructorBean (String name , Long id ) {
252+ }
253+ }
254+
255+
233256 static class ItemListHolder {
234257
235- List <Item > items ;
258+ private List <Item > items ;
236259
237260 public List <Item > getItems () {
238261 return this .items ;
@@ -246,7 +269,7 @@ public void setItems(List<Item> items) {
246269
247270 static class Item {
248271
249- String name ;
272+ private String name ;
250273
251274 public String getName () {
252275 return this .name ;
0 commit comments