BitmexLevel1QuoteEngine extends QuoteEngine implements IQuoteListener, ITradeListener { @Override public void quoteUpdated(BitmexQuote quoteData) { logger.debug("Received from Bitmex: " + quoteData ); Ticker ticker = tickerMap.get(quoteData.getSymbol()); Map<QuoteType, BigDecimal> quoteMap = new HashMap<>(); quoteMap.put(QuoteType.ASK, new BigDecimal(quoteData.getAskPrice())); quoteMap.put(QuoteType.BID, new BigDecimal(quoteData.getBidPrice())); quoteMap.put(QuoteType.BID_SIZE, new BigDecimal(quoteData.getBidSize())); quoteMap.put(QuoteType.ASK_SIZE, new BigDecimal(quoteData.getAskSize())); quoteMap.put(QuoteType.MIDPOINT, new BigDecimal((quoteData.getAskPrice() + quoteData.getBidPrice()) / 2.0)); ZonedDateTime timestamp = getTimestamp(quoteData.getTimestamp()); Level1Quote quote = new Level1Quote(ticker, timestamp, quoteMap); fireLevel1Quote(quote); }  @Override void startEngine(); @Override void startEngine(Properties props); @Override void stopEngine(); @Override Date getServerTime(); @Override boolean started(); @Override boolean isConnected(); @Override void useDelayedData(boolean useDelayed); @Override void subscribeLevel1(Ticker ticker, Level1QuoteListener listener); @Override void quoteUpdated(BitmexQuote quoteData); @Override void tradeUpdated(BitmexTrade trade); int getMessageProcessorQueueSize();  }
@Test public void testQuoteUpdated() { Ticker ticker = new GenericTicker("ABC"); testQuoteEngine.tickerMap.put("ABC", ticker); String timestampString = "2018-07-24T16:45:32.739Z"; ZonedDateTime timestamp = ZonedDateTime.of(2018, 7, 24, 16, 45, 32, 739, ZoneId.of("GMT")); doNothing().when(testQuoteEngine).fireLevel1Quote(any(Level1Quote.class)); double bid = 1.53; double ask = 3.25; int bidSize = 22; int askSize = 333; BigDecimal expectedBid = new BigDecimal(bid); BigDecimal expectedAsk = new BigDecimal(ask); BigDecimal expectedBidSize = new BigDecimal(bidSize); BigDecimal expectedAskSize = new BigDecimal(askSize); BigDecimal expectedMidpoint = new BigDecimal((ask+bid)/2.0); Map<QuoteType, BigDecimal> quoteMap = new HashMap<>(); quoteMap.put(QuoteType.BID, expectedBid); quoteMap.put(QuoteType.ASK, expectedAsk); quoteMap.put(QuoteType.BID_SIZE, expectedBidSize); quoteMap.put(QuoteType.ASK_SIZE, expectedAskSize); quoteMap.put(QuoteType.MIDPOINT, expectedMidpoint); Level1Quote expectedQuote = new Level1Quote(ticker, timestamp, quoteMap); BitmexQuote data = new BitmexQuote(); data.setAskPrice(ask); data.setAskSize(askSize); data.setBidPrice(bid); data.setBidSize(bidSize); data.setTimestamp(timestampString); testQuoteEngine.quoteUpdated(data); verify(testQuoteEngine, times(1)).fireLevel1Quote(expectedQuote); System.out.println("Quote is: " + expectedQuote ); }