public void runCustomSerDesApi() throws Exception {
String serdesJarName = "/serdes-examples.jar";
InputStream serdesJarInputStream = SampleSchemaRegistryClientApp.class.getResourceAsStream(serdesJarName);
if (serdesJarInputStream == null) {
throw new RuntimeException("Jar " + serdesJarName + " could not be loaded");
}
String fileId = schemaRegistryClient.uploadFile(serdesJarInputStream);
SchemaMetadata schemaMetadata = createSchemaMetadata("serdes-device-" + System.currentTimeMillis());
SchemaIdVersion v1 = schemaRegistryClient.addSchemaVersion(schemaMetadata,
new SchemaVersion(getSchema("/device.avsc"),
"Initial version of the schema"));
Long serDesId = registerSimpleSerDes(fileId);
String schemaName = schemaMetadata.getName();
schemaRegistryClient.mapSchemaWithSerDes(schemaName, serDesId);
SnapshotSerializer<Object, byte[], SchemaMetadata> snapshotSerializer = getSnapshotSerializer(schemaMetadata);
String payload = "Random text: " + new Random().nextLong();
byte[] serializedBytes = snapshotSerializer.serialize(payload, schemaMetadata);
SnapshotDeserializer<byte[], Object, Integer> snapshotdeserializer = getSnapshotDeserializer(schemaMetadata);
Object deserializedObject = snapshotdeserializer.deserialize(serializedBytes, null);
LOG.info("Given payload and deserialized object are equal: " + payload.equals(deserializedObject));
}