### Question:
TransactionBuilderImpl implements TransactionBuilder { public AppendRequest buildRequest() { return new AppendRequest( reqId, clientHighWaterMark, compileLockRequest(writeLocks), compileLockRequest(readLocks), compileLockRequest(appendLocks), header, data, Utils.checksum(data) ); } TransactionBuilderImpl(ReqId reqId, long clientHighWaterMark); @Override void setHeader(int header); @Override void setTransactionData(T transactionData, Serializer<T> serializer); @Override void setWriteLocks(List<PartitionLocalLock> locks); @Override void setReadLocks(List<PartitionLocalLock> locks); @Override void setAppendLocks(List<PartitionLocalLock> locks); AppendRequest buildRequest(); final ReqId reqId; final long clientHighWaterMark; }### Answer:
@Test public void test() { MockContext context = MockContext.builder() .data("good transaction") .writeLocks(1, 2, 3) .readLocks(4, 5, 6) .appendLocks(7, 8, 9) .build(); TransactionBuilderImpl builder = new TransactionBuilderImpl(new ReqId(111, 222, 333, 444), 999); context.execute(builder); AppendRequest request = builder.buildRequest(); assertEquals(new ReqId(111, 222, 333, 444), request.reqId); assertEquals(999, request.clientHighWaterMark); assertEquals("good transaction", new String(request.data, StandardCharsets.UTF_8)); int[] expectedWriteLockRequest = new int[]{ MockContext.makeLock(1).hashCode(), MockContext.makeLock(2).hashCode(), MockContext.makeLock(3).hashCode() }; int[] expectedReadLockRequest = new int[]{ MockContext.makeLock(4).hashCode(), MockContext.makeLock(5).hashCode(), MockContext.makeLock(6).hashCode() }; int[] expectedAppendLockRequest = new int[]{ MockContext.makeLock(7).hashCode(), MockContext.makeLock(8).hashCode(), MockContext.makeLock(9).hashCode() }; assertArrayEquals(expectedWriteLockRequest, request.writeLockRequest); assertArrayEquals(expectedReadLockRequest, request.readLockRequest); assertArrayEquals(expectedAppendLockRequest, request.appendLockRequest); }