+ protected Object prepareForwardedReadyTransaction(ShardDataTreeCohort cohort, String transactionID,
+ short version, boolean doCommitOnReady) {
+ ShardDataTreeTransactionParent mockParent = mock(ShardDataTreeTransactionParent.class);
+ doReturn(cohort).when(mockParent).finishTransaction(any(ReadWriteShardDataTreeTransaction.class));
+ doNothing().when(mockParent).abortTransaction(any(AbstractShardDataTreeTransaction.class));
+ return new ForwardedReadyTransaction(transactionID, version,
+ new ReadWriteShardDataTreeTransaction(mockParent, transactionID,
+ mock(DataTreeModification.class)), true, doCommitOnReady);
+ }
+
+ protected Object prepareReadyTransactionMessage(boolean remoteReadWriteTransaction, Shard shard, ShardDataTreeCohort cohort,
+ String transactionID,
+ MutableCompositeModification modification) {
+ return prepareReadyTransactionMessage(remoteReadWriteTransaction, shard, cohort, transactionID, modification, false);
+ }
+
+ protected void setupCohortDecorator(Shard shard, final ShardDataTreeCohort cohort) {
+ shard.getCommitCoordinator().setCohortDecorator(new ShardCommitCoordinator.CohortDecorator() {
+ @Override
+ public ShardDataTreeCohort decorate(String transactionID, ShardDataTreeCohort actual) {
+ return cohort;
+ }
+ });
+ }
+
+ protected BatchedModifications prepareBatchedModifications(String transactionID,
+ MutableCompositeModification modification) {
+ return prepareBatchedModifications(transactionID, modification, false);
+ }
+
+ private BatchedModifications prepareBatchedModifications(String transactionID,
+ MutableCompositeModification modification,
+ boolean doCommitOnReady) {
+ final BatchedModifications batchedModifications = new BatchedModifications(transactionID, CURRENT_VERSION, null);
+ batchedModifications.addModification(modification);
+ batchedModifications.setReady(true);
+ batchedModifications.setDoCommitOnReady(doCommitOnReady);
+ batchedModifications.setTotalMessagesSent(1);
+ return batchedModifications;
+ }