mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestControllerMgrImpl.java
@Test
    public void testSetupInitialChannel()
    {
        final RemoteChannel remoteChannel = mock(RemoteChannel.class, 
                withSettings().extraInterfaces(SocketChannel.class));
        final String hostname = "12.11.10.9";
        when(((SocketChannel)remoteChannel).getHost()).thenReturn(hostname);
        when(((SocketChannel)remoteChannel).getPort()).thenReturn(5001);
        
        final Map<Integer, Set<RemoteChannel>> channelsMap = new HashMap<>();
        final Set<RemoteChannel> channelsSet = new HashSet<>();
        channelsSet.add(remoteChannel);
        channelsMap.put(100, channelsSet);
        
        //Setup remote channel lookup so that there is one channel initially.
        when(m_ChannelLookup.getAllChannels()).thenReturn(channelsMap);
        
        m_SUT.setup();
        
        final ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        final Event controllerAdded = eventCaptor.getValue();
        assertThat(controllerAdded.getTopic(), is(ControllerMgr.TOPIC_CONTROLLER_ADDED));
        assertThat(controllerAdded.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is((Object)100));
        
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Controller Info:", 
                String.format("Added controller 0x%08x", 100));
    }
/**
     * Verify that a controller model is created if the remote channel lookup contains any channels upon setup.
     */
Verify that a controller model is created if the remote channel lookup contains any channels upon setup.
Verify that a controller model is created if the remote channel lookup contains any channels upon setup .
@Test
    public void testSetupInitialChannel()
    {
        final RemoteChannel remoteChannel = mock(RemoteChannel.class, 
                withSettings().extraInterfaces(SocketChannel.class));
        final String hostname = "12.11.10.9";
        when(((SocketChannel)remoteChannel).getHost()).thenReturn(hostname);
        when(((SocketChannel)remoteChannel).getPort()).thenReturn(5001);
        final Map<Integer, Set<RemoteChannel>> channelsMap = new HashMap<>();
        final Set<RemoteChannel> channelsSet = new HashSet<>();
        channelsSet.add(remoteChannel);
        channelsMap.put(100, channelsSet);
        when(m_ChannelLookup.getAllChannels()).thenReturn(channelsMap);
        m_SUT.setup();
        final ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin).postEvent(eventCaptor.capture());
        final Event controllerAdded = eventCaptor.getValue();
        assertThat(controllerAdded.getTopic(), is(ControllerMgr.TOPIC_CONTROLLER_ADDED));
        assertThat(controllerAdded.getProperty(SharedPropertyConstants.EVENT_PROP_CONTROLLER_ID), is((Object)100));
        verify(m_GrowlUtil).createGlobalFacesMessage(FacesMessage.SEVERITY_INFO, "Controller Info:", 
                String.format("Added controller 0x%08x", 100));
    }
@ Test public void testSetupInitialChannel ( ) { final RemoteChannel remoteChannel = mock ( RemoteChannel . class , withSettings ( ) . extraInterfaces ( SocketChannel . class ) ) ; final String hostname = "12.11.10.9" ; when ( ( ( SocketChannel ) remoteChannel ) . getHost ( ) ) . thenReturn ( hostname ) ; when ( ( ( SocketChannel ) remoteChannel ) . getPort ( ) ) . thenReturn ( 5001 ) ; final Map < Integer , Set < RemoteChannel > > channelsMap = new HashMap < > ( ) ; final Set < RemoteChannel > channelsSet = new HashSet < > ( ) ; channelsSet . add ( remoteChannel ) ; channelsMap . put ( 100 , channelsSet ) ; when ( m_ChannelLookup . getAllChannels ( ) ) . thenReturn ( channelsMap ) ; m_SUT . setup ( ) ; final ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin ) . postEvent ( eventCaptor . capture ( ) ) ; final Event controllerAdded = eventCaptor . getValue ( ) ; assertThat ( controllerAdded . getTopic ( ) , is ( ControllerMgr . TOPIC_CONTROLLER_ADDED ) ) ; assertThat ( controllerAdded . getProperty ( SharedPropertyConstants . EVENT_PROP_CONTROLLER_ID ) , is ( ( Object ) 100 ) ) ; verify ( m_GrowlUtil ) . createGlobalFacesMessage ( FacesMessage . SEVERITY_INFO , "Controller Info:" , String . format ( "Added controller 0x%08x" , 100 ) ) ; }
Verify that a controller model is created if the remote channel lookup contains any channels upon setup.
Verify that a controller model is created if the remote channel lookup contains any channels upon setup .
//Setup remote channel lookup so that there is one channel initially.