@@ -254,9 +254,17 @@ public void base_class_explicitly_in_Union_annotation_test() throws Exception {
254
254
}
255
255
256
256
@ Union ({
257
- // Interface being explicitly in @Union led to StackOverflowError exception.
258
- DocumentInterface .class ,
259
- Word .class , Excel .class })
257
+ // Interface being explicitly in @Union led to StackOverflowError exception.
258
+ DocumentInterface .class ,
259
+ // We added a bunch of implementations to test deterministic ordering of the schemas' subtypes ordering.
260
+ Word .class ,
261
+ Excel .class ,
262
+ Pdf .class ,
263
+ PowerPoint .class ,
264
+ TextDocument .class ,
265
+ Markdown .class ,
266
+ HtmlDocument .class
267
+ })
260
268
interface DocumentInterface {
261
269
}
262
270
@@ -266,11 +274,32 @@ static class Word implements DocumentInterface {
266
274
static class Excel implements DocumentInterface {
267
275
}
268
276
277
+ static class Pdf implements DocumentInterface {
278
+ }
279
+
280
+ static class PowerPoint implements DocumentInterface {
281
+ }
282
+
283
+ static class TextDocument implements DocumentInterface {
284
+ }
285
+
286
+ static class Markdown implements DocumentInterface {
287
+ }
288
+
289
+ static class HtmlDocument implements DocumentInterface {
290
+ }
291
+
292
+
269
293
@ Test
270
294
public void interface_explicitly_in_Union_annotation_test () throws Exception {
271
295
// GIVEN
272
296
final Schema wordSchema = MAPPER .schemaFor (Word .class ).getAvroSchema ();
273
297
final Schema excelSchema = MAPPER .schemaFor (Excel .class ).getAvroSchema ();
298
+ final Schema pdfSchema = MAPPER .schemaFor (Pdf .class ).getAvroSchema ();
299
+ final Schema powerPointSchema = MAPPER .schemaFor (PowerPoint .class ).getAvroSchema ();
300
+ final Schema textSchema = MAPPER .schemaFor (TextDocument .class ).getAvroSchema ();
301
+ final Schema markdownSchema = MAPPER .schemaFor (Markdown .class ).getAvroSchema ();
302
+ final Schema htmlSchema = MAPPER .schemaFor (HtmlDocument .class ).getAvroSchema ();
274
303
275
304
// WHEN
276
305
Schema actualSchema = MAPPER .schemaFor (DocumentInterface .class ).getAvroSchema ();
@@ -279,6 +308,16 @@ public void interface_explicitly_in_Union_annotation_test() throws Exception {
279
308
280
309
// THEN
281
310
assertThat (actualSchema .getType ()).isEqualTo (Schema .Type .UNION );
282
- assertThat (actualSchema .getTypes ()).containsExactlyInAnyOrder (wordSchema , excelSchema );
311
+
312
+ // Deterministic order: exactly as declared in @Union (excluding the interface).
313
+ assertThat (actualSchema .getTypes ()).containsExactly (
314
+ wordSchema ,
315
+ excelSchema ,
316
+ pdfSchema ,
317
+ powerPointSchema ,
318
+ textSchema ,
319
+ markdownSchema ,
320
+ htmlSchema
321
+ );
283
322
}
284
323
}
0 commit comments