@@ -68,6 +68,15 @@ enum MyEnum {
68
68
foo: String
69
69
}
70
70
71
+ structure NestedStruct {
72
+ foo: SimpleStruct
73
+ bar: SimpleStruct
74
+ }
75
+
76
+ structure ParentStruct {
77
+ foo: NestedStruct
78
+ }
79
+
71
80
union SimpleUnion {
72
81
foo: String
73
82
}
@@ -134,9 +143,65 @@ static List<Arguments> convertsAggregateSchemasSource() {
134
143
Arguments .of (ShapeType .LIST , "SimpleList" ),
135
144
Arguments .of (ShapeType .MAP , "SimpleMap" ),
136
145
Arguments .of (ShapeType .STRUCTURE , "SimpleStruct" ),
146
+ Arguments .of (ShapeType .STRUCTURE , "NestedStruct" ),
147
+ Arguments .of (ShapeType .STRUCTURE , "ParentStruct" ),
137
148
Arguments .of (ShapeType .UNION , "SimpleUnion" ),
138
149
Arguments .of (ShapeType .LIST , "RecursiveList" ),
139
150
Arguments .of (ShapeType .MAP , "RecursiveMap" ),
140
151
Arguments .of (ShapeType .STRUCTURE , "RecursiveStructure" ));
141
152
}
153
+
154
+ @ MethodSource ("detectsRecursiveSchemasSource" )
155
+ @ ParameterizedTest
156
+ public void detectsRecursiveSchemas (String name ) {
157
+ var converter = new SchemaConverter (model );
158
+ var schema = converter .getSchema (model .expectShape (ShapeId .from ("smithy.example#" + name )));
159
+
160
+ // Detecting that SchemaConverter handled this schema as recursive by checking classname is
161
+ // hacky, but public API doesn't expose a cleaner way, and probably shouldn't.
162
+ assertThat (schema .getClass ().getSimpleName (), is ("DeferredRootSchema" ));
163
+ }
164
+
165
+ static List <Arguments > detectsRecursiveSchemasSource () {
166
+ return List .of (
167
+ Arguments .of ("RecursiveList" ),
168
+ Arguments .of ("RecursiveMap" ),
169
+ Arguments .of ("RecursiveStructure" ));
170
+ }
171
+
172
+ @ MethodSource ("detectsNonRecursiveSchemasSource" )
173
+ @ ParameterizedTest
174
+ public void detectsNonRecursiveSchemas (String name ) {
175
+ var converter = new SchemaConverter (model );
176
+ var schema = converter .getSchema (model .expectShape (ShapeId .from ("smithy.example#" + name )));
177
+
178
+ // Detecting that SchemaConverter handled this schema as non-recursive by checking classname is
179
+ // hacky, but public API doesn't expose a cleaner way, and probably shouldn't.
180
+ assertThat (schema .getClass ().getSimpleName (), not ("DeferredRootSchema" ));
181
+ }
182
+
183
+ static List <Arguments > detectsNonRecursiveSchemasSource () {
184
+ return List .of (
185
+ Arguments .of ("MyDocument" ),
186
+ Arguments .of ("MyString" ),
187
+ Arguments .of ("MyBoolean" ),
188
+ Arguments .of ("MyTimestamp" ),
189
+ Arguments .of ("MyBlob" ),
190
+ Arguments .of ("MyByte" ),
191
+ Arguments .of ("MyShort" ),
192
+ Arguments .of ("MyInteger" ),
193
+ Arguments .of ("MyLong" ),
194
+ Arguments .of ("MyFloat" ),
195
+ Arguments .of ("MyDouble" ),
196
+ Arguments .of ("MyBigInteger" ),
197
+ Arguments .of ("MyBigDecimal" ),
198
+ Arguments .of ("MyEnum" ),
199
+ Arguments .of ("MyIntEnum" ),
200
+ Arguments .of ("SimpleList" ),
201
+ Arguments .of ("SimpleMap" ),
202
+ Arguments .of ("SimpleStruct" ),
203
+ Arguments .of ("NestedStruct" ),
204
+ Arguments .of ("ParentStruct" ),
205
+ Arguments .of ("SimpleUnion" ));
206
+ }
142
207
}
0 commit comments