### Question:
Protocol { public static String readString( ChannelBuffer buffer ) { return readString( buffer, buffer.readInt() ); } Protocol( int chunkSize, byte applicationProtocolVersion, byte internalProtocolVersion ); static void addLengthFieldPipes( ChannelPipeline pipeline, int frameLength ); static void writeString( ChannelBuffer buffer, String name ); static void writeChars( ChannelBuffer buffer, char[] chars ); static String readString( ChannelBuffer buffer ); static boolean readBoolean( ChannelBuffer buffer ); static String readString( ChannelBuffer buffer, int length ); static void assertChunkSizeIsWithinFrameSize( int chunkSize, int frameLength ); void serializeRequest( Channel channel, ChannelBuffer buffer, RequestType type, RequestContext ctx,
                                  Serializer payload ); Response<PAYLOAD> deserializeResponse( BlockingReadHandler<ChannelBuffer> reader,
            ByteBuffer input, long timeout,
            Deserializer<PAYLOAD> payloadDeserializer,
            ResourceReleaser channelReleaser,
            final LogEntryReader<ReadableClosablePositionAwareChannel> entryReader ); static final int MEGA; static final int DEFAULT_FRAME_LENGTH; static final ObjectSerializer<Integer> INTEGER_SERIALIZER; static final ObjectSerializer<Long> LONG_SERIALIZER; static final ObjectSerializer<Void> VOID_SERIALIZER; static final Deserializer<Integer> INTEGER_DESERIALIZER; static final Deserializer<Void> VOID_DESERIALIZER; static final Serializer EMPTY_SERIALIZER; }### Answer:
@Test public void shouldSerializeAndDeserializeTransactionRepresentation() throws Exception { PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation( justOneNode() ); byte[] additionalHeader = "extra".getBytes(); int masterId = 1; int authorId = 2; long timeStarted = 12345; long lastTxWhenStarted = 12; long timeCommitted = timeStarted + 10; transaction.setHeader( additionalHeader, masterId, authorId, timeStarted, lastTxWhenStarted, timeCommitted, -1 ); Protocol.TransactionSerializer serializer = new Protocol.TransactionSerializer( transaction ); ChannelBuffer buffer = new ChannelBufferWrapper( new InMemoryClosableChannel() ); serializer.write( buffer ); assertEquals( NeoStoreDataSource.DEFAULT_DATA_SOURCE_NAME, Protocol.readString( buffer ) ); VersionAwareLogEntryReader<ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader<>(); TransactionRepresentation readTransaction = new Protocol.TransactionRepresentationDeserializer( reader ) .read( buffer, ByteBuffer.allocate( 1000 ) ); assertArrayEquals( additionalHeader, readTransaction.additionalHeader() ); assertEquals( masterId, readTransaction.getMasterId() ); assertEquals( authorId, readTransaction.getAuthorId() ); assertEquals( timeStarted, readTransaction.getTimeStarted() ); assertEquals( lastTxWhenStarted, readTransaction.getLatestCommittedTxWhenStarted() ); assertEquals( timeCommitted, readTransaction.getTimeCommitted() ); }