@Test
public void testGetSchemaFromStringNested() {

  // Set fields schema for testing.
  String fields =
      "[{'name': 'MyName', 'type': 'STRING'},"
      + "{'name': 'MyNestedField', 'type': 'RECORD', 'mode': 'repeated', 'fields': ["
          + "{'name': 'field1', 'type': 'INTEGER'}, {'name': 'field2', 'type': 'STRING'}"
      + "]}]";
  List<TableFieldSchema> list = BigQueryUtils.getSchemaFromString(fields);
  assertThat(list).hasSize(2);
  assertThat(list.get(0).getName()).isEqualTo("MyName");
  assertThat(list.get(0).getType()).isEqualTo("STRING");
  assertThat(list.get(1).getName()).isEqualTo("MyNestedField");
  assertThat(list.get(1).getType()).isEqualTo("RECORD");
  assertThat(list.get(1).getMode()).isEqualTo("repeated");
  List<TableFieldSchema> nestedList = list.get(1).getFields();
  assertThat(nestedList).isNotNull();
  assertThat(nestedList).hasSize(2);
  assertThat(nestedList.get(0).getName()).isEqualTo("field1");
  assertThat(nestedList.get(0).getType()).isEqualTo("INTEGER");
  assertThat(nestedList.get(1).getName()).isEqualTo("field2");
  assertThat(nestedList.get(1).getType()).isEqualTo("STRING");
}