public void setSchema(Schema schema) {
        this.userDefinedSchema = schema;
    }
@Test
    void testGenericRecord() throws IOException {
        final Path outputPath =
                new Path(File.createTempFile("avro-output-file", "generic.avro").getAbsolutePath());
        final AvroOutputFormat<GenericRecord> outputFormat =
                new AvroOutputFormat<>(outputPath, GenericRecord.class);
        Schema schema =
                new Schema.Parser()
                        .parse(
                                "{\"type\":\"record\", \"name\":\"user\", \"fields\": [{\"name\":\"user_name\", \"type\":\"string\"}, {\"name\":\"favorite_number\", \"type\":\"int\"}, {\"name\":\"favorite_color\", \"type\":\"string\"}]}");
        outputFormat.setWriteMode(FileSystem.WriteMode.OVERWRITE);
        outputFormat.setSchema(schema);
        output(outputFormat, schema);

        GenericDatumReader<GenericRecord> reader = new GenericDatumReader<>(schema);
        DataFileReader<GenericRecord> dataFileReader =
                new DataFileReader<>(new File(outputPath.getPath()), reader);

        while (dataFileReader.hasNext()) {
            GenericRecord record = dataFileReader.next();
            assertThat(record.get("user_name").toString()).isEqualTo("testUser");
            assertThat(record.get("favorite_number")).isEqualTo(1);
            assertThat(record.get("favorite_color").toString()).isEqualTo("blue");
        }

        // cleanup
        FileSystem fs = FileSystem.getLocalFileSystem();
        fs.delete(outputPath, false);
    }