SchemaAwareSerDe { public static SchemaAwarePayload deserialize(byte[] payloadWithHeader) { ByteBuffer buffer = ByteBuffer.wrap(payloadWithHeader); assertMagicByte(buffer.get()); int schemaId = buffer.getInt(); byte[] payload = new byte[payloadWithHeader.length - HEADER_SIZE]; buffer.get(payload); return new SchemaAwarePayload(payload, SchemaId.valueOf(schemaId)); } 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(expectedExceptions = { DeserializationException.class }) public void shouldThrowExceptionWhenDeserializingWithoutMagicByte() throws IOException { SchemaAwareSerDe.deserialize(new byte[]{1,2,3}); }