mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/channel/TestChannelMgrImpl.java
@Test
    public void testGetChannelsByType()
    {
        //behavior for remote lookup
        TransportChannel remoteChan = createMockTransportChannel("transport", "localaddr", 
                "remoteaddr", ChannelStatus.Unknown);
        
        TransportChannel remoteChan1 = createMockTransportChannel("transport1", "localaddr1", 
                "remoteaddr1", ChannelStatus.Unknown);
        
        TransportChannel remoteChan2 = createMockTransportChannel("transport2", "localaddr2", 
                "remoteaddr2", ChannelStatus.Unknown);
        
        List<RemoteChannel> listChans = new ArrayList<RemoteChannel>();
        listChans.add(remoteChan);        
        
        //mocking a socket channel
        SocketChannel socChannel = createMockSocketChannel("localhost", 3001, ChannelStatus.Active);
        
        List<RemoteChannel> listChans2 = new ArrayList<RemoteChannel>();
        listChans2.add(socChannel);
        listChans2.add(remoteChan1);
        listChans2.add(remoteChan2);
        
        //mocking behavior
        when(m_RemoteChannelLookup.getChannels(8523)).thenReturn(listChans);
        when(m_RemoteChannelLookup.getChannels(1478)).thenReturn(listChans2);
        
        //replay
        List<Channel> channels8523Trans = m_SUT.getChannelsForController(8523, RemoteChannelTypeEnum.TRANSPORT);
        List<Channel> channels8523Sock = m_SUT.getChannelsForController(8523, RemoteChannelTypeEnum.SOCKET);
        List<Channel> channels1478Trans = m_SUT.getChannelsForController(1478, RemoteChannelTypeEnum.TRANSPORT);
        List<Channel> channels1478Sock = m_SUT.getChannelsForController(1478, RemoteChannelTypeEnum.SOCKET);
        
        //check that there are channels returned for the different controllers
        assertThat(channels8523Trans.size(), is(1));
        assertThat(channels8523Sock.size(), is(0));
        assertThat(channels1478Sock.size(), is(1));
        assertThat(channels1478Trans.size(), is(2));    
        
        //check that info with in the abstract base channel type is correct, because the lists are Channel models and 
        //not remote channels cannot do hasItem for the remote channels mocked.
        assertThat(channels8523Trans.get(0).getChannelType(), is(RemoteChannelTypeEnum.TRANSPORT));
        assertThat(channels8523Trans.get(0).getControllerId(), is(8523));
        assertThat(channels1478Sock.get(0).getChannelType(), is(RemoteChannelTypeEnum.SOCKET));
        assertThat(channels1478Sock.get(0).getControllerId(), is(1478));
        assertThat(channels1478Trans.get(0).getChannelType(), is(RemoteChannelTypeEnum.TRANSPORT));
        assertThat(channels1478Trans.get(0).getControllerId(), is(1478));
    }
/**
     * Test getting all channels known to the system.
     * Verify that the correct channel types are returned for the controller id referenced.
     */
Test getting all channels known to the system.
Verify that the correct channel types are returned for the controller id referenced.
Test getting all channels known to the system . Verify that the correct channel types are returned for the controller id referenced .
@Test
    public void testGetChannelsByType()
    {
        TransportChannel remoteChan = createMockTransportChannel("transport", "localaddr", 
                "remoteaddr", ChannelStatus.Unknown);
        TransportChannel remoteChan1 = createMockTransportChannel("transport1", "localaddr1", 
                "remoteaddr1", ChannelStatus.Unknown);
        TransportChannel remoteChan2 = createMockTransportChannel("transport2", "localaddr2", 
                "remoteaddr2", ChannelStatus.Unknown);
        List<RemoteChannel> listChans = new ArrayList<RemoteChannel>();
        listChans.add(remoteChan);        
        SocketChannel socChannel = createMockSocketChannel("localhost", 3001, ChannelStatus.Active);
        List<RemoteChannel> listChans2 = new ArrayList<RemoteChannel>();
        listChans2.add(socChannel);
        listChans2.add(remoteChan1);
        listChans2.add(remoteChan2);
        when(m_RemoteChannelLookup.getChannels(8523)).thenReturn(listChans);
        when(m_RemoteChannelLookup.getChannels(1478)).thenReturn(listChans2);
        List<Channel> channels8523Trans = m_SUT.getChannelsForController(8523, RemoteChannelTypeEnum.TRANSPORT);
        List<Channel> channels8523Sock = m_SUT.getChannelsForController(8523, RemoteChannelTypeEnum.SOCKET);
        List<Channel> channels1478Trans = m_SUT.getChannelsForController(1478, RemoteChannelTypeEnum.TRANSPORT);
        List<Channel> channels1478Sock = m_SUT.getChannelsForController(1478, RemoteChannelTypeEnum.SOCKET);
        assertThat(channels8523Trans.size(), is(1));
        assertThat(channels8523Sock.size(), is(0));
        assertThat(channels1478Sock.size(), is(1));
        assertThat(channels1478Trans.size(), is(2));    
        assertThat(channels8523Trans.get(0).getChannelType(), is(RemoteChannelTypeEnum.TRANSPORT));
        assertThat(channels8523Trans.get(0).getControllerId(), is(8523));
        assertThat(channels1478Sock.get(0).getChannelType(), is(RemoteChannelTypeEnum.SOCKET));
        assertThat(channels1478Sock.get(0).getControllerId(), is(1478));
        assertThat(channels1478Trans.get(0).getChannelType(), is(RemoteChannelTypeEnum.TRANSPORT));
        assertThat(channels1478Trans.get(0).getControllerId(), is(1478));
    }
@ Test public void testGetChannelsByType ( ) { TransportChannel remoteChan = createMockTransportChannel ( "transport" , "localaddr" , "remoteaddr" , ChannelStatus . Unknown ) ; TransportChannel remoteChan1 = createMockTransportChannel ( "transport1" , "localaddr1" , "remoteaddr1" , ChannelStatus . Unknown ) ; TransportChannel remoteChan2 = createMockTransportChannel ( "transport2" , "localaddr2" , "remoteaddr2" , ChannelStatus . Unknown ) ; List < RemoteChannel > listChans = new ArrayList < RemoteChannel > ( ) ; listChans . add ( remoteChan ) ; SocketChannel socChannel = createMockSocketChannel ( "localhost" , 3001 , ChannelStatus . Active ) ; List < RemoteChannel > listChans2 = new ArrayList < RemoteChannel > ( ) ; listChans2 . add ( socChannel ) ; listChans2 . add ( remoteChan1 ) ; listChans2 . add ( remoteChan2 ) ; when ( m_RemoteChannelLookup . getChannels ( 8523 ) ) . thenReturn ( listChans ) ; when ( m_RemoteChannelLookup . getChannels ( 1478 ) ) . thenReturn ( listChans2 ) ; List < Channel > channels8523Trans = m_SUT . getChannelsForController ( 8523 , RemoteChannelTypeEnum . TRANSPORT ) ; List < Channel > channels8523Sock = m_SUT . getChannelsForController ( 8523 , RemoteChannelTypeEnum . SOCKET ) ; List < Channel > channels1478Trans = m_SUT . getChannelsForController ( 1478 , RemoteChannelTypeEnum . TRANSPORT ) ; List < Channel > channels1478Sock = m_SUT . getChannelsForController ( 1478 , RemoteChannelTypeEnum . SOCKET ) ; assertThat ( channels8523Trans . size ( ) , is ( 1 ) ) ; assertThat ( channels8523Sock . size ( ) , is ( 0 ) ) ; assertThat ( channels1478Sock . size ( ) , is ( 1 ) ) ; assertThat ( channels1478Trans . size ( ) , is ( 2 ) ) ; assertThat ( channels8523Trans . get ( 0 ) . getChannelType ( ) , is ( RemoteChannelTypeEnum . TRANSPORT ) ) ; assertThat ( channels8523Trans . get ( 0 ) . getControllerId ( ) , is ( 8523 ) ) ; assertThat ( channels1478Sock . get ( 0 ) . getChannelType ( ) , is ( RemoteChannelTypeEnum . SOCKET ) ) ; assertThat ( channels1478Sock . get ( 0 ) . getControllerId ( ) , is ( 1478 ) ) ; assertThat ( channels1478Trans . get ( 0 ) . getChannelType ( ) , is ( RemoteChannelTypeEnum . TRANSPORT ) ) ; assertThat ( channels1478Trans . get ( 0 ) . getControllerId ( ) , is ( 1478 ) ) ; }
Test getting all channels known to the system.
Test getting all channels known to the system .
//behavior for remote lookup //mocking a socket channel //mocking behavior //replay //check that there are channels returned for the different controllers //check that info with in the abstract base channel type is correct, because the lists are Channel models and  //not remote channels cannot do hasItem for the remote channels mocked.