BarBuilder implements IBarBuilder { protected final void setVolume(BigDecimal volume) { this.volume = this.volume.add(volume); } 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 testSetVolume() throws Exception { final SchedulerFactory mockFactory = mockery.mock(SchedulerFactory.class); final Scheduler mockScheduler = mockery.mock(Scheduler.class); final IHistoricalDataProvider mockHistoricalDataProvider = mockery.mock(IHistoricalDataProvider.class); Ticker ticker = new StockTicker("qqq"); final RealtimeBarRequest request = new RealtimeBarRequest(1, ticker, 1, LengthUnit.MINUTE); String jobName = RealtimeBarUtil.getJobName(request); final Trigger trigger = RealtimeBarUtil.getTrigger(jobName, request.getTimeInterval(), request.getTimeUnit()); final List<BarData> barList = new ArrayList<BarData>(); barList.add(new BarData(LocalDateTime.now(), new BigDecimal(2), new BigDecimal(3), new BigDecimal(2), new BigDecimal(2), new BigDecimal(10))); mockery.checking(new Expectations() { { one(mockFactory).getScheduler(); will(returnValue(mockScheduler)); one(mockHistoricalDataProvider).requestHistoricalData(request.getTicker(), 1, LengthUnit.DAY, request.getTimeInterval(), request.getTimeUnit(), IHistoricalDataProvider.ShowProperty.TRADES, false); will(returnValue(barList)); one(mockScheduler).scheduleJob(with(any(JobDetail.class)), with(any(Trigger.class))); one(mockScheduler).isStarted(); will(returnValue(true)); } }); BarBuilder builder = new BarBuilder(mockFactory, request, mockHistoricalDataProvider); assertEquals(new BigDecimal(10), builder.volume); builder.setVolume(new BigDecimal(100)); assertEquals(new BigDecimal(110), builder.volume); builder.setVolume(new BigDecimal(50)); assertEquals(new BigDecimal(160), builder.volume); mockery.assertIsSatisfied(); }