@Test public void test() { final CoffeeEvent actual = cut.deserialize(null, data.getBytes(StandardCharsets.UTF_8)); assertEventEquals(actual, expected); }
@Override public CoffeeEvent deserialize(final String topic, final byte[] data) { try (ByteArrayInputStream input = new ByteArrayInputStream(data)) { final JsonObject jsonObject = Json.createReader(input).readObject(); final Class<? extends CoffeeEvent> eventClass = (Class<? extends CoffeeEvent>) Class.forName(jsonObject.getString("class")); return eventClass.getConstructor(JsonObject.class).newInstance(jsonObject.getJsonObject("data")); } catch (Exception e) { logger.severe("Could not deserialize event: " + e.getMessage()); throw new SerializationException("Could not deserialize event", e); } }
EventDeserializer implements Deserializer<CoffeeEvent> { @Override public CoffeeEvent deserialize(final String topic, final byte[] data) { try (ByteArrayInputStream input = new ByteArrayInputStream(data)) { final JsonObject jsonObject = Json.createReader(input).readObject(); final Class<? extends CoffeeEvent> eventClass = (Class<? extends CoffeeEvent>) Class.forName(jsonObject.getString("class")); return eventClass.getConstructor(JsonObject.class).newInstance(jsonObject.getJsonObject("data")); } catch (Exception e) { logger.severe("Could not deserialize event: " + e.getMessage()); throw new SerializationException("Could not deserialize event", e); } } }
EventDeserializer implements Deserializer<CoffeeEvent> { @Override public CoffeeEvent deserialize(final String topic, final byte[] data) { try (ByteArrayInputStream input = new ByteArrayInputStream(data)) { final JsonObject jsonObject = Json.createReader(input).readObject(); final Class<? extends CoffeeEvent> eventClass = (Class<? extends CoffeeEvent>) Class.forName(jsonObject.getString("class")); return eventClass.getConstructor(JsonObject.class).newInstance(jsonObject.getJsonObject("data")); } catch (Exception e) { logger.severe("Could not deserialize event: " + e.getMessage()); throw new SerializationException("Could not deserialize event", e); } }  }
EventDeserializer implements Deserializer<CoffeeEvent> { @Override public CoffeeEvent deserialize(final String topic, final byte[] data) { try (ByteArrayInputStream input = new ByteArrayInputStream(data)) { final JsonObject jsonObject = Json.createReader(input).readObject(); final Class<? extends CoffeeEvent> eventClass = (Class<? extends CoffeeEvent>) Class.forName(jsonObject.getString("class")); return eventClass.getConstructor(JsonObject.class).newInstance(jsonObject.getJsonObject("data")); } catch (Exception e) { logger.severe("Could not deserialize event: " + e.getMessage()); throw new SerializationException("Could not deserialize event", e); } }  @Override void configure(final Map<String, ?> configs, final boolean isKey); @Override CoffeeEvent deserialize(final String topic, final byte[] data); @Override void close(); }
EventDeserializer implements Deserializer<CoffeeEvent> { @Override public CoffeeEvent deserialize(final String topic, final byte[] data) { try (ByteArrayInputStream input = new ByteArrayInputStream(data)) { final JsonObject jsonObject = Json.createReader(input).readObject(); final Class<? extends CoffeeEvent> eventClass = (Class<? extends CoffeeEvent>) Class.forName(jsonObject.getString("class")); return eventClass.getConstructor(JsonObject.class).newInstance(jsonObject.getJsonObject("data")); } catch (Exception e) { logger.severe("Could not deserialize event: " + e.getMessage()); throw new SerializationException("Could not deserialize event", e); } }  @Override void configure(final Map<String, ?> configs, final boolean isKey); @Override CoffeeEvent deserialize(final String topic, final byte[] data); @Override void close();  }