BarBuilder implements IBarBuilder { protected boolean validQuote( ILevel1Quote quote ) { if( isCurrency ) { return quote.containsType(QuoteType.BID) || quote.containsType(QuoteType.ASK); } else if( showProperty == IHistoricalDataProvider.ShowProperty.MIDPOINT ) { return quote.containsType(QuoteType.MIDPOINT); } else { return quote.containsType(QuoteType.LAST); } } protected  BarBuilder();  BarBuilder(SchedulerFactory schedulerFactory, RealtimeBarRequest request, IHistoricalDataProvider historicalDataProvider); void quoteRecieved(ILevel1Quote quote); @Override void addBarListener(RealtimeBarListener listener); @Override void removeBarListener(RealtimeBarListener listener); void buildBarAndFireEvents(); int getListenerCount(); void stop();  }
@Test public void testValidQuote() { Map<QuoteType,BigDecimal> quoteValues = new HashMap<>(); testBarBuilder.isCurrency = true; Level1Quote quote = new Level1Quote(null, null, quoteValues); assertFalse( testBarBuilder.validQuote(quote)); quoteValues.put(QuoteType.BID, BigDecimal.ONE); assertTrue( testBarBuilder.validQuote(quote)); quoteValues.clear(); quoteValues.put(QuoteType.ASK, BigDecimal.ONE); quote = new Level1Quote(null, null, quoteValues); assertTrue( testBarBuilder.validQuote(quote)); testBarBuilder.showProperty = IHistoricalDataProvider.ShowProperty.MIDPOINT; testBarBuilder.isCurrency = false; quoteValues.clear(); quoteValues.put(QuoteType.MIDPOINT, BigDecimal.ONE); quote = new Level1Quote(null, null, quoteValues); assertTrue( testBarBuilder.validQuote(quote) ); testBarBuilder.showProperty = IHistoricalDataProvider.ShowProperty.TRADES; testBarBuilder.isCurrency = false; quoteValues.clear(); quoteValues.put(QuoteType.LAST, BigDecimal.ONE); quote = new Level1Quote(null, null, quoteValues); assertTrue( testBarBuilder.validQuote(quote)); }