@Test public final void testDeserialize() { final int objByteCount = 1024; final byte[] receivedBytes = new byte[objByteCount + 1]; final DomainEvent event = mock(DomainEvent.class); final VersioningSerializer serializer = new VersioningSerializer() { @Override public final Object deserialize(final InputStream in) throws IOException, DeserializationException { assertThat(in.read(receivedBytes)).isEqualTo(objByteCount); return event; } @Override public final void serialize(final OutputStream out, final Object obj) throws IOException { } }; final VersioningEventSerializer testee = new VersioningEventSerializer(serializer, 512); final byte[] objBytes = new byte[objByteCount]; new Random().nextBytes(objBytes); final DomainEvent result = testee.deserialize(objBytes); assertThat(result).isSameAs(event); assertThat(Arrays.copyOf(receivedBytes, objByteCount)).isEqualTo(objBytes); }
@Override public final DomainEvent deserialize(final byte[] serializedEvent) { final ByteArrayInputStream in = new ByteArrayInputStream(serializedEvent); try { return (DomainEvent) serializer.deserialize(in); } catch (final IOException ex) { throw new RuntimeException(ex); } catch (final DeserializationException ex) { throw new RuntimeException(ex); } }
VersioningEventSerializer implements EventSerializer { @Override public final DomainEvent deserialize(final byte[] serializedEvent) { final ByteArrayInputStream in = new ByteArrayInputStream(serializedEvent); try { return (DomainEvent) serializer.deserialize(in); } catch (final IOException ex) { throw new RuntimeException(ex); } catch (final DeserializationException ex) { throw new RuntimeException(ex); } } }
VersioningEventSerializer implements EventSerializer { @Override public final DomainEvent deserialize(final byte[] serializedEvent) { final ByteArrayInputStream in = new ByteArrayInputStream(serializedEvent); try { return (DomainEvent) serializer.deserialize(in); } catch (final IOException ex) { throw new RuntimeException(ex); } catch (final DeserializationException ex) { throw new RuntimeException(ex); } } VersioningEventSerializer(final VersioningSerializer serializer);  VersioningEventSerializer(final VersioningSerializer serializer, final int bufSize); }
VersioningEventSerializer implements EventSerializer { @Override public final DomainEvent deserialize(final byte[] serializedEvent) { final ByteArrayInputStream in = new ByteArrayInputStream(serializedEvent); try { return (DomainEvent) serializer.deserialize(in); } catch (final IOException ex) { throw new RuntimeException(ex); } catch (final DeserializationException ex) { throw new RuntimeException(ex); } } VersioningEventSerializer(final VersioningSerializer serializer);  VersioningEventSerializer(final VersioningSerializer serializer, final int bufSize); @Override final DomainEvent deserialize(final byte[] serializedEvent); @Override final byte[] serialize(final DomainEvent event); final VersioningSerializer getSerializer(); final int getBufSize(); }
VersioningEventSerializer implements EventSerializer { @Override public final DomainEvent deserialize(final byte[] serializedEvent) { final ByteArrayInputStream in = new ByteArrayInputStream(serializedEvent); try { return (DomainEvent) serializer.deserialize(in); } catch (final IOException ex) { throw new RuntimeException(ex); } catch (final DeserializationException ex) { throw new RuntimeException(ex); } } VersioningEventSerializer(final VersioningSerializer serializer);  VersioningEventSerializer(final VersioningSerializer serializer, final int bufSize); @Override final DomainEvent deserialize(final byte[] serializedEvent); @Override final byte[] serialize(final DomainEvent event); final VersioningSerializer getSerializer(); final int getBufSize();  }