public void write(D datum, Encoder out) throws IOException {
    Objects.requireNonNull(out, "Encoder cannot be null");
    try {
      write(root, datum, out);
    } catch (TracingNullPointException | TracingClassCastException | TracingAvroTypeException e) {
      throw e.summarize(root);
    }
  }
@Test
  void writeDoesNotAllowStringForGenericEnum() throws IOException {
    assertThrows(AvroTypeException.class, () -> {
      final String json = "{\"type\": \"record\", \"name\": \"recordWithEnum\"," + "\"fields\": [ "
          + "{\"name\": \"field\", \"type\": " + "{\"type\": \"enum\", \"name\": \"enum\", \"symbols\": "
          + "[\"ONE\",\"TWO\",\"THREE\"] " + "}" + "}" + "]}";
      Schema schema = new Schema.Parser().parse(json);
      GenericRecord record = new GenericData.Record(schema);
      record.put("field", "ONE");

      ByteArrayOutputStream bao = new ByteArrayOutputStream();
      GenericDatumWriter<GenericRecord> writer = new GenericDatumWriter<>(schema);
      Encoder encoder = EncoderFactory.get().jsonEncoder(schema, bao);

      writer.write(record, encoder);
    });
  }