### Question:
TransactionCommittingResponseUnpacker extends LifecycleAdapter implements ResponseUnpacker { @Override public void unpackResponse( Response<?> response, TxHandler txHandler ) throws Exception { if ( stopped ) { throw new IllegalStateException( "Component is currently stopped" ); } BatchingResponseHandler responseHandler = new BatchingResponseHandler( maxBatchSize, batchCommitter, obligationFulfiller, txHandler, versionContextSupplier, log ); try { response.accept( responseHandler ); } finally { responseHandler.applyQueuedTransactions(); } } TransactionCommittingResponseUnpacker( DependencyResolver dependencies, int maxBatchSize,
            long idReuseSafeZoneTime );  TransactionCommittingResponseUnpacker( Dependencies dependencies, int maxBatchSize,
            long idReuseSafeZoneTime ); @Override void unpackResponse( Response<?> response, TxHandler txHandler ); @Override void start(); @Override void stop(); static final int DEFAULT_BATCH_SIZE; }### Answer:
@Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable { int maxBatchSize = 10; long idReuseSafeZoneTime = 100; Dependencies dependencies = mock( Dependencies.class ); TransactionObligationFulfiller fulfiller = mock( TransactionObligationFulfiller.class ); when( dependencies.obligationFulfiller() ).thenReturn( fulfiller ); when( dependencies.logService() ).thenReturn( NullLogService.getInstance() ); when( dependencies.versionContextSupplier() ).thenReturn( EmptyVersionContextSupplier.EMPTY ); KernelTransactions kernelTransactions = mock( KernelTransactions.class ); when( dependencies.kernelTransactions() ).thenReturn( kernelTransactions ); TransactionCommitProcess commitProcess = mock( TransactionCommitProcess.class ); when( dependencies.commitProcess() ).thenReturn( commitProcess ); TransactionCommittingResponseUnpacker unpacker = life.add( new TransactionCommittingResponseUnpacker( dependencies, maxBatchSize, idReuseSafeZoneTime ) ); int txCount = maxBatchSize; int doesNotMatter = 1; unpacker.unpackResponse( new DummyTransactionResponse( doesNotMatter, txCount, idReuseSafeZoneTime + 1 ), NO_OP_TX_HANDLER ); InOrder inOrder = inOrder( commitProcess, kernelTransactions ); inOrder.verify( commitProcess, times( 1 ) ).commit( any(), any(), any() ); inOrder.verify( kernelTransactions, times( 1 ) ).unblockNewTransactions(); }
@Test public void shouldAwaitTransactionObligationsToBeFulfilled() throws Throwable { Dependencies dependencies = mock( Dependencies.class ); TransactionObligationFulfiller fulfiller = mock( TransactionObligationFulfiller.class ); when( dependencies.obligationFulfiller() ).thenReturn( fulfiller ); when( dependencies.logService() ).thenReturn( NullLogService.getInstance() ); TransactionCommittingResponseUnpacker unpacker = life.add( new TransactionCommittingResponseUnpacker( dependencies, 10, 0 ) ); unpacker.unpackResponse( new DummyObligationResponse( 4 ), NO_OP_TX_HANDLER ); verify( fulfiller, times( 1 ) ).fulfill( 4L ); }
@Test public void shouldCommitTransactionsInBatches() throws Exception { Dependencies dependencies = mock( Dependencies.class ); TransactionCountingTransactionCommitProcess commitProcess = new TransactionCountingTransactionCommitProcess(); when( dependencies.commitProcess() ).thenReturn( commitProcess ); when( dependencies.logService() ).thenReturn( NullLogService.getInstance() ); when( dependencies.versionContextSupplier() ).thenReturn( EmptyVersionContextSupplier.EMPTY ); KernelTransactions kernelTransactions = mock( KernelTransactions.class ); when( dependencies.kernelTransactions() ).thenReturn( kernelTransactions ); TransactionCommittingResponseUnpacker unpacker = life.add( new TransactionCommittingResponseUnpacker( dependencies, 5, 0 ) ); unpacker.unpackResponse( new DummyTransactionResponse( BASE_TX_ID + 1, 7 ), NO_OP_TX_HANDLER ); commitProcess.assertBatchSize( 5 ); commitProcess.assertBatchSize( 2 ); commitProcess.assertNoMoreBatches(); }