@Override public boolean visit( StorageCommand element ) throws IOException { return ((Command)element).handle( this ); } }
@Override public boolean visit( StorageCommand element ) throws IOException { for ( TransactionApplier applier : appliers ) { if ( ((Command)element).handle( applier ) ) { return true; } } return false; }
@Test public void testVisit() throws Exception { Command cmd = mock( Command.class ); // WHEN boolean result = facade.visit( cmd ); // THEN InOrder inOrder = inOrder( cmd ); inOrder.verify( cmd ).handle( txApplier1 ); inOrder.verify( cmd ).handle( txApplier2 ); inOrder.verify( cmd ).handle( txApplier3 ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); }
@Test public void shouldExecuteCommandsInTheSameOrderRegardlessOfItBeingRecoveredOrNot() throws Exception { // Given TransactionRecordState tx = injectAllPossibleCommands(); // When PhysicalTransactionRepresentation commands = transactionRepresentationOf( tx ); // Then final OrderVerifyingCommandHandler orderVerifyingCommandHandler = new OrderVerifyingCommandHandler(); commands.accept( element -> ((Command)element).handle( orderVerifyingCommandHandler ) ); }
ptx.accept( command -> ((Command)command).handle( new CommandVisitor.Adapter()
representation.accept( command -> ((Command)command).handle( new CommandVisitor.Adapter()
@Override public boolean visit( StorageCommand element ) throws IOException { for ( TransactionApplier applier : appliers ) { if ( ((Command)element).handle( applier ) ) { return true; } } return false; }
@Override public boolean visit( StorageCommand element ) throws IOException { return ((Command)element).handle( this ); } }