SchemaAwareSerDe { public static byte[] serialize(SchemaId schemaId, byte[] binaryAvro) { ByteBuffer buffer = ByteBuffer.allocate(HEADER_SIZE + binaryAvro.length); buffer.put(MAGIC_BYTE_VALUE); buffer.putInt(schemaId.value()); buffer.put(binaryAvro); return buffer.array(); } private  SchemaAwareSerDe(); static byte[] serialize(SchemaId schemaId, byte[] binaryAvro); static SchemaAwarePayload deserialize(byte[] payloadWithHeader); static boolean startsWithMagicByte(byte[] payload); static byte[] trimMagicByteAndSchemaVersion(byte[] data);  }
@Test public void shouldSerialize() throws IOException { SchemaId id = SchemaId.valueOf(8); byte[] serialized = SchemaAwareSerDe.serialize(id, avro.asBytes()); assertThat(serialized).startsWith((byte)0); }