@Test public final void testSerialize() throws IOException { final byte[] objBytes = new byte[2048]; new Random().nextBytes(objBytes); final VersioningSerializer serializer = new VersioningSerializer() { @Override public final Object deserialize(final InputStream in) throws IOException, DeserializationException { return null; } @Override public final void serialize(final OutputStream out, final Object obj) throws IOException { out.write(objBytes); } }; final VersioningEventSerializer testee = new VersioningEventSerializer(serializer, 512); final DomainEvent event = mock(DomainEvent.class); final byte[] result = testee.serialize(event); assertThat(result).isEqualTo(objBytes); }
@Override public final byte[] serialize(final DomainEvent event) { final ByteArrayOutputStream out = new ByteArrayOutputStream(bufSize); try { serializer.serialize(out, event); } catch (final IOException ex) { throw new RuntimeException(ex); } return out.toByteArray(); }
VersioningEventSerializer implements EventSerializer { @Override public final byte[] serialize(final DomainEvent event) { final ByteArrayOutputStream out = new ByteArrayOutputStream(bufSize); try { serializer.serialize(out, event); } catch (final IOException ex) { throw new RuntimeException(ex); } return out.toByteArray(); } }
VersioningEventSerializer implements EventSerializer { @Override public final byte[] serialize(final DomainEvent event) { final ByteArrayOutputStream out = new ByteArrayOutputStream(bufSize); try { serializer.serialize(out, event); } catch (final IOException ex) { throw new RuntimeException(ex); } return out.toByteArray(); } VersioningEventSerializer(final VersioningSerializer serializer);  VersioningEventSerializer(final VersioningSerializer serializer, final int bufSize); }
VersioningEventSerializer implements EventSerializer { @Override public final byte[] serialize(final DomainEvent event) { final ByteArrayOutputStream out = new ByteArrayOutputStream(bufSize); try { serializer.serialize(out, event); } catch (final IOException ex) { throw new RuntimeException(ex); } return out.toByteArray(); } 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 byte[] serialize(final DomainEvent event) { final ByteArrayOutputStream out = new ByteArrayOutputStream(bufSize); try { serializer.serialize(out, event); } catch (final IOException ex) { throw new RuntimeException(ex); } return out.toByteArray(); } 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();  }