IBLevel2QuoteProcessor extends IBQuoteProcessor<Level2QuoteData> { protected void buildAndFireEvent(Ticker ticker, IMarketDepthBook book) { QuoteType type; if( book.getSide() == MarketDepthBook.Side.ASK ) { type = QuoteType.MARKET_DEPTH_ASK; } else { type = QuoteType.MARKET_DEPTH_BID; } quoteEngine.fireMarketDepthQuote(new Level2Quote(ticker, type, getTime(), book)); } IBLevel2QuoteProcessor(BlockingQueue<Level2QuoteData> queue, IQuoteEngine quoteEngine); void removeTicker( Ticker ticker );  }
@Test public void testBuildAndFireEvent_Bid() { final IQuoteEngine mockQuoteEngine = mockery.mock(IQuoteEngine.class, "new"); final IMarketDepthBook mockBook = mockery.mock(IMarketDepthBook.class); QuoteType type; MockIBLevel2QuoteProcessor processor = buildQuoteProcessor(false); processor.quoteEngine = mockQuoteEngine; CurrencyTicker ticker = getCurrencyTicker(); final Level2Quote quote = new Level2Quote(ticker, QuoteType.MARKET_DEPTH_BID, processor.date, mockBook); mockery.checking(new Expectations() { { one(mockBook).getSide(); will(returnValue(MarketDepthBook.Side.BID)); one(mockQuoteEngine).fireMarketDepthQuote(quote); } }); processor.buildAndFireEvent(ticker, mockBook); mockery.assertIsSatisfied(); }
@Test public void testBuildAndFireEvent_Ask() { final IQuoteEngine mockQuoteEngine = mockery.mock(IQuoteEngine.class, "new"); final IMarketDepthBook mockBook = mockery.mock(IMarketDepthBook.class); QuoteType type; MockIBLevel2QuoteProcessor processor = buildQuoteProcessor(false); processor.quoteEngine = mockQuoteEngine; CurrencyTicker ticker = getCurrencyTicker(); final Level2Quote quote = new Level2Quote(ticker, QuoteType.MARKET_DEPTH_ASK, processor.date, mockBook); mockery.checking(new Expectations() { { one(mockBook).getSide(); will(returnValue(MarketDepthBook.Side.ASK)); one(mockQuoteEngine).fireMarketDepthQuote(quote); } }); processor.buildAndFireEvent(ticker, mockBook); mockery.assertIsSatisfied(); }