CommitTransactionPayload extends IdentifiablePayload<TransactionIdentifier> implements Serializable { public static @NonNull CommitTransactionPayload create(final TransactionIdentifier transactionId, final DataTreeCandidate candidate, final PayloadVersion version, final int initialSerializedBufferCapacity) throws IOException { final ChunkedOutputStream cos = new ChunkedOutputStream(initialSerializedBufferCapacity); try (DataOutputStream dos = new DataOutputStream(cos)) { transactionId.writeTo(dos); DataTreeCandidateInputOutput.writeDataTreeCandidate(dos, version, candidate); } final Variant<byte[], ChunkedByteArray> source = cos.toVariant(); LOG.debug("Initial buffer capacity {}, actual serialized size {}", initialSerializedBufferCapacity, cos.size()); return source.isFirst() ? new Simple(source.getFirst()) : new Chunked(source.getSecond()); } CommitTransactionPayload(); static @NonNull CommitTransactionPayload create(final TransactionIdentifier transactionId,
            final DataTreeCandidate candidate, final PayloadVersion version, final int initialSerializedBufferCapacity); @VisibleForTesting static @NonNull CommitTransactionPayload create(final TransactionIdentifier transactionId,
            final DataTreeCandidate candidate, final PayloadVersion version); @VisibleForTesting static @NonNull CommitTransactionPayload create(final TransactionIdentifier transactionId,
            final DataTreeCandidate candidate); @NonNull Entry<TransactionIdentifier, DataTreeCandidateWithVersion> getCandidate(); final @NonNull Entry<TransactionIdentifier, DataTreeCandidateWithVersion> getCandidate(
            final ReusableStreamReceiver receiver); @Override TransactionIdentifier getIdentifier(); Entry<TransactionIdentifier, DataTreeCandidateWithVersion> acquireCandidate();  }
@Test public void testCandidateSerialization() throws IOException { final CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate); assertEquals("payload size", 156, payload.size()); }