@@ -168,14 +168,16 @@ void testComplexMaps() throws IOException {
168
168
new SchemaFieldDataType ()
169
169
.setType (
170
170
SchemaFieldDataType .Type .create (
171
- new MapType ().setKeyType ("string" ).setValueType ("ComplexType" ))));
171
+ new MapType ().setKeyType ("string" ).setValueType ("ComplexType" ))),
172
+ "{\" custom-prop\" :\" custom-value\" }" );
172
173
assertSchemaField (
173
174
schema .getFields ().get (2 ),
174
175
"[version=2.0].[type=MapType].[type=map].[type=ComplexType].mapOfComplexType.[type=string].field1" ,
175
176
"string" ,
176
177
false ,
177
178
false ,
178
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())));
179
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())),
180
+ "{\" custom-prop-1\" :\" custom-value-1\" }" );
179
181
assertSchemaField (
180
182
schema .getFields ().get (3 ),
181
183
"[version=2.0].[type=MapType].[type=map].[type=ComplexType].mapOfComplexType.[type=int].field2" ,
@@ -209,21 +211,24 @@ void testComplexMaps() throws IOException {
209
211
new SchemaFieldDataType ()
210
212
.setType (
211
213
SchemaFieldDataType .Type .create (
212
- new MapType ().setKeyType ("string" ).setValueType ("union" ))));
214
+ new MapType ().setKeyType ("string" ).setValueType ("union" ))),
215
+ "{\" custom-prop\" :\" custom-value\" }" );
213
216
assertSchemaField (
214
217
schema .getFields ().get (7 ),
215
218
"[version=2.0].[type=MapType].[type=map].[type=union].[type=ComplexTypeNullable].mapOfNullableComplexType" ,
216
219
"ComplexTypeNullable" ,
217
220
false ,
218
221
false ,
219
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new RecordType ())));
222
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new RecordType ())),
223
+ "{\" custom-prop\" :\" custom-value\" }" );
220
224
assertSchemaField (
221
225
schema .getFields ().get (8 ),
222
226
"[version=2.0].[type=MapType].[type=map].[type=union].[type=ComplexTypeNullable].mapOfNullableComplexType.[type=string].field1" ,
223
227
"string" ,
224
228
false ,
225
229
false ,
226
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())));
230
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())),
231
+ "{\" custom-prop-1\" :\" custom-value-1\" }" );
227
232
assertSchemaField (
228
233
schema .getFields ().get (9 ),
229
234
"[version=2.0].[type=MapType].[type=map].[type=union].[type=ComplexTypeNullable].mapOfNullableComplexType.[type=int].field2" ,
@@ -296,7 +301,8 @@ void testComplexArrays() throws IOException {
296
301
new SchemaFieldDataType ()
297
302
.setType (
298
303
SchemaFieldDataType .Type .create (
299
- new ArrayType ().setNestedType (new StringArray ("string" )))));
304
+ new ArrayType ().setNestedType (new StringArray ("string" )))),
305
+ "{\" custom-prop\" :\" custom-value\" }" );
300
306
assertSchemaField (
301
307
schema .getFields ().get (1 ),
302
308
"[version=2.0].[type=ArrayType].[type=array].[type=map].arrayOfMap" ,
@@ -306,7 +312,8 @@ void testComplexArrays() throws IOException {
306
312
new SchemaFieldDataType ()
307
313
.setType (
308
314
SchemaFieldDataType .Type .create (
309
- new MapType ().setKeyType ("string" ).setValueType ("string" ))));
315
+ new MapType ().setKeyType ("string" ).setValueType ("string" ))),
316
+ "{\" custom-prop\" :\" custom-value\" }" );
310
317
assertSchemaField (
311
318
schema .getFields ().get (2 ),
312
319
"[version=2.0].[type=ArrayType].[type=array].[type=ComplexType].arrayOfRecord" ,
@@ -316,21 +323,24 @@ void testComplexArrays() throws IOException {
316
323
new SchemaFieldDataType ()
317
324
.setType (
318
325
SchemaFieldDataType .Type .create (
319
- new ArrayType ().setNestedType (new StringArray ("ComplexType" )))));
326
+ new ArrayType ().setNestedType (new StringArray ("ComplexType" )))),
327
+ "{\" custom-prop\" :\" custom-value\" }" );
320
328
assertSchemaField (
321
329
schema .getFields ().get (3 ),
322
330
"[version=2.0].[type=ArrayType].[type=array].[type=ComplexType].arrayOfRecord.[type=string].field1" ,
323
331
"string" ,
324
332
false ,
325
333
false ,
326
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())));
334
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())),
335
+ "{\" custom-prop-1\" :\" custom-value-1\" }" );
327
336
assertSchemaField (
328
337
schema .getFields ().get (4 ),
329
338
"[version=2.0].[type=ArrayType].[type=array].[type=ComplexType].arrayOfRecord.[type=int].field2" ,
330
339
"int" ,
331
340
false ,
332
341
false ,
333
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new NumberType ())));
342
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new NumberType ())),
343
+ "{\" custom-prop-2\" :\" custom-value-2\" }" );
334
344
assertSchemaField (
335
345
schema .getFields ().get (5 ),
336
346
"[version=2.0].[type=ArrayType].[type=array].[type=array].arrayOfArray" ,
@@ -445,7 +455,8 @@ void testComplexStructs() throws IOException {
445
455
"string" ,
446
456
false ,
447
457
false ,
448
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())));
458
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())),
459
+ "{\" custom-prop\" :\" custom-value\" }" );
449
460
assertSchemaField (
450
461
schema .getFields ().get (2 ),
451
462
"[version=2.0].[type=StructType].[type=ComplexStruct].structField.[type=int].fieldInt" ,
@@ -556,28 +567,32 @@ void testComplexUnions() throws IOException {
556
567
new SchemaFieldDataType ()
557
568
.setType (
558
569
SchemaFieldDataType .Type .create (
559
- new UnionType ().setNestedTypes (new StringArray ("union" )))));
570
+ new UnionType ().setNestedTypes (new StringArray ("union" )))),
571
+ "{\" custom-prop\" :\" custom-value\" }" );
560
572
assertSchemaField (
561
573
schema .getFields ().get (1 ),
562
574
"[version=2.0].[type=UnionType].[type=union].[type=string].fieldUnionNullablePrimitives" ,
563
575
"string" ,
564
576
false ,
565
577
false ,
566
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())));
578
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new StringType ())),
579
+ "{\" custom-prop\" :\" custom-value\" }" );
567
580
assertSchemaField (
568
581
schema .getFields ().get (2 ),
569
582
"[version=2.0].[type=UnionType].[type=union].[type=int].fieldUnionNullablePrimitives" ,
570
583
"int" ,
571
584
false ,
572
585
false ,
573
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new NumberType ())));
586
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new NumberType ())),
587
+ "{\" custom-prop\" :\" custom-value\" }" );
574
588
assertSchemaField (
575
589
schema .getFields ().get (3 ),
576
590
"[version=2.0].[type=UnionType].[type=union].[type=boolean].fieldUnionNullablePrimitives" ,
577
591
"boolean" ,
578
592
false ,
579
593
false ,
580
- new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new BooleanType ())));
594
+ new SchemaFieldDataType ().setType (SchemaFieldDataType .Type .create (new BooleanType ())),
595
+ "{\" custom-prop\" :\" custom-value\" }" );
581
596
assertSchemaField (
582
597
schema .getFields ().get (4 ),
583
598
"[version=2.0].[type=UnionType].[type=union].fieldUnionComplexTypes" ,
@@ -955,9 +970,9 @@ private void assertSchemaField(
955
970
assertEquals (field .isNullable (), expectedNullable );
956
971
assertEquals (field .isIsPartOfKey (), expectedIsPartOfKey );
957
972
assertEquals (field .getType (), expectedType );
958
- if ( expectedJsonProps != null ) {
959
- assertEquals ( field .getJsonProps (), expectedJsonProps );
960
- }
973
+ assertEquals (
974
+ field .getJsonProps (),
975
+ expectedJsonProps ); // ensure this is null if there are no custom properties
961
976
}
962
977
963
978
private Schema readAvroSchema (String schemaFileName ) throws IOException {
0 commit comments