IBRealTimeBarEngine implements IRealtimeBarEngine { @Override public boolean isConnected() { return quoteEngine.isConnected() && historicalDataProvider.isConnected(); } IBRealTimeBarEngine(IQuoteEngine quoteEngine, IHistoricalDataProvider historicalDataProvider); @Override boolean isConnected(); @Override void subscribeRealtimeBars(RealtimeBarRequest request, RealtimeBarListener listener); @Override void unsubscribeRealtimeBars(RealtimeBarRequest request, RealtimeBarListener listener);  }
@Test public void testIsConnected() { final IQuoteEngine mockQuoteEngine = mockery.mock(IQuoteEngine.class); final IHistoricalDataProvider mockHistoricalData = mockery.mock(IHistoricalDataProvider.class); mockery.checking( new Expectations() {{ one(mockQuoteEngine).isConnected(); will(returnValue(false)); one(mockQuoteEngine).isConnected(); will(returnValue(true)); one(mockHistoricalData).isConnected(); will(returnValue(false)); one(mockQuoteEngine).isConnected(); will(returnValue(true)); one(mockHistoricalData).isConnected(); will(returnValue(true)); } }); IBRealTimeBarEngine engine = new IBRealTimeBarEngine(mockQuoteEngine, mockHistoricalData); assertFalse( engine.isConnected() ); assertFalse( engine.isConnected() ); assertTrue( engine.isConnected() ); }