IBQuoteEngine extends AbstractIBQuoteEngine { @Override public void fireLevel1Quote(ILevel1Quote quote) { super.fireLevel1Quote(quote); if (quote.containsType(QuoteType.CLOSE) ) { closeQuoteMap.put(quote.getTicker(), quote); } if (quote.containsType(QuoteType.OPEN) ) { openQuoteMap.put(quote.getTicker(), quote); } } IBQuoteEngine(IBSocket ibSocket); @Override boolean isConnected(); void tickSize(int tickerId, int field, int size); void tickPrice(int tickerId, int field, double price, int canAutoExecute); void updateMktDepth(int tickerId, int position, int operation, int side, double price, int size); void updateMktDepth2(int tickerId, int position, String marketMaker, int operation, int side, double price, int size); void error(Exception e); void error(String str); void error(int id, int errorCode, String errorMsg); @Override void subscribeMarketDepth(Ticker ticker, Level2QuoteListener listener); @Override void unsubscribeMarketDepth(Ticker ticker, Level2QuoteListener listener); @Override synchronized void subscribeLevel1(Ticker ticker, Level1QuoteListener listener); @Override void unsubscribeLevel1(Ticker ticker, Level1QuoteListener listener); Date getServerTime(); void startEngine(Properties props); void stopEngine(); void startEngine(); boolean started(); IBSocket getIbSocket(); String getName(); void setName(String name); @Override void fireLevel1Quote(ILevel1Quote quote); @Override void useDelayedData(boolean useDelayed);  }
@Test public void testFireLevel1Quote_Close() { ILevel1Quote quote = Mockito.mock(ILevel1Quote.class); Ticker ticker = new StockTicker("abc"); when(quote.containsType(QuoteType.CLOSE)).thenReturn(true); when(quote.getTicker()).thenReturn(ticker); ibQuoteEngine.fireLevel1Quote(quote); assertEquals(1, ibQuoteEngine.closeQuoteMap.size()); assertEquals(quote, ibQuoteEngine.closeQuoteMap.get(ticker)); assertTrue(ibQuoteEngine.openQuoteMap.isEmpty()); }
@Test public void testFireLevel1Quote_Open() { ILevel1Quote quote = Mockito.mock(ILevel1Quote.class); Ticker ticker = new StockTicker("abc"); when(quote.containsType(QuoteType.OPEN)).thenReturn(true); when(quote.getTicker()).thenReturn(ticker); ibQuoteEngine.fireLevel1Quote(quote); assertEquals(1, ibQuoteEngine.openQuoteMap.size()); assertEquals(quote, ibQuoteEngine.openQuoteMap.get(ticker)); assertTrue(ibQuoteEngine.closeQuoteMap.isEmpty()); }