Search in sources :

Example 1 with StreamMonitorHelper

use of org.codice.alliance.video.ui.service.StreamMonitorHelper in project alliance by codice.

the class StreamMonitorHelperTest method setUp.

@Before
public void setUp() throws Exception {
    bundleContext = mock(BundleContext.class);
    uri = new URI(TEST_URL);
    List<ServiceReference<StreamMonitor>> serviceReferences = new ArrayList<>();
    udpStreamMonitor = mock(UdpStreamMonitor.class);
    ServiceReference<StreamMonitor> streamMonitorServiceReference = mock(ServiceReference.class);
    serviceReferences.add(streamMonitorServiceReference);
    when(bundleContext.getServiceReferences(eq(StreamMonitor.class), anyString())).thenReturn(serviceReferences);
    when(udpStreamMonitor.getTitle()).thenReturn(Optional.of("test"));
    when(udpStreamMonitor.getStreamUri()).thenReturn(Optional.of(uri));
    // when(udpStreamMonitor.startMonitoring()).thenReturn(Optional.of(uri));
    doAnswer(invocation -> {
        isMonitoring = true;
        return null;
    }).when(udpStreamMonitor).startMonitoring();
    doAnswer(invocation -> {
        isMonitoring = false;
        return null;
    }).when(udpStreamMonitor).stopMonitoring();
    when(bundleContext.getService(any(ServiceReference.class))).thenReturn(udpStreamMonitor);
    when(streamMonitorServiceReference.getProperty(anyString())).thenReturn(StreamMonitorHelper.SERVICE_PID);
    stream = new StreamMonitorHelper();
    stream.setContext(bundleContext);
}
Also used : StreamMonitorHelper(org.codice.alliance.video.ui.service.StreamMonitorHelper) UdpStreamMonitor(org.codice.alliance.video.stream.mpegts.UdpStreamMonitor) ArrayList(java.util.ArrayList) StreamMonitor(org.codice.alliance.video.stream.mpegts.StreamMonitor) UdpStreamMonitor(org.codice.alliance.video.stream.mpegts.UdpStreamMonitor) URI(java.net.URI) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference) Before(org.junit.Before)

Example 2 with StreamMonitorHelper

use of org.codice.alliance.video.ui.service.StreamMonitorHelper in project alliance by codice.

the class StreamMonitorHelperTest method testStreamMonitorsNullBundleContext.

@Test
public void testStreamMonitorsNullBundleContext() {
    StreamMonitorHelper stream = new StreamMonitorHelper();
    List<Map<String, Object>> list = stream.udpStreamMonitors();
    assertThat(list, nullValue());
}
Also used : StreamMonitorHelper(org.codice.alliance.video.ui.service.StreamMonitorHelper) HashMap(java.util.HashMap) Map(java.util.Map) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

StreamMonitorHelper (org.codice.alliance.video.ui.service.StreamMonitorHelper)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StreamMonitor (org.codice.alliance.video.stream.mpegts.StreamMonitor)1 UdpStreamMonitor (org.codice.alliance.video.stream.mpegts.UdpStreamMonitor)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BundleContext (org.osgi.framework.BundleContext)1 ServiceReference (org.osgi.framework.ServiceReference)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1