### Question:
TradeServiceImpl implements TradeService { @Override public Trade addTrade(long assetId, AskOrder askOrder, BidOrder bidOrder) { final Block block = blockchain.getLastBlock(); final DbKey dbKey = tradeTable.getDbKey(askOrder.getId(), bidOrder.getId()); log.trace(">> addTrade() newDbKey={}, assetId={}, askOrder={}, bidOrder={}, height={}", dbKey, assetId, askOrder, bidOrder, block.getHeight()); Trade trade = new Trade( assetId, askOrder, bidOrder, dbKey, block.getId(), block.getHeight(), block.getTimestamp() ); tradeTable.insert(trade); log.trace("<< addTrade() assetId={}, askOrder={}, bidOrder={}, trade={}", assetId, askOrder, bidOrder, trade); return trade; } TradeServiceImpl(
        final DatabaseManager databaseManager,
        final Blockchain blockchain,
        final TradeTable tradeTable,
        final IteratorToStreamConverter<Trade> converter
    ); @Inject  TradeServiceImpl(
        final DatabaseManager databaseManager,
        final Blockchain blockchain,
        final TradeTable tradeTable
    ); @Override Stream<Trade> getAllTrades(int from, int to); @Override int getCount(); @Override Trade getTrade(long askOrderId, long bidOrderId); @Override Stream<Trade> getAssetTrades(long assetId, int from, int to); @Override List<Trade> getLastTrades(long[] assetIds); @Override Stream<Trade> getAccountTrades(long accountId, int from, int to); @Override Stream<Trade> getAccountAssetTrades(long accountId, long assetId, int from, int to); @Override Stream<Trade> getAskOrderTrades(long askOrderId, int from, int to); @Override Stream<Trade> getBidOrderTrades(long bidOrderId, int from, int to); @Override int getTradeCount(long assetId); @Override Trade addTrade(long assetId, AskOrder askOrder, BidOrder bidOrder);  }### Answer:
@Test void addTrade() { final long assetId = 1L; final AskOrder askOrder = mock(AskOrder.class); final BidOrder bidOrder = mock(BidOrder.class); final Block block = mock(Block.class); when(blockchain.getLastBlock()).thenReturn(block); final long askOrderId = 8L; final long bidOrderId = 9L; when(askOrder.getId()).thenReturn(askOrderId); when(bidOrder.getId()).thenReturn(bidOrderId); final DbKey dbKey = mock(DbKey.class); when(tradeTable.getDbKey(askOrderId, bidOrderId)).thenReturn(dbKey); final long blockId = 5L; when(block.getId()).thenReturn(blockId); final int height = 1040; when(block.getHeight()).thenReturn(height); final int timestamp = 999999; when(block.getTimestamp()).thenReturn(timestamp); final Trade trade = new Trade( assetId, askOrder, bidOrder, dbKey, block.getId(), block.getHeight(), block.getTimestamp() ); final Trade tradeActual = tradeService.addTrade(assetId, askOrder, bidOrder); verify(tradeTable).insert(trade); }