mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testGetChannels()
    {
        // add channels with these ids
        int systemIdA = 897;
        int systemIdB = 1417;
        int systemIdC = 321;
        
        // mock socket factory to create a different channel for each call to new instance
        RemoteChannel socketChannel1 = mock(SocketChannel.class);
        RemoteChannel socketChannel2 = mock(SocketChannel.class);
        RemoteChannel socketChannel3 = mock(SocketChannel.class);
        when(m_ServerSocketChannelInstance.getInstance()).thenReturn(socketChannel1, socketChannel2, socketChannel3);
        
        stubTransportChannel(m_TransportChannel, "tl1", "tl1:333", "tl1:444");
        
        // sync channels to different ids
        m_SUT.syncChannel(socketChannel1, systemIdA);
        m_SUT.syncChannel(socketChannel2, systemIdB);
        m_SUT.syncTransportChannel("tl1", "tl1:333", "tl1:444", systemIdC);
        m_SUT.syncChannel(socketChannel3, systemIdC);
        m_SUT.syncTransportChannel("tl1", "tl1:333", "tl1:444", systemIdA);
                
        //verify that there are two channels in the list for system A
        assertThat(m_SUT.getChannels(systemIdA).size(), is(2));
        //verify that there is one channel in the list for system B
        assertThat(m_SUT.getChannels(systemIdB).size(), is(1));
        //verify that there are two channels in the list for system C
        assertThat(m_SUT.getChannels(systemIdC).size(), is(2));
        
        //try to get channels for a system id that doesn't have any channels, should return an empty list
        List<RemoteChannel> channels = m_SUT.getChannels(3698);
        assertThat(channels.isEmpty(), is(true));
    }
/**
     * Verify that a list of channels is returned if multiple channels to one controller are registered.
     */
Verify that a list of channels is returned if multiple channels to one controller are registered.
Verify that a list of channels is returned if multiple channels to one controller are registered .
@Test
    public void testGetChannels()
    {
        int systemIdA = 897;
        int systemIdB = 1417;
        int systemIdC = 321;
        RemoteChannel socketChannel1 = mock(SocketChannel.class);
        RemoteChannel socketChannel2 = mock(SocketChannel.class);
        RemoteChannel socketChannel3 = mock(SocketChannel.class);
        when(m_ServerSocketChannelInstance.getInstance()).thenReturn(socketChannel1, socketChannel2, socketChannel3);
        stubTransportChannel(m_TransportChannel, "tl1", "tl1:333", "tl1:444");
        m_SUT.syncChannel(socketChannel1, systemIdA);
        m_SUT.syncChannel(socketChannel2, systemIdB);
        m_SUT.syncTransportChannel("tl1", "tl1:333", "tl1:444", systemIdC);
        m_SUT.syncChannel(socketChannel3, systemIdC);
        m_SUT.syncTransportChannel("tl1", "tl1:333", "tl1:444", systemIdA);
        assertThat(m_SUT.getChannels(systemIdA).size(), is(2));
        assertThat(m_SUT.getChannels(systemIdB).size(), is(1));
        assertThat(m_SUT.getChannels(systemIdC).size(), is(2));
        List<RemoteChannel> channels = m_SUT.getChannels(3698);
        assertThat(channels.isEmpty(), is(true));
    }
@ Test public void testGetChannels ( ) { int systemIdA = 897 ; int systemIdB = 1417 ; int systemIdC = 321 ; RemoteChannel socketChannel1 = mock ( SocketChannel . class ) ; RemoteChannel socketChannel2 = mock ( SocketChannel . class ) ; RemoteChannel socketChannel3 = mock ( SocketChannel . class ) ; when ( m_ServerSocketChannelInstance . getInstance ( ) ) . thenReturn ( socketChannel1 , socketChannel2 , socketChannel3 ) ; stubTransportChannel ( m_TransportChannel , "tl1" , "tl1:333" , "tl1:444" ) ; m_SUT . syncChannel ( socketChannel1 , systemIdA ) ; m_SUT . syncChannel ( socketChannel2 , systemIdB ) ; m_SUT . syncTransportChannel ( "tl1" , "tl1:333" , "tl1:444" , systemIdC ) ; m_SUT . syncChannel ( socketChannel3 , systemIdC ) ; m_SUT . syncTransportChannel ( "tl1" , "tl1:333" , "tl1:444" , systemIdA ) ; assertThat ( m_SUT . getChannels ( systemIdA ) . size ( ) , is ( 2 ) ) ; assertThat ( m_SUT . getChannels ( systemIdB ) . size ( ) , is ( 1 ) ) ; assertThat ( m_SUT . getChannels ( systemIdC ) . size ( ) , is ( 2 ) ) ; List < RemoteChannel > channels = m_SUT . getChannels ( 3698 ) ; assertThat ( channels . isEmpty ( ) , is ( true ) ) ; }
Verify that a list of channels is returned if multiple channels to one controller are registered.
Verify that a list of channels is returned if multiple channels to one controller are registered .
// add channels with these ids // mock socket factory to create a different channel for each call to new instance // sync channels to different ids //verify that there are two channels in the list for system A //verify that there is one channel in the list for system B //verify that there are two channels in the list for system C //try to get channels for a system id that doesn't have any channels, should return an empty list