### Question:
TransactionRepresentationReplicatedTransaction implements ReplicatedTransaction { @Override public void marshal( WritableChannel writableChannel ) throws IOException { ReplicatedTransactionSerializer.marshal( writableChannel, this ); } TransactionRepresentationReplicatedTransaction( TransactionRepresentation tx ); @Override ChunkedInput<ByteBuf> encode(); @Override void marshal( WritableChannel writableChannel ); @Override TransactionRepresentation extract( TransactionRepresentationExtractor extractor ); TransactionRepresentation tx(); @Override void handle( ReplicatedContentHandler contentHandler );  }### Answer:
@Test public void shouldMarshalToSameByteIfByteBufBackedOrNot() throws IOException { PhysicalTransactionRepresentation expectedTx = new PhysicalTransactionRepresentation( Collections.singleton( new Command.NodeCommand( new NodeRecord( 1 ), new NodeRecord( 2 ) ) ) ); expectedTx.setHeader( new byte[0], 1, 2, 3, 4, 5, 6 ); TransactionRepresentationReplicatedTransaction replicatedTransaction = ReplicatedTransaction.from( expectedTx ); ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteBuf buffer = buffers.buffer(); OutputStreamWritableChannel outputStreamWritableChannel = new OutputStreamWritableChannel( stream ); NetworkWritableChannel networkWritableChannel = new NetworkWritableChannel( buffer ); replicatedTransaction.marshal( outputStreamWritableChannel ); replicatedTransaction.marshal( networkWritableChannel ); byte[] bufferArray = Arrays.copyOf( buffer.array(), buffer.writerIndex() ); Assertions.assertArrayEquals( bufferArray, stream.toByteArray() ); }