@Override public void publishAsClosed() { transactionIdStore.transactionClosed( id, 1, 2 ); }
@Override public void publishAsClosed() { transactionIdStore.transactionClosed( transactionId, logPosition.getLogVersion(), logPosition.getByteOffset() ); }
@Test public void shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() throws Exception { // GIVEN TransactionIdStore transactionIdStore = mock( TransactionIdStore.class ); TransactionAppender appender = new TestableTransactionAppender( transactionIdStore ); long txId = 11; when( transactionIdStore.nextCommittingTransactionId() ).thenReturn( txId ); IOException rootCause = new IOException( "Mock exception" ); StorageEngine storageEngine = mock( StorageEngine.class ); doThrow( new IOException( rootCause ) ).when( storageEngine ).apply( any( TransactionToApply.class ), any( TransactionApplicationMode.class ) ); TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess( appender, storageEngine ); TransactionToApply transaction = mockedTransaction(); // WHEN try { commitProcess.commit( transaction, commitEvent, INTERNAL ); } catch ( TransactionFailureException e ) { assertThat( e.getMessage(), containsString( "Could not apply the transaction to the store" ) ); assertTrue( contains( e, rootCause.getMessage(), rootCause.getClass() ) ); } // THEN // we can't verify transactionCommitted since that's part of the TransactionAppender, which we have mocked verify( transactionIdStore, times( 1 ) ).transactionClosed( eq( txId ), anyLong(), anyLong() ); }
verify( transactionIdStore, never() ).transactionClosed( eq( txId ), anyLong(), anyLong() ); verify( databaseHealth ).panic( failure );
verify( transactionIdStore, never() ).transactionClosed( eq( txId ), anyLong(), anyLong() ); verify( databaseHealth ).panic( failure );
@Override public void publishAsClosed() { transactionIdStore.transactionClosed( transactionId, logPosition.getLogVersion(), logPosition.getByteOffset() ); }