@Test(expected = SerializationException.class) public void serializeInvalidUser() throws Exception { User user = new User("john", "doe", (short) -1, "jack"); byte[] bytes = serializer.serialize("foo", user); Object deserialized = getDeserializer(User.class).deserialize(topic, bytes); assertEquals(user, deserialized); }
@Override public byte[] serialize(String topic, T record) { if (record == null) { return null; } JsonSchema schema; if (JsonSchemaUtils.isEnvelope(record)) { schema = getSchema(record); } else { schema = schemaCache.get(record.getClass()); if (schema == null) { schema = getSchema(record); schemaCache.put(record.getClass(), schema); } } Object value = JsonSchemaUtils.getValue(record); return serializeImpl(getSubjectName(topic, isKey, value, schema), (T) value, schema); }
KafkaJsonSchemaSerializer extends AbstractKafkaJsonSchemaSerializer<T> implements Serializer<T> { @Override public byte[] serialize(String topic, T record) { if (record == null) { return null; } JsonSchema schema; if (JsonSchemaUtils.isEnvelope(record)) { schema = getSchema(record); } else { schema = schemaCache.get(record.getClass()); if (schema == null) { schema = getSchema(record); schemaCache.put(record.getClass(), schema); } } Object value = JsonSchemaUtils.getValue(record); return serializeImpl(getSubjectName(topic, isKey, value, schema), (T) value, schema); } }
KafkaJsonSchemaSerializer extends AbstractKafkaJsonSchemaSerializer<T> implements Serializer<T> { @Override public byte[] serialize(String topic, T record) { if (record == null) { return null; } JsonSchema schema; if (JsonSchemaUtils.isEnvelope(record)) { schema = getSchema(record); } else { schema = schemaCache.get(record.getClass()); if (schema == null) { schema = getSchema(record); schemaCache.put(record.getClass(), schema); } } Object value = JsonSchemaUtils.getValue(record); return serializeImpl(getSubjectName(topic, isKey, value, schema), (T) value, schema); } KafkaJsonSchemaSerializer();  KafkaJsonSchemaSerializer(SchemaRegistryClient client);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props,
                                   int cacheCapacity); }
KafkaJsonSchemaSerializer extends AbstractKafkaJsonSchemaSerializer<T> implements Serializer<T> { @Override public byte[] serialize(String topic, T record) { if (record == null) { return null; } JsonSchema schema; if (JsonSchemaUtils.isEnvelope(record)) { schema = getSchema(record); } else { schema = schemaCache.get(record.getClass()); if (schema == null) { schema = getSchema(record); schemaCache.put(record.getClass(), schema); } } Object value = JsonSchemaUtils.getValue(record); return serializeImpl(getSubjectName(topic, isKey, value, schema), (T) value, schema); } KafkaJsonSchemaSerializer();  KafkaJsonSchemaSerializer(SchemaRegistryClient client);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props,
                                   int cacheCapacity); @Override void configure(Map<String, ?> config, boolean isKey); @Override byte[] serialize(String topic, T record); @Override void close(); }
KafkaJsonSchemaSerializer extends AbstractKafkaJsonSchemaSerializer<T> implements Serializer<T> { @Override public byte[] serialize(String topic, T record) { if (record == null) { return null; } JsonSchema schema; if (JsonSchemaUtils.isEnvelope(record)) { schema = getSchema(record); } else { schema = schemaCache.get(record.getClass()); if (schema == null) { schema = getSchema(record); schemaCache.put(record.getClass(), schema); } } Object value = JsonSchemaUtils.getValue(record); return serializeImpl(getSubjectName(topic, isKey, value, schema), (T) value, schema); } KafkaJsonSchemaSerializer();  KafkaJsonSchemaSerializer(SchemaRegistryClient client);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props);  KafkaJsonSchemaSerializer(SchemaRegistryClient client, Map<String, ?> props,
                                   int cacheCapacity); @Override void configure(Map<String, ?> config, boolean isKey); @Override byte[] serialize(String topic, T record); @Override void close();  }