public static <T extends SpecificRecordBase> T dataMapToSpecificRecord(DataMap map, RecordDataSchema dataSchema,
      Schema avroSchema) throws DataTranslationException {
    DataMapToSpecificRecordTranslator translator = new DataMapToSpecificRecordTranslator();
    try {
      T avroRecord = translator.translate(map, dataSchema, avroSchema);
      translator.checkMessageListForErrorsAndThrowDataTranslationException();
      return avroRecord;
    } catch (RuntimeException e) {
      throw translator.dataTranslationException(e);
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
      throw translator.dataTranslationException(new RuntimeException(e));
    }
  }
@Test
  public void testMapArrayUnion() throws IOException {
    RecordDataSchema recordDataSchemaMapArrayUnion =
        (RecordDataSchema) TestUtil.dataSchemaFromString(MapArrayUnion.TEST_SCHEMA.toString());

    RecordDataSchema recordDataSchema =
        (RecordDataSchema) TestUtil.dataSchemaFromString(ArrayOfMapArrayUnion.TEST_SCHEMA.toString());

    RecordDataSchema recordDataSchemaOfMap =
        (RecordDataSchema) TestUtil.dataSchemaFromString(MapOfArrayOfMapArrayUnion.TEST_SCHEMA.toString());

    RecordDataSchema recordDataSchemaOfMapOfMap =
        (RecordDataSchema) TestUtil.dataSchemaFromString(MapOfMapOfArrayOfMapArrayUnion.TEST_SCHEMA.toString());

    DataMap arrayData = new DataMap(ImmutableMap.of("mapOrArray", new DataMap(ImmutableMap.of("array", new DataList(Arrays.asList("a"))))));
    MapArrayUnion arrayUnion = DataTranslator.dataMapToSpecificRecord(arrayData, recordDataSchemaMapArrayUnion, MapArrayUnion.TEST_SCHEMA);

    DataMap mapData = new DataMap(ImmutableMap.of("mapOrArray", new DataMap(ImmutableMap.of("map", new DataMap(
        ImmutableMap.of("key", "value")
    )))));
    MapArrayUnion mapUnion = DataTranslator.dataMapToSpecificRecord(mapData, recordDataSchemaMapArrayUnion, MapArrayUnion.TEST_SCHEMA);

    DataMap arrayOfMapArrayUnionData = new DataMap(ImmutableMap.of("recordArray", new DataList(Arrays.asList(arrayData, mapData))));
    ArrayOfMapArrayUnion arrayOfMapArrayUnion = DataTranslator.dataMapToSpecificRecord(arrayOfMapArrayUnionData, recordDataSchema, ArrayOfMapArrayUnion.TEST_SCHEMA);

    DataMap mapOfArrayOfMapArrayUnionData = new DataMap(ImmutableMap.of("recordMap", arrayOfMapArrayUnionData));
    MapOfArrayOfMapArrayUnion mapOfArrayOfMapArrayUnion = DataTranslator.dataMapToSpecificRecord(mapOfArrayOfMapArrayUnionData, recordDataSchemaOfMap, MapOfArrayOfMapArrayUnion.TEST_SCHEMA);

    DataMap mapOfMapOfArrayOfMapArrayUnionData = new DataMap(ImmutableMap.of("recordMap", new DataMap(ImmutableMap.of("recordMap", mapOfArrayOfMapArrayUnionData))));
    MapOfMapOfArrayOfMapArrayUnion mapOfMapOfArrayOfMapArrayUnion = DataTranslator.dataMapToSpecificRecord(mapOfMapOfArrayOfMapArrayUnionData, recordDataSchemaOfMapOfMap, MapOfMapOfArrayOfMapArrayUnion.TEST_SCHEMA);

    Assert.assertTrue(arrayUnion.get(0) instanceof List);
    Assert.assertEquals(((List<?>) arrayUnion.get(0)).get(0), "a");
    Assert.assertTrue(mapUnion.get(0) instanceof Map);
    Assert.assertEquals(((Map<?, ?>) mapUnion.get(0)).get("key"), "value");

    Assert.assertTrue(arrayOfMapArrayUnion.get(0) instanceof List);
    Assert.assertTrue(((MapArrayUnion)((List<?>) arrayOfMapArrayUnion.get(0)).get(0)).get(0) instanceof List);
    Assert.assertTrue(((MapArrayUnion)((List<?>) arrayOfMapArrayUnion.get(0)).get(1)).get(0) instanceof Map);

    Assert.assertTrue(mapOfArrayOfMapArrayUnion.get(0) instanceof Map);
    Assert.assertEquals(((Map<?, ?>) mapOfArrayOfMapArrayUnion.get(0)).get("recordArray"), Arrays.asList(arrayUnion, mapUnion));

    Assert.assertTrue(mapOfMapOfArrayOfMapArrayUnion.get(0) instanceof Map);
    Assert.assertEquals(((Map<?, ?>) mapOfMapOfArrayOfMapArrayUnion.get(0)).get("recordMap"), mapOfArrayOfMapArrayUnion);
  }