EODTradingStrategy implements Level1QuoteListener, OrderEventListener, BrokerErrorListener { protected boolean setAllPricesInitialized() { if (allPricesInitialized) { return true; } for (Ticker ticker : longShortPairMap.keySet()) { if (lastPriceMap.get(ticker) == null) { return false; } if (lastPriceMap.get(longShortPairMap.get(ticker)) == null) { return false; } } return true; }  void start(String propFile); synchronized void placeMOCOrders(Ticker longTicker, Ticker shortTicker, ZonedDateTime lastReportedTime); @Override void orderEvent(OrderEvent event); @Override void quoteRecieved(ILevel1Quote quote); ZonedDateTime getNextBusinessDay(ZonedDateTime date); @Override void brokerErrorFired(BrokerError error); static void main(String[] args);  }
@Test public void testSetAllPricesInitialized() { Map mockLastPriceMap = mock(Map.class); strategy.lastPriceMap = mockLastPriceMap; strategy.longShortPairMap.put(longTicker, shortTicker); when(mockLastPriceMap.get(longTicker)).thenReturn(55.5); when(mockLastPriceMap.get(shortTicker)).thenReturn(20.5); assertFalse(strategy.allPricesInitialized); assertTrue(strategy.setAllPricesInitialized()); }
@Test public void testSetAllPricesInitialized_LongNotInitialized() { Map mockLastPriceMap = mock(Map.class); strategy.lastPriceMap = mockLastPriceMap; strategy.longShortPairMap.put(longTicker, shortTicker); when(mockLastPriceMap.get(longTicker)).thenReturn(null); when(mockLastPriceMap.get(shortTicker)).thenReturn(20.5); assertFalse(strategy.allPricesInitialized); assertFalse(strategy.setAllPricesInitialized()); }
@Test public void testSetAllPricesInitialized_ShortNotInitialized() { Map mockLastPriceMap = mock(Map.class); strategy.lastPriceMap = mockLastPriceMap; strategy.longShortPairMap.put(longTicker, shortTicker); when(mockLastPriceMap.get(longTicker)).thenReturn(50.0); when(mockLastPriceMap.get(shortTicker)).thenReturn(null); assertFalse(strategy.allPricesInitialized); assertFalse(strategy.setAllPricesInitialized()); }
@Test public void testSetAllPricesInitialized_AlreadyInitialized() { strategy.allPricesInitialized = true; Map mockLastPriceMap = mock(Map.class); strategy.lastPriceMap = mockLastPriceMap; assertTrue(strategy.setAllPricesInitialized()); verify(mockLastPriceMap, never()).get(longTicker); verify(mockLastPriceMap, never()).get(shortTicker); }