### Question:
CoreStateMachines { public CommandDispatcher commandDispatcher() { localDatabase.assertHealthy( IllegalStateException.class ); assert !runningBatch; runningBatch = true; return dispatcher; } CoreStateMachines(
            ReplicatedTransactionStateMachine replicatedTxStateMachine,
            ReplicatedTokenStateMachine labelTokenStateMachine,
            ReplicatedTokenStateMachine relationshipTypeTokenStateMachine,
            ReplicatedTokenStateMachine propertyKeyTokenStateMachine,
            ReplicatedLockTokenStateMachine replicatedLockTokenStateMachine,
            ReplicatedIdAllocationStateMachine idAllocationStateMachine,
            DummyMachine benchmarkMachine,
            LocalDatabase localDatabase,
            RecoverConsensusLogIndex consensusLogIndexRecovery ); CommandDispatcher commandDispatcher(); long getLastAppliedIndex(); void flush(); void addSnapshots( CoreSnapshot coreSnapshot ); void installSnapshots( CoreSnapshot coreSnapshot ); void installCommitProcess( TransactionCommitProcess localCommit );  }### Answer:
@Test public void shouldAllowForBatchingOfTransactions() { try ( CommandDispatcher dispatcher = coreStateMachines.commandDispatcher() ) { dispatcher.dispatch( replicatedTransaction, 0, callback ); dispatcher.dispatch( replicatedTransaction, 1, callback ); dispatcher.dispatch( replicatedTransaction, 2, callback ); } verifier.verify( txSM ).applyCommand( replicatedTransaction, 0, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 1, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 2, callback ); verifier.verify( txSM ).ensuredApplied(); verifier.verifyNoMoreInteractions(); }
@Test public void shouldApplyTransactionBatchAsSoonAsThereIsADifferentKindOfRequestInTheBatch() { try ( CommandDispatcher dispatcher = coreStateMachines.commandDispatcher() ) { dispatcher.dispatch( replicatedTransaction, 0, callback ); dispatcher.dispatch( replicatedTransaction, 1, callback ); dispatcher.dispatch( iAllocationRequest, 2, callback ); dispatcher.dispatch( replicatedTransaction, 3, callback ); dispatcher.dispatch( replicatedTransaction, 4, callback ); dispatcher.dispatch( relationshipTypeTokenRequest, 5, callback ); dispatcher.dispatch( replicatedTransaction, 6, callback ); dispatcher.dispatch( replicatedTransaction, 7, callback ); dispatcher.dispatch( lockTokenRequest, 8, callback ); dispatcher.dispatch( replicatedTransaction, 9, callback ); dispatcher.dispatch( replicatedTransaction, 10, callback ); } verifier.verify( txSM ).applyCommand( replicatedTransaction, 0, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 1, callback ); verifier.verify( txSM ).ensuredApplied(); verifier.verify( idAllocationSM ).applyCommand( iAllocationRequest, 2, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 3, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 4, callback ); verifier.verify( txSM ).ensuredApplied(); verifier.verify( relationshipTypeTokenSM ).applyCommand( relationshipTypeTokenRequest, 5, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 6, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 7, callback ); verifier.verify( txSM ).ensuredApplied(); verifier.verify( lockTokenSM ).applyCommand( lockTokenRequest, 8, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 9, callback ); verifier.verify( txSM ).applyCommand( replicatedTransaction, 10, callback ); verifier.verify( txSM ).ensuredApplied(); verifier.verifyNoMoreInteractions(); }