mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/controller/TestControllerMgrImpl.java
@Test
    public void testFlushControllerList()
    {
        //controllerId
        int contNew = 6431;
        
        RemoteChannel channel = addChannelMockHelper(contNew);//mock channel lookup
        
        //mock addition of controller
        m_ChannelHelper.handleEvent(createBasicChannelUpdatedEvent(channel, contNew));
        //mock sys info response for new controller
        mockControllerMessage(contNew, BaseMessageType.ControllerInfo);

        //verify the controller was added
        assertThat(m_SUT.getController(contNew), is(notNullValue()));
        
        //replay with no channels being returned for the controller id
        Map<Integer, Set<RemoteChannel>> channels = new HashMap<Integer, Set<RemoteChannel>>();
        channels.put(contNew, new HashSet<RemoteChannel>());
        when(m_ChannelLookup.getAllChannels()).thenReturn(channels);
 
        //verify that null is returned because the controller has no channels
        assertThat(m_SUT.getController(contNew), nullValue());
        
        //Verify that a controller removed event was posted for the controller.
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(3)).postEvent(eventCaptor.capture());
        
        final Event removedEvent = eventCaptor.getValue();
        assertThat(removedEvent.getTopic(), is(ControllerMgr.TOPIC_CONTROLLER_REMOVED));
    }
/**
     * Verify flushing of controller list.
     */
Verify flushing of controller list.
Verify flushing of controller list .
@Test
    public void testFlushControllerList()
    {
        int contNew = 6431;
        RemoteChannel channel = addChannelMockHelper(contNew);
        m_ChannelHelper.handleEvent(createBasicChannelUpdatedEvent(channel, contNew));
        mockControllerMessage(contNew, BaseMessageType.ControllerInfo);
        assertThat(m_SUT.getController(contNew), is(notNullValue()));
        Map<Integer, Set<RemoteChannel>> channels = new HashMap<Integer, Set<RemoteChannel>>();
        channels.put(contNew, new HashSet<RemoteChannel>());
        when(m_ChannelLookup.getAllChannels()).thenReturn(channels);
        assertThat(m_SUT.getController(contNew), nullValue());
        ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
        verify(m_EventAdmin, times(3)).postEvent(eventCaptor.capture());
        final Event removedEvent = eventCaptor.getValue();
        assertThat(removedEvent.getTopic(), is(ControllerMgr.TOPIC_CONTROLLER_REMOVED));
    }
@ Test public void testFlushControllerList ( ) { int contNew = 6431 ; RemoteChannel channel = addChannelMockHelper ( contNew ) ; m_ChannelHelper . handleEvent ( createBasicChannelUpdatedEvent ( channel , contNew ) ) ; mockControllerMessage ( contNew , BaseMessageType . ControllerInfo ) ; assertThat ( m_SUT . getController ( contNew ) , is ( notNullValue ( ) ) ) ; Map < Integer , Set < RemoteChannel > > channels = new HashMap < Integer , Set < RemoteChannel > > ( ) ; channels . put ( contNew , new HashSet < RemoteChannel > ( ) ) ; when ( m_ChannelLookup . getAllChannels ( ) ) . thenReturn ( channels ) ; assertThat ( m_SUT . getController ( contNew ) , nullValue ( ) ) ; ArgumentCaptor < Event > eventCaptor = ArgumentCaptor . forClass ( Event . class ) ; verify ( m_EventAdmin , times ( 3 ) ) . postEvent ( eventCaptor . capture ( ) ) ; final Event removedEvent = eventCaptor . getValue ( ) ; assertThat ( removedEvent . getTopic ( ) , is ( ControllerMgr . TOPIC_CONTROLLER_REMOVED ) ) ; }
Verify flushing of controller list.
Verify flushing of controller list .
//controllerId //mock channel lookup //mock addition of controller //mock sys info response for new controller //verify the controller was added //replay with no channels being returned for the controller id //verify that null is returned because the controller has no channels //Verify that a controller removed event was posted for the controller.