4747import static org .junit .jupiter .api .Assertions .assertSame ;
4848import static org .junit .jupiter .api .Assertions .assertThrows ;
4949import static org .junit .jupiter .api .Assertions .assertTrue ;
50- import static org .junit .jupiter .api .Assertions .fail ;
5150
5251class TestMapRecord {
5352
@@ -335,9 +334,9 @@ void testNestedSchema() {
335334 }
336335
337336 @ Test
338- void testNestedSchemaWithEmptyArray () {
339- final String FOO_TEST_VAL = "test!" ;
340- final String NESTED_RECORD_VALUE = "Hello, world!" ;
337+ void testNestedSchemaWithEmptyArray () throws Exception {
338+ final String testValue = "test!" ;
339+ final String nestedRecordValue = "Hello, world!" ;
341340
342341 final List <RecordField > fields = new ArrayList <>();
343342 fields .add (new RecordField ("foo" , RecordFieldType .STRING .getDataType (), null , set ("bar" , "baz" )));
@@ -350,31 +349,29 @@ void testNestedSchemaWithEmptyArray() {
350349 RecordSchema fullSchema = new SimpleRecordSchema (fields );
351350
352351 Map <String , Object > nestedValues = new HashMap <>();
353- nestedValues .put ("test" , NESTED_RECORD_VALUE );
352+ nestedValues .put ("test" , nestedRecordValue );
354353 Record nestedRecord = new MapRecord (nestedSchema , nestedValues );
355354 Map <String , Object > values = new HashMap <>();
356- values .put ("foo" , FOO_TEST_VAL );
355+ values .put ("foo" , testValue );
357356 values .put ("nested" , nestedRecord );
358357
359358 values .put ("array" , new Object [0 ]);
360359
361360 Record record = new MapRecord (fullSchema , values );
362361
363362 Map <String , Object > fullConversion = null ;
364- try {
365- fullConversion = ((MapRecord ) record ).toMap (true );
366- } catch (Exception e ) {
367- fail ("Nested toMap() failed unexpectedly" );
368- }
369- assertEquals (FOO_TEST_VAL , fullConversion .get ("foo" ));
363+ fullConversion = ((MapRecord ) record ).toMap (true );
364+
365+ assertEquals (testValue , fullConversion .get ("foo" ));
370366 assertInstanceOf (Map .class , fullConversion .get ("nested" ));
371367
372368 Map <String , Object > nested = (Map <String , Object >) fullConversion .get ("nested" );
373369 assertEquals (1 , nested .size ());
374- assertEquals (NESTED_RECORD_VALUE , nested .get ("test" ));
370+ assertEquals (nestedRecordValue , nested .get ("test" ));
375371
376- assertInstanceOf (Object [].class , fullConversion .get ("array" ));
377- Object [] recordArray = (Object []) fullConversion .get ("array" );
372+ Object arrayFieldName = fullConversion .get ("array" );
373+ assertInstanceOf (Object [].class , arrayFieldName );
374+ Object [] recordArray = (Object []) arrayFieldName ;
378375 assertEquals (0 , recordArray .length );
379376 }
380377
0 commit comments