public static RecordBuilder<Schema> record(String name) {
    return builder().record(name);
  }
@Test
  void record() {
    Schema schema = SchemaBuilder.record("myrecord").namespace("org.example").aliases("oldrecord").fields().name("f0")
        .aliases("f0alias").type().stringType().noDefault().name("f1").doc("This is f1").type().longType().noDefault()
        .name("f2").type().nullable().booleanType().booleanDefault(true).name("f3").type().unionOf().nullType().and()
        .booleanType().endUnion().nullDefault().endRecord();

    assertEquals("myrecord", schema.getName());
    assertEquals("org.example", schema.getNamespace());
    assertEquals("org.example.oldrecord", schema.getAliases().iterator().next());
    assertFalse(schema.isError());
    List<Schema.Field> fields = schema.getFields();
    assertEquals(4, fields.size());
    assertEquals(new Schema.Field("f0", Schema.create(Schema.Type.STRING)), fields.get(0));
    assertTrue(fields.get(0).aliases().contains("f0alias"));
    assertEquals(new Schema.Field("f1", Schema.create(Schema.Type.LONG), "This is f1"), fields.get(1));

    List<Schema> types = new ArrayList<>();
    types.add(Schema.create(Schema.Type.BOOLEAN));
    types.add(Schema.create(Schema.Type.NULL));
    Schema optional = Schema.createUnion(types);
    assertEquals(new Schema.Field("f2", optional, null, true), fields.get(2));

    List<Schema> types2 = new ArrayList<>();
    types2.add(Schema.create(Schema.Type.NULL));
    types2.add(Schema.create(Schema.Type.BOOLEAN));
    Schema optional2 = Schema.createUnion(types2);

    assertNotEquals(new Schema.Field("f3", optional2, null, (Object) null), fields.get(3));
    assertEquals(new Schema.Field("f3", optional2, null, Schema.Field.NULL_DEFAULT_VALUE), fields.get(3));
  }