@Override
  public Record build() {
    Record record;
    try {
      record = new GenericData.Record(schema());
    } catch (Exception e) {
      throw new AvroRuntimeException(e);
    }

    for (Field field : fields()) {
      Object value;
      try {
        value = getWithDefault(field);
      } catch (IOException e) {
        throw new AvroRuntimeException(e);
      }
      if (value != null) {
        record.put(field.pos(), value);
      }
    }

    return record;
  }
@Test
  void buildWithoutSettingRequiredFields1() {
    assertThrows(org.apache.avro.AvroRuntimeException.class, () -> {
      new GenericRecordBuilder(recordSchema()).build();
    });
  }