@Test public void testSellTransactionExecuted() throws Exception { final Date time = currentTime(); final BigMoney executedMoney = BigMoney.of(Constants.DEFAULT_CURRENCY_UNIT, 30); final BigMoney executedCommission = BigMoney.of(Constants.CURRENCY_UNIT_BTC, 30); final BigMoney executed = BigMoney.of(Constants.CURRENCY_UNIT_BTC, 10); final BigMoney item = BigMoney.of(Constants.CURRENCY_UNIT_BTC, 10); final BigMoney price = BigMoney.of(Constants.DEFAULT_CURRENCY_UNIT, 10); final BigMoney money = BigMoney.of(Constants.DEFAULT_CURRENCY_UNIT, 10); final BigMoney commission = BigMoney.of(Constants.CURRENCY_UNIT_BTC, 10); final TransactionEntry entry = new TransactionEntry(); entry.setState(TransactionState.STARTED); entry.setCommission(executedCommission); entry.setExecutedMoney(executedMoney); entry.setAmountOfExecutedItem(executed); when(transactionQueryRepository.findOne(eq(transactionIdentifier.toString()))) .thenReturn(entry); final SellTransactionExecutedEvent event = new SellTransactionExecutedEvent(transactionIdentifier, coinIdentifier, item, price, money, commission, time); listener.handleEvent(event); ArgumentCaptor<TransactionEntry> captor = ArgumentCaptor.forClass(TransactionEntry.class); verify(transactionQueryRepository).save(captor.capture()); final TransactionEntry saved = captor.getValue(); assertThat(saved, notNullValue()); assertThat(saved.getState(), equalTo(TransactionState.EXECUTED)); assertThat(saved.getCommission(), equalTo(commission.plus(executedCommission))); assertThat(saved.getAmountOfExecutedItem(), equalTo(executed.plus(item))); assertThat(saved.getExecutedMoney(), equalTo(money.plus(executedMoney))); }
@EventHandler public void handleEvent(BuyTransactionStartedEvent event) { startTransaction(event, TransactionType.BUY); }
TransactionEventListener { @EventHandler public void handleEvent(BuyTransactionStartedEvent event) { startTransaction(event, TransactionType.BUY); } }
TransactionEventListener { @EventHandler public void handleEvent(BuyTransactionStartedEvent event) { startTransaction(event, TransactionType.BUY); }  }
TransactionEventListener { @EventHandler public void handleEvent(BuyTransactionStartedEvent event) { startTransaction(event, TransactionType.BUY); }  @EventHandler void handleEvent(BuyTransactionStartedEvent event); @EventHandler void handleEvent(SellTransactionStartedEvent event); @EventHandler void handleEvent(BuyTransactionCancelledEvent event); @EventHandler void handleEvent(SellTransactionCancelledEvent event); @EventHandler void handleEvent(BuyTransactionConfirmedEvent event); @EventHandler void handleEvent(SellTransactionConfirmedEvent event); @EventHandler void handleEvent(BuyTransactionExecutedEvent event); @EventHandler void handleEvent(SellTransactionExecutedEvent event); @EventHandler void handleEvent(BuyTransactionPartiallyExecutedEvent event); @EventHandler void handleEvent(SellTransactionPartiallyExecutedEvent event); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setOrderBookQueryRepository(OrderBookQueryRepository orderBookQueryRepository); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setTransactionQueryRepository(TransactionQueryRepository transactionQueryRepository); }
TransactionEventListener { @EventHandler public void handleEvent(BuyTransactionStartedEvent event) { startTransaction(event, TransactionType.BUY); }  @EventHandler void handleEvent(BuyTransactionStartedEvent event); @EventHandler void handleEvent(SellTransactionStartedEvent event); @EventHandler void handleEvent(BuyTransactionCancelledEvent event); @EventHandler void handleEvent(SellTransactionCancelledEvent event); @EventHandler void handleEvent(BuyTransactionConfirmedEvent event); @EventHandler void handleEvent(SellTransactionConfirmedEvent event); @EventHandler void handleEvent(BuyTransactionExecutedEvent event); @EventHandler void handleEvent(SellTransactionExecutedEvent event); @EventHandler void handleEvent(BuyTransactionPartiallyExecutedEvent event); @EventHandler void handleEvent(SellTransactionPartiallyExecutedEvent event); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setOrderBookQueryRepository(OrderBookQueryRepository orderBookQueryRepository); @SuppressWarnings("SpringJavaAutowiringInspection") @Autowired void setTransactionQueryRepository(TransactionQueryRepository transactionQueryRepository);  }