StreamService { public List<StreamSession> listStreams(Node node) throws ReaperException { try { LOG.debug("Pulling streams for node {}", node); return pullStreamInfo(node); } catch (ReaperException | InterruptedException | IOException e) { LOG.info("Pulling streams failed: {}", e.getMessage()); throw new ReaperException(e); } } private  StreamService(Supplier<ClusterFacade> clusterFacadeSupplier); static StreamService create(AppContext context); List<StreamSession> listStreams(Node node);  }
@Test public void testListStreams() throws ReaperException, ClassNotFoundException, InterruptedException { JmxProxy proxy = JmxProxyTest.mockJmxProxyImpl(); StreamManagerMBean streamingManagerMBean = Mockito.mock(StreamManagerMBean.class); JmxProxyTest.mockGetStreamManagerMBean(proxy, streamingManagerMBean); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connectAny(Mockito.anyList())).thenReturn(proxy); ClusterFacade clusterFacadeSpy = Mockito.spy(ClusterFacade.create(cxt)); Mockito.doReturn("dc1").when(clusterFacadeSpy).getDatacenter(any()); StreamService .create(() -> clusterFacadeSpy) .listStreams(Node.builder().withHostname("127.0.0.1").build()); verify(streamingManagerMBean, times(1)).getCurrentStreams(); }